rcb007 Posted May 28, 2021 Posted May 28, 2021 I am running into error when I am running my routine. It basically states a draworder based upon xref drawing names. In some instances, the drawing I run this in does not have an Aerial , or Building. But usually once it activates that command it stops and does not finish the routine. (command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 . "*Aerial*"))) "" "_B") (command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 . "*Proposed*"))) "" "_B") (command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 . "*survey*"))) "" "_B") (command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 . "*Building*"))) "" "_B") Anyone have an idea around this possibly? Thank you! Quote
mhupp Posted May 28, 2021 Posted May 28, 2021 (edited) Use if statements If anything selected use Draworder command on the selection set else skip it (if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*")))) (vl-cmdf "._DRAWORDER" SS "" "_B") ) (if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Proposed*")))) (vl-cmdf "._DRAWORDER" SS "" "_B") ) (if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*survey*")))) (vl-cmdf "._DRAWORDER" SS "" "_B") ) (if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Building*")))) (vl-cmdf "._DRAWORDER" SS "" "_B") ) Edited June 3, 2021 by mhupp Changed 'set to 'setq Quote
ronjonp Posted May 28, 2021 Posted May 28, 2021 (edited) Here's another way to refactor it: (foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*") (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f)))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) ) Or if you're just sending them all to back without regard to each other: (if (setq ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*")))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) Edited June 3, 2021 by ronjonp *changed 'set to 'setq' Quote
rcb007 Posted June 3, 2021 Author Posted June 3, 2021 Sorry to bring this up again. I do know what happened. It was working but now get the following error. From what I see everything looks ok. Command: basic ; error: bad argument type: symbolp nil (defun c:Basic (/ ss) (if (set ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*")))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) (foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*") (if (set ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f)))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) ) (princ)) Thank you for any help. Quote
ronjonp Posted June 3, 2021 Posted June 3, 2021 3 minutes ago, rcb007 said: Sorry to bring this up again. I do know what happened. It was working but now get the following error. From what I see everything looks ok. Command: basic ; error: bad argument type: symbolp nil (defun c:Basic (/ ss) (if (set ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*")))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) (foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*") (if (set ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f)))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) ) (princ)) Thank you for any help. Not sure what is going on but why are you running both of the draworder functions? Quote
rcb007 Posted June 3, 2021 Author Posted June 3, 2021 Sorry i was using it to test with. I just commented out the other line. Quote
mhupp Posted June 3, 2021 Posted June 3, 2021 i don't know but it has set instead of setq is that a thing? (defun c:Basic () (foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*") (if (setq ss (ssget "_X" '((0 . "INSERT") (cons 2 f)))) (vl-cmdf "._DRAWORDER" ss "" "_B") ) ) (princ) ) Quote
ronjonp Posted June 3, 2021 Posted June 3, 2021 (edited) 10 minutes ago, mhupp said: lol looks like we all did it. Hahahaha .. that's what a copy paste gets you Edited June 3, 2021 by ronjonp 1 Quote
rcb007 Posted June 3, 2021 Author Posted June 3, 2021 Interesting... Something like that. It seems its working. so guilty with the copy paste thing lol. Thank you again guys! 1 Quote
BIGAL Posted June 3, 2021 Posted June 3, 2021 (edited) For your info SET is a valid function used often to create variables on the fly. (set 'a "abc") (setq num 123) (setq abc "werrt") (set (read (strcat "X" (rtos num 2 0))) abc) Edited June 4, 2021 by BIGAL Quote
ronjonp Posted June 4, 2021 Posted June 4, 2021 Another example: (mapcar 'set '(a b c) '(1 2 3)) (mapcar 'print (list a b c)) 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.