ILoveMadoka Posted January 12, 2023 Posted January 12, 2023 This code (setq ss (ssget "X" '((62 . 5)))) finds all blue objects across multiple sheets inside a drawing. (I don't know the VLA equivalent..) How do I change the color to BYLAYER for all objects in the selection set? When I've tried CHANGE/CHPROP I get errors.. ## were not in current space I am anticipating that it's something simple but it evades me at the moment... Quote
mhupp Posted January 12, 2023 Posted January 12, 2023 (edited) Have to use entmod usually you cant use (command "_.comand" SS "") on things you cant select with a mouse click. so like things on another tab or inside a block. (defun C:test (/ ss) (if (setq ss (ssget "X" '((62 . 5)))) (foreach ent (reverse (mapcar 'cadr (ssnamex ss))) (entmod (append (entget ent) (list '(62 . 256)))) ) ) (princ) ) -edit might also need a regen Edited January 12, 2023 by mhupp Quote
ILoveMadoka Posted January 17, 2023 Author Posted January 17, 2023 Thank you... If I have the code below.. (setq ss1 (ssget "_X" (list (cons 62 5)))) How do I add a second color to the selection set? I want to pick both blue and cyan objects.. I tried this (setq ss1 (ssget "_X" (list (cons 62 5)(cons 62 4)))) I know there is some sort of separator in there somehow.. Quote
Steven P Posted January 17, 2023 Posted January 17, 2023 As a hint.... (setq ss1 (ssget "_X" (list (cons 62 5)(cons 62 4)))) the selection set filter 'list' is a logical AND for each item - so you are looking for an object colour 5 AND colour 4... Quote
mhupp Posted January 17, 2023 Posted January 17, 2023 (edited) Needs to be "OR" because an item can't be both colors. so it won't find anything with and. http://lee-mac.com/ssget.html#logical (defun C:test (/ ss) (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>")))) (foreach ent (reverse (mapcar 'cadr (ssnamex ss))) (entmod (append (entget ent) (list '(62 . 256)))) ) (prompt "\nNothing Found") ) (princ) ) Edited January 17, 2023 by mhupp update code Quote
ILoveMadoka Posted January 17, 2023 Author Posted January 17, 2023 (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>")))) This does not work for me. It's missing a paren and if I manually close it I get *Cancel* This also returns a *Cancel* (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>"))))) This works (setq ss1 (ssget "_X" (list (cons 62 5)))) (setq ss2 (ssget "_X" (list (cons 62 4)))) (setq ss3 (acet-ss-union (list ss1 ss2))) But is it the "best way?" I was attempting to select everything that is BLUE and everything that is CYAN in a single SSGET statement. Is that not possible? Quote
Steven P Posted January 17, 2023 Posted January 17, 2023 This might be your problem: (if Your second line: (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>"))))) read as "If SS is somethng do... nothing" - you'll maybe be wanting to remove the 'if' or before your closing bracket tell the LISP what to do: (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>")))) (progn ;; do all your clever stuff here if selection set finds anything blue or cyan ) (progn ;; do all your other clever stuff here if nothing is blue or cyan ) ) often selection set is enclosed with an 'if' so that the LISP doesn't fail if there is nothing valid selected - you can go off and do something like an error message to the user 1 Quote
mhupp Posted January 17, 2023 Posted January 17, 2023 (edited) 2 hours ago, ILoveMadoka said: But is it the "best way?" See my updated code. I only posted the if line so you could replace it in the original code. sorry i didn't make the more clear. Edited January 17, 2023 by mhupp 1 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.