jonathann3891 Posted June 19, 2019 Share Posted June 19, 2019 (edited) I'm wanting to create a way to quickly change the layers of a CADworx object. This is what I have so far but its not working like I want. The problem is no matter how many objects I select, it only changes the first then stops working completely. If I try to run it again and select another object it wont do anything. I need to be able to select objects manually. Can someone point me in the right direction? (defun C:ttt () (setq STL_SS nil) (graphscr) (setq STL_SS (ssget '((0 . "LINE")(8 . "CL_Steel"))));;;FIND ALL THE LINES ON LAYER CL-STEEL (setq CL_CNT 0) (if (/= STL_SS nil) (repeat (sslength STL_SS) (setq STL_NAME (ssname STL_SS CL_CNT)) (setvar "pickstyle" 0) (command "chprop" STL_NAME "" "LA" "BEAM_CL" "") (setq CL_CNT (1+ CL_CNT)) );;;repeat );;;if (setq STL_SS nil) (setq STL_SS (ssget "L" '((0 . "3DSOLID")(8 . "STEEL"))));;;FIND ALL THE SOLIDS ON LAYER STEEL (setq CL_CNT 0) (if (/= STL_SS nil) (repeat (sslength STL_SS) (setq STL_NAME (ssname STL_SS CL_CNT)) (command "chprop" STL_NAME "" "LA" "BEAM" "") (setq CL_CNT (1+ CL_CNT)) );;;repeat );;;if (setvar "pickstyle" 1) (princ) ) Edited June 20, 2019 by jonathann3891 Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 19, 2019 Share Posted June 19, 2019 Hi, Something like this? (defun c:test (/ s i n e ) (if (setq s (ssget '((-4 . "<OR") (-4 . "<AND") (0 . "LINE")(8 . "CL_Steel") (-4 . "AND>") (-4 . "<AND") (0 . "3DSOLID")(8 . "STEEL") (-4 . "AND>") (-4 . "OR>")))) (repeat (setq i (sslength s)) (setq i (1- i) e (entget (ssname s i)) ) (entmod (subst (cons 8 (if (= (cdr (assoc 0 e)) "LINE") "BEAM_CL" "BEAM")) (assoc 8 e) e)) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 20, 2019 Share Posted June 20, 2019 (edited) Nice Tharwat, just thinking the problem would lend its self to a list answer, the only problem is when calling the ssget would require repeated select but if "all" is the suggested option then can use "X" (defun AH:changelay (lst / s y x e) (setq y 0) (repeat (setq x (/ (length lst) 3)) (if (setq s (ssget "x" (list (cons 0 (nth y lst))(cons 8 (nth (+ y 1) lst))))) (repeat (setq i (sslength s)) (setq i (1- i) e (entget (ssname s i)) ) (entmod (subst (cons 8 (nth (+ y 2) lst))(assoc 8 e) e)) ) (alert (strcat "layer not found " (nth (+ y 1) lst))) ) (setq y (+ y 3)) ) (princ) ) (AH:changelay ( list "line" "Cl_Steel" "BEM_CL" "3DSOLID" "STEEL" "BEAM" "line" "Ex-Serv-Gas" "Gas-Main")) or (AH:changelay ( list "line" "Cl_Steel" "BEAM_CL" "3DSOLID" "STEEL" "BEAM" "line" "Ex-Serv-Gas" "Gas-Main" )) Could add the "x" as part of the list and check for a user slect. (AH:changelay ( list "line" "Cl_Steel" "BEAM_CL" "x" "3DSOLID" "STEEL" "BEAM" "" "line" "Ex-Serv-Gas" "Gas-Main" "X" ) ) Edited June 20, 2019 by BIGAL Quote Link to comment Share on other sites More sharing options...
jonathann3891 Posted June 20, 2019 Author Share Posted June 20, 2019 Tharwat that works perfectly and much simpler. Thanks! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 20, 2019 Share Posted June 20, 2019 45 minutes ago, jonathann3891 said: Tharwat that works perfectly and much simpler. Thanks! You're welcome anytime. Thank you @BIGAL. 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.