ctrlaltdel Posted August 8, 2016 Share Posted August 8, 2016 Found a lisp to change entity colour by layer name. But I require for it to work on wildcards for layer names. Example: Change colour for *ANO* layer names to green colour This code works but not for wildcards (defun c:Test (/ doc) (vlax-for block (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for x block (if (eq (vla-get-layer x) "[color=red][b]*ANO*[/b][/color]") (vla-put-color x [color=red][b]3[/b][/color]) ) ) ) (vla-regen doc acActiveViewport) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 8, 2016 Share Posted August 8, 2016 ([color="blue"]wcmatch [/color](vla-get-layer x) "*ANO*") Quote Link to comment Share on other sites More sharing options...
ctrlaltdel Posted August 9, 2016 Author Share Posted August 9, 2016 (edited) ([color="blue"]wcmatch [/color](vla-get-layer x) "*ANO*") Tharwat sir, I get an error when load the lisp Command: (LOAD "E:lsp/ChangeLayerColour.lsp")Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Command: test nil After running the lisp all entities change colour instead of following wildcard this is the lisp (defun c:Test (/ doc) (vlax-for block (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for x block [b][color="blue"](wcmatch (vla-get-layer x) "*ano*")[/color][/b] (vla-put-color x 3) ) ) ) (vla-regen doc acActiveViewport) (princ) ) (vl-load-com) Edited August 9, 2016 by ctrlaltdel Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 9, 2016 Share Posted August 9, 2016 You should add 'if' function before the wildcard function as in your first post of this thread. Quote Link to comment Share on other sites More sharing options...
ctrlaltdel Posted August 9, 2016 Author Share Posted August 9, 2016 You should add 'if' function before the wildcard function as in your first post of this thread. Thanks Tharwat. (defun c:Test (/ doc) (vlax-for block (vla-get-blocks (setq doc (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for x block (if (wcmatch (vla-get-layer x) "*ano*") (vla-put-color x 3) ) ) ) (vla-regen doc acActiveViewport) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 9, 2016 Share Posted August 9, 2016 Thanks Tharwat. Good for you. 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.