shokoufeh Posted 9 hours ago Posted 9 hours ago Hi everyone I am looking for a lisp to quick select different objects according to their specific properties in the entire drawing. The objects I am going to select are: 1- Every line that has "start Z" or "End Z" "Not Equal" to zero. 2- All "Text" that have "Position Z" "Not Equal" to zero. 3- All "Block References" that have "Position Z" "Not Equal" to zero. 4- All "Polyline" that have "Elevation" "Not Equal" to zero. Actually, I have so many files in which, Z values are not zero (Z values are about for example 0.000001). It makes the file so difficult to edit. I want to select every object and manually change the Z values to "zero". Also, it would be great if you guys can help me by any other way, to solve my problem and change the whole drawing's Z value to "zero", if possible. If not, it doesn't matter. Help me to write this Lisp, so that the selection of the objects get easier. Below, I attach a simple sample of my file, in which, some block, text, or lines have Z value other than zero. Z Value Problem.dwg Quote
andyb57J Posted 7 hours ago Posted 7 hours ago try this one. ZLABEL-Label Z Values On Topography Lines.fas Quote
shokoufeh Posted 7 hours ago Author Posted 7 hours ago 9 minutes ago, andyb57J said: try this one. ZLABEL-Label Z Values On Topography Lines.fas 1.85 kB · 0 downloads thank you. It seems that this lisp finds the lines with Z value problem and adds a label near them. It is great that it can find the lines, but I don't want this label to be added near this lines. I only need to select them. Can this lisp file be modified, so that it changes the Z values of the selected lines, to Zero? I mean, it selects the lines and modifies the "Start Z" and "End Z" to 0. Quote
GLAVCVS Posted 6 hours ago Posted 6 hours ago (edited) Try (defun c:todoA0 (/ cj e le n to p1 p2) (IF (setq cj (ssget "x" '((0 . "TEXT,MTEXT,INSERT,LINE,LWP*")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq le (entget e) to (cdr (assoc 0 le)) p1 (assoc 10 le) ) (cond ((= to "LINE") (setq p2 (assoc 11 le)) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) (entmod (subst (cons 11 (list (cadr p2) (caddr p2) 0.0)) p2 le)) ) ((= to "LWPOLYLINE") (entmod (subst (cons 38 0.0) (assoc 38 le) le)) ) ((member to '("TEXT" "MTEXT" "INSERT")) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) ) ) ) ) (princ) ) Edited 6 hours ago by GLAVCVS 1 Quote
shokoufeh Posted 5 hours ago Author Posted 5 hours ago 16 minutes ago, GLAVCVS said: Try (defun c:todoA0 (/ cj e le n to p1 p2) (IF (setq cj (ssget "x" '((0 . "TEXT,MTEXT,INSERT,LINE,LWP*")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq le (entget e) to (cdr (assoc 0 le)) p1 (assoc 10 le) ) (cond ((= to "LINE") (setq p2 (assoc 11 le)) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) (entmod (subst (cons 11 (list (cadr p2) (caddr p2) 0.0)) p2 le)) ) ((= to "LWPOLYLINE") (entmod (subst (cons 38 0.0) (assoc 38 le) le)) ) ((member to '("TEXT" "MTEXT" "INSERT")) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) ) ) ) ) (princ) ) Wow It worked great. thank you very much. just one last question: Only "End Z" of lines are being modified to Zero. how can I make this modification to "Start Z" of lines, too? Quote
shokoufeh Posted 5 hours ago Author Posted 5 hours ago Just now, shokoufeh said: Wow It worked great. thank you very much. just one last question: Only "End Z" of lines are being modified to Zero. how can I make this modification to "Start Z" of lines, too? Z Value Problem-modified.dwg Quote
shokoufeh Posted 5 hours ago Author Posted 5 hours ago 4 minutes ago, shokoufeh said: Wow It worked great. thank you very much. just one last question: Only "End Z" of lines are being modified to Zero. how can I make this modification to "Start Z" of lines, too? Please check this code. I made a few modification, and I think now it works for both start and end Z values. ZRemove.txt Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago Try again (defun c:todoA0 (/ cj e le n to p1 p2) (IF (setq cj (ssget "x" '((0 . "TEXT,MTEXT,INSERT,LINE,LWP*")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq le (entget e) to (cdr (assoc 0 le)) p1 (assoc 10 le) ) (cond ((= to "LINE") (setq p2 (assoc 11 le)) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) (entmod (subst (cons 11 (list (cadr p2) (caddr p2) 0.0)) p2 (entget e))) ) ((= to "LWPOLYLINE") (entmod (subst (cons 38 0.0) (assoc 38 le) le)) ) ((member to '("TEXT" "MTEXT" "INSERT")) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) ) ) ) ) (princ) ) 1 Quote
shokoufeh Posted 5 hours ago Author Posted 5 hours ago 9 minutes ago, GLAVCVS said: Try again (defun c:todoA0 (/ cj e le n to p1 p2) (IF (setq cj (ssget "x" '((0 . "TEXT,MTEXT,INSERT,LINE,LWP*")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (setq le (entget e) to (cdr (assoc 0 le)) p1 (assoc 10 le) ) (cond ((= to "LINE") (setq p2 (assoc 11 le)) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) (entmod (subst (cons 11 (list (cadr p2) (caddr p2) 0.0)) p2 (entget e))) ) ((= to "LWPOLYLINE") (entmod (subst (cons 38 0.0) (assoc 38 le) le)) ) ((member to '("TEXT" "MTEXT" "INSERT")) (entmod (subst (cons 10 (list (cadr p1) (caddr p1) 0.0)) p1 le)) ) ) ) ) (princ) ) GREAT. It works. Thank you very much Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago 13 minutes ago, shokoufeh said: Please check this code. I made a few modification, and I think now it works for both start and end Z values. ZRemove.txt 1.13 kB · 1 download Sounds good If you've tried it and it works: Quote
Steven P Posted 5 hours ago Posted 5 hours ago There was a thread a few days ago about speeding up a LISP to do the same, have look at that for ideas. I think the thread got as far as arcs are tricky to do with LISPs. You could use the flatten command for small drawings. This snippet will filter a selection set to lines or LWPolylines to anything not 0 Z (setq MySS (ssget (list (cons 0 "*TEXT,INSERT,LINE,LWPOLYLINE") '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "<>") (cons 38 0) '(-4 . "OR>") )) ; end list, end ssget ) Can be added to the other solutions herein the case that your drawing has a lot of lines / polylines / blocks it speeds it up a bit Link to other thread: 1 Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago (edited) 21 minutes ago, Steven P said: There was a thread a few days ago about speeding up a LISP to do the same, have look at that for ideas. I think the thread got as far as arcs are tricky to do with LISPs. You could use the flatten command for small drawings. This snippet will filter a selection set to lines or LWPolylines to anything not 0 Z (setq MySS (ssget (list (cons 0 "*TEXT,INSERT,LINE,LWPOLYLINE") '(-4 . "<OR") '(-4 . "*,*,<>") (list 10 0.0 0.0 0.0) '(-4 . "*,*,<>") (list 11 0.0 0.0 0.0) '(-4 . "<>") (cons 38 0) '(-4 . "OR>") )) ; end list, end ssget ) Can be added to the other solutions herein the case that your drawing has a lot of lines / polylines / blocks it speeds it up a bit Link to other thread: Sorry: The problem I referred to will never exist in a LWPOLYLINE: Forget what I said, if you managed to read the previous message Edited 5 hours ago by GLAVCVS Error 1 Quote
GLAVCVS Posted 5 hours ago Posted 5 hours ago Sorry: That problem will never exist in a LWPOLYLINE: Forget what I said, if you managed to read the previous message Quote
shokoufeh Posted 3 hours ago Author Posted 3 hours ago 1 hour ago, GLAVCVS said: Sorry: That problem will never exist in a LWPOLYLINE: Forget what I said, if you managed to read the previous message I was checking my files and I found out another problem. Except elements I mentioned (lines, poly lines, texts and blocks), the problem with Z values exist in other elements, as I mention below: Hatch: Elevation Leader: Vertex Z Ellipse: Start Z, Center Z, End Z Arc: Start Z, Center Z, End Z Circle: Center Z Solid: Elevation Attribute Definition: Text Alignment Z Array (Rectangular) : Base Z Please check this modified lisp and see if it is correct or not. This lisp doesn't work on HATCH. ZRemove.lsp Quote
Steven P Posted 3 hours ago Posted 3 hours ago I think hatch is the first '10' if an elevation has been set (10 0.0 0.0 'Z') Quote
Steven P Posted 3 hours ago Posted 3 hours ago 1 hour ago, GLAVCVS said: Sorry: The problem I referred to will never exist in a LWPOLYLINE: Forget what I said, if you managed to read the previous message Missed your message but am intrigued now... (a guess I would say you were saying LWPolyline has X, Y, Z coords - I've done the same many times too) Quote
shokoufeh Posted 3 hours ago Author Posted 3 hours ago 3 minutes ago, Steven P said: I think hatch is the first '10' if an elevation has been set (10 0.0 0.0 'Z') so, how should I change the code? Quote
GLAVCVS Posted 2 hours ago Posted 2 hours ago 28 minutes ago, Steven P said: 34 minutes ago, Steven P said: Missed your message but am intrigued now... (a guess I would say you were saying LWPolyline has X, Y, Z coords - I've done the same many times too) Yes I briefly forgot that LWPOLYLINES don't have a Z coordinate and instead use group 38 to define their elevation. Therefore @shokoufeh: the code you added to set the Z for LWPOLYLINES is unnecessary 1 Quote
shokoufeh Posted 2 hours ago Author Posted 2 hours ago 3 minutes ago, GLAVCVS said: Yes I briefly forgot that LWPOLYLINES don't have a Z coordinate and instead use group 38 to define their elevation. Therefore @shokoufeh: the code you added to set the Z for LWPOLYLINES is unnecessary Oh OK. Thanks for mentioning Quote
Steven P Posted 1 hour ago Posted 1 hour ago 1 hour ago, shokoufeh said: so, how should I change the code? Use what you have done previously but for dx code 10: (foreach dxf le (if (= (car dxf) 10) (setq le (subst (cons 10 (zeroz (cdr dxf))) dxf le)) ) ) Quote
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.