Organic Posted March 6, 2009 Share Posted March 6, 2009 Can someone create a lisp where it sets the Start Z value and End Z value of all lines in model space to 0? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 7, 2009 Share Posted March 7, 2009 Lines and polylines, or just lines? Quote Link to comment Share on other sites More sharing options...
Came Posted March 7, 2009 Share Posted March 7, 2009 What's that try sites http://ronleigh.info/autolisp/index.htm http://klobouk.fsv.cvut.cz/~chour/Lisp/Chapter%201.htm or if you layzy http://www.jtbworld.com/lisp.htm http://www.cadmonkey.com/lisp.htm give me a month and i will wrote that one for you am learning basic HE s not sleeping Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 7, 2009 Share Posted March 7, 2009 Try this for lines: (defun c:0line (/ ss pt1 pt2 lst) (if (setq ss (ssget "X" (list (cons 0 "LINE") (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq ss (mapcar 'entget (mapcar 'cadr (ssnamex ss)))) (foreach elst ss (setq pt1 (cdr (assoc 10 elst)) pt2 (cdr (assoc 11 elst))) (setq pt1 (subst 0.0 (last pt1) pt1) pt2 (subst 0.0 (last pt2) pt2)) (setq lst (subst (cons 10 pt1) (assoc 10 elst) elst)) (entmod (subst (cons 11 pt2) (assoc 11 lst) lst)))) (princ "\n<!> No Lines Found <!>")) (princ)) Not my best, but its gone midnight here. Quote Link to comment Share on other sites More sharing options...
Came Posted March 7, 2009 Share Posted March 7, 2009 dam you're fast i have done half and with some errors am on a role :wink: Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 7, 2009 Share Posted March 7, 2009 dam you're fast i have done half and with some errors am on a role :wink: Keep at it If you need any help, just let me know Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 7, 2009 Share Posted March 7, 2009 To be honest, in my posted LISP i wanted to change both start points and end points at the same time using a mapcar function, but for some reason only the endpoint would be updated when I did it that way, so had to settle for the less elegant method. Quote Link to comment Share on other sites More sharing options...
CarlB Posted March 7, 2009 Share Posted March 7, 2009 Sometimes less elegant methods work fine, maybe even less code! For example you could select all lines & polylines, (say ss1) then use the move command on them to "flatten" to 0: (command "._move" ss1 "" '(0.0 0.0 1e99) "" "._move" ss1 "" '(0.0 0.0 -1e99) "") Quote Link to comment Share on other sites More sharing options...
David Bethel Posted March 7, 2009 Share Posted March 7, 2009 Maybe it has changed over the years, but "_.CHANGE " "_P" "_E" would be sweet if it dealt with differing z values Command: CHANGE Select objects: l 1 found Select objects: Specify change point or [Properties]: _P Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: _E Specify new elevation <varies>: 0 Enter property to change [Color/Elev/LAyer/LType/ltScale/LWeight/Thickness]: Cannot change elevation of objects with differing Z coordinates. So its back to AutoLISP Change all model space LINEs Z axis values to 0.0 [b][color=BLACK]([/color][/b]defun c:flatline [b][color=FUCHSIA]([/color][/b]/ ss i en ed p10 p11 n10 n11[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]67 . 0[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq i [b][color=MAROON]([/color][/b]sslength ss[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]minusp [b][color=BLUE]([/color][/b]setq i [b][color=RED]([/color][/b]1- i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss i[b][color=GREEN])[/color][/b] ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b] p10 [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 10 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] n10 [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]car p10[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cadr p10[b][color=BLUE])[/color][/b] 0.0[b][color=GREEN])[/color][/b] p11 [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 11 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] n11 [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]car p11[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cadr p11[b][color=BLUE])[/color][/b] 0.0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmod [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 10 n10[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 10 ed[b][color=BLUE])[/color][/b] ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmod [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 11 n11[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 11 ed[b][color=BLUE])[/color][/b] ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
dave buckberry Posted March 8, 2009 Share Posted March 8, 2009 try this i found it the Other Day for A freind of mine He Was Having problems With Files That he was sent All The plan Drawings Were on Diffrent z's This moved All to 0 And Did not miss any he Was happy Hope this Helps Download And Load Lisp And Type Z0 in Commandline Select All In Drawing Then It moves All Or only select What you need to move Regards Dave b MOVEZ.lsp Quote Link to comment Share on other sites More sharing options...
dpgf Posted March 30, 2009 Share Posted March 30, 2009 try this i found it the Other Day for A freind of mine He Was Having problems With Files That he was sent All The plan Drawings Were on Diffrent z's This moved All to 0 And Did not miss any he Was happy Hope this Helps Download And Load Lisp And Type Z0 in Commandline Select All In Drawing Then It moves All Or only select What you need to move Regards Dave b Works on autocad 2010? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 30, 2009 Share Posted March 30, 2009 Works on autocad 2010? What are you referring to? Quote Link to comment Share on other sites More sharing options...
mlutzen Posted April 14, 2009 Share Posted April 14, 2009 Hey everyone, I have R14 and am trying to use survey drawings to create 2D images. I have lots of lines that do not have z = 0. I have tried the posted LISPs and keep getting AutoLISP stack overflows. I have looked all over for a LISP to make both end points with a z = 0. Can anyone help as I have 20 drawings to work on. Quote Link to comment Share on other sites More sharing options...
Organic Posted April 14, 2009 Author Share Posted April 14, 2009 I found an easy way to do this actually. Just use Quick Properties to select all lines in the drawing, then on the Properties palette you can easily set the start and end Z values to 0 (all at the same time). Thanks for those with lisps, they got me though till I found out how to dio it the easy way lol. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 14, 2009 Share Posted April 14, 2009 Have you tried a LISP like this? To "flatten" all objects: (defun c:flat (/ laylst ss ssObj j) (vl-load-com) (vlax-for lay (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))) (setq laylst (cons lay laylst))) (mapcar '(lambda (l) (vla-put-lock l :vlax-false)) laylst) (if (setq ss (ssget "X" (list (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq ssObj (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))) j 0) (foreach Obj ssObj (foreach n '(1e99 -1e99) (if (vl-catch-all-error-p (vl-catch-all-apply '(lambda (x) (vla-move x (vlax-3d-point (list 0 0 0)) (vlax-3d-point (list 0 0 n)))) (list Obj))) nil (setq j (1+ j))))) (princ (strcat "\n" (rtos (/ j 2.0)) " Objects Flattened."))) (princ "\n<!> No Objects Found <!>")) (princ)) Quote Link to comment Share on other sites More sharing options...
ReMark Posted April 14, 2009 Share Posted April 14, 2009 mlutzen: For Release 14 Vladmir Livshiz's Flatten.lsp routine should work quite nicely. The other option is to use the Change command. Change > Properties > All > Elevation > 0 > Enter. Done. Note: There is a Flat.lsp routine in the CADTutor AutoLisp Archive section too. Quote Link to comment Share on other sites More sharing options...
mlutzen Posted April 16, 2009 Share Posted April 16, 2009 Thanks for the tip on "Flatten", change only works with elevation and I had differing z coordiates which also prevented global quick prop. this is the working file. Thanks again everyone, this has saved lots of tedious blah....... Flatten.LSP Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.