paulmcz Posted September 17, 2011 Share Posted September 17, 2011 Is there a way to replace the ssget filter like '((62 . 5)) with a variable? When I set variable occ to (cons 62 5), ssget won't work with it. (setq ss (ssget "X" occ)) Here is the routine: (defun c:cch (/ ss a ln ent cc oc occ) (setq a nil cc (getint "\n Set new colour [integer]: ") oc (getint "\n Colour to be changed [integer]: ") occ (cons 62 oc) ) (if (= (getvar 'tilemode) 0) (progn (setvar 'tilemode 1) (setq a 2) ) ) (if (setq ss (ssget "X" occ)) (command "change" ss "" "p" "c" cc "") ) (setq ln (tblnext "layer" T)) (while ln (setq ent (entget (tblobjname "layer" (cdr (assoc 2 ln)))) ln (tblnext "layer") ) (if (= oc (cdr (assoc 62 ent))) (progn (setq ent (subst (cons 62 cc) occ ent)) (entmod ent) ) ) ) (if (= a 2) (setvar 'tilemode 0) ) (princ) ) Any idea anyone? Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 17, 2011 Share Posted September 17, 2011 (setq occ '((62 . 5))) Or: (setq occ (list (cons 62 5))) Then: (ssget "_X" occ) Alternatively: (setq occ '(62 . 5)) Or: (setq occ (cons 62 5)) Then: (ssget "_X" (list occ)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 17, 2011 Share Posted September 17, 2011 Maybe this will help: (defun c:cch ( / cc co en in ld oc ss ) (if (and (princ "\nSelect New Colour: ") (princ) (setq cc (acad_colordlg 1 nil)) (princ "\nSelect Colour to be Changed: ") (princ) (setq oc (acad_colordlg 1 nil)) ) (progn (if (setq ss (ssget "_X" (list (cons 62 oc)))) (repeat (setq in (sslength ss)) (setq en (entget (ssname ss (setq in (1- in))))) (entmod (subst (cons 62 cc) (assoc 62 en) en)) ) ) (while (setq ld (tblnext "LAYER" (null ld))) (if (= oc (abs (cdr (setq co (assoc 62 ld))))) (progn (setq en (entget (tblobjname "LAYER" (cdr (assoc 2 ld))))) (entmod (subst (cons 62 (* cc (if (minusp (cdr co)) -1 1))) co en)) ) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
paulmcz Posted September 17, 2011 Author Share Posted September 17, 2011 (list occ) did the trick. Thank you very much Lee. 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.