Jump to content

Is there any lisp to flatten to change the Z values of all lines, arcs, and polylines to 0?


Elektrik

Recommended Posts

When I try to fillet some lines, I fail to do so as their Z elevations are different. When I use flatten command, sometimes it works and I can then fillet them, but another times I can't fillet themeven  after using flatten command, and I have no idea why. The other problem I have with the flatten command i sthat it recreates flatten versions of blocks, but I do not want it to do that either. So, is there any lisp that would bring Z elevations to 0 so that I could always fillet lines, and would not recreate the flatten verions of blocks. Thanks in advance.

Link to comment
Share on other sites

48 minutes ago, Elektrik said:

When I try to fillet some lines, I fail to do so as their Z elevations are different. When I use flatten command, sometimes it works and I can then fillet them, but another times I can't fillet themeven  after using flatten command, and I have no idea why. The other problem I have with the flatten command i sthat it recreates flatten versions of blocks, but I do not want it to do that either. So, is there any lisp that would bring Z elevations to 0 so that I could always fillet lines, and would not recreate the flatten verions of blocks. Thanks in advance.

Please upload your sample.dwg

with a before and after

 

Link to comment
Share on other sites

What this code does: 

- Lines are no problem.  Everywhere the Z value is set to 0

 

- Arc: Arcs have a center; I set its z-value to 0

- Polyline: they have an elevation, just a number.  I set it to 0.

 

Things like polylines, circles, arcs... are always drawn on a UCS plane.  If that plane is not parallel to the current plane, then this code will not do what you want.

 

I don't touch anything else, like blocks, 3D polyline, ...  Just what you asked.

 

Command FLAT (feel free to rename)

 

(defun c:flat ( / ss i ent ip1 ip2 elv)

	;; lines
	(setq ss (ssget "_X" (list (cons 0 "LINE"))))
	(setq i 0)
	(repeat (sslength ss)
		(setq ent (ssname ss i))
		
		;; insert point start 
		(setq ip1 (cdr (assoc 10 (entget ent))))
		;; add a z-value 0.0 , or replace the z-value by 0.0 
		(setq ip1 (list
			(nth 0 ip1) (nth 1 ip1) 0.0
		))
		
		;; insert point start 
		(setq ip2 (cdr (assoc 11 (entget ent))))
		;; add a z-value 0.0 , or replace the z-value by 0.0 
		(setq ip2 (list
			(nth 0 ip2) (nth 1 ip2) 0.0
		))
		
		;; entity modify, by substituting groups
		(entmod (subst (cons 10 ip1) 	(assoc 10 (entget ent)) 	(entget ent) ))  	;; substitute IP start
		(entmod (subst (cons 11 ip2) 	(assoc 11 (entget ent)) 	(entget ent) ))  	;; substitute IP end
		
		(setq i (+ i 1))
	)

	;; ARC
	(setq ss (ssget "_X" (list (cons 0 "ARC"))))
	(setq i 0)
	(repeat (sslength ss)
		(setq ent (ssname ss i))
		;; insert point center 
		(setq ip1 (cdr (assoc 10 (entget ent))))
		;; add a z-value 0.0 , or replace the z-value by 0.0 
		(setq ip1 (list
			(nth 0 ip1) (nth 1 ip1) 0.0
		))
		
		(entmod (subst (cons 10 ip1) 	(assoc 10 (entget ent)) 	(entget ent) ))  	;; substitute IP center

		(setq i (+ i 1))
	)
	
	;; POLYLINE
	(setq ss (ssget "_X" (list (cons 0 "LWPOLYLINE"))))
	(setq i 0)
	(repeat (sslength ss)
		(setq ent (ssname ss i))
		;; Elevation
		(setq elv 0.0)
		(entmod (subst (cons 38 elv) 	(assoc 38 (entget ent)) 	(entget ent) ))  	;; substitute elevation
		(setq i (+ i 1))
	)
)

 

Edited by Emmanuel Delay
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...