zwonko Posted January 27 Share Posted January 27 trying to set many layers transperency by autolisp. Is it another way or it only possible by "command". Part of sample code: (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (if (wcmatch (vla-get-name layer) "*|*") (progn (command "_-LAYER" "_TR" "35" (vla-get-name layer) "") ) ) (if (wcmatch (vla-get-name layer) "*map*|*") (progn (command "_-LAYER" "_TR" "55" (vla-get-name layer) "") ) ) ) The code is finding xref layers and setting the transperency, but it is slow. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 28 Share Posted January 28 (edited) Why not just: (command "_.-layer" "_tr" "35" "*|*" "_tr" "55" "*map*|*" "") Edited January 28 by Lee Mac 2 Quote Link to comment Share on other sites More sharing options...
mhupp Posted January 28 Share Posted January 28 (edited) Command always takes a second to run. so if you had about 50 layers that match the wcmatch its setting the first transparency to 35. then if it maches the 2nd wcmatch it then changes to 55 trans. this means it could take 50 to 100 seconds. using a cond function and swapping the order it would only execute the correct transparency on the layer. Lee's way works because its running the command once rather then 50 to 100 times. Tho I try and stay away from using command. if you don't want 100 lines of spam to the command prompt you have to set cmdecho to 0 then back after, also has a higher potential to error. this should work for autocad. might also have to throw in a regen to take effect. (vlax-for layer (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (cond ((wcmatch (vla-get-name layer) "*map*|*") (setpropertyvalue layer "Transparency" 55) ) ((wcmatch (vla-get-name layer) "*|*") (setpropertyvalue layer "Transparency" 35) ) ) ) Edited January 28 by mhupp 2 Quote Link to comment Share on other sites More sharing options...
zwonko Posted January 28 Author Share Posted January 28 WoW! @Lee Mac approach is fast. One thing and it is hundreads time faster. Tahnk You! @mhupp also thanks for You! problem is that I'm using ZWCAD which is lack of setpropertyvalue in LISP Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 28 Share Posted January 28 You're welcome @zwonko - whilst repeated calls to a command within a loop may be slow, the internal operations performed by commands are implemented in C++ and so will outstrip LISP when it comes to iterating over a collection and performing an operation on many items. 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.