Sewdar1 Posted April 19, 2014 Share Posted April 19, 2014 Can anyone help? When we receive drawings from architects we change all items to colour 252 then save and use this drawing as an XREF to overlay our own detail. We normally apply SETBYLAYER to all items, then change all layers to 252. We then need to manually explode all blocks and change the colour which can be very time consuming in big drawings. The command needs to apply the same changes to blocks and nested blocks. Thanks Quote Link to comment Share on other sites More sharing options...
Snownut Posted April 19, 2014 Share Posted April 19, 2014 Not to mention the drawing size must expand considerably (by exploding all blocks)... Quote Link to comment Share on other sites More sharing options...
Snownut Posted April 19, 2014 Share Posted April 19, 2014 Welcome to CAD tutor, please keep in mind that all information given here is being donated by the person giving it, so do your part and perform a thorough search of just what you are looking for prior to posting a request for free programming. Do some searching regarding changing block layers/colors etc., there are good examples out there. Quote Link to comment Share on other sites More sharing options...
hmsilva Posted April 19, 2014 Share Posted April 19, 2014 (edited) Can anyone help?When we receive drawings from architects we change all items to colour 252 then save and use this drawing as an XREF to overlay our own detail. We normally apply SETBYLAYER to all items, then change all layers to 252. We then need to manually explode all blocks and change the colour which can be very time consuming in big drawings. The command needs to apply the same changes to blocks and nested blocks. The SETBYLAYER command, change blocks and nested blocks color too... As a "demo"... (defun c:demo () (command "_.layer" "_co" "252" "*" "") (command "_.setbylayer" "all" "" "y" "y" "") (princ) ) HTH Henrique Edited April 19, 2014 by hmsilva Quote Link to comment Share on other sites More sharing options...
Sewdar1 Posted April 19, 2014 Author Share Posted April 19, 2014 Many thanks for the reply hmsilva. Snownut - I had tried searching the threads before posting but couldn't find what I needed. I did continue searching after posting and now think I have found the solution. Along with hmsilva's reply we are on the way to resolving this one. Will save a lot of time! Thanks Quote Link to comment Share on other sites More sharing options...
hmsilva Posted April 19, 2014 Share Posted April 19, 2014 Many thanks for the reply hmsilva. You're welcome, Sewdar1 Henrique Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2014 Share Posted April 20, 2014 Good concise solution Henrique - you could even combine those command expressions into one line, e.g.: (defun c:demo nil (command "_.-layer" "_co" "252" "*" "" "_.setbylayer" "all" "" "y" "y" "") (princ) ) Here is an alternative using Visual LISP: (defun c:c252 ( / doc ) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-layers doc)(vla-put-color lay 252)) (vlax-for blk (vla-get-blocks doc) (if (= :vlax-false (vla-get-isxref blk)) (vlax-for obj blk (vl-catch-all-apply 'vla-put-color (list obj acbylayer))) ) ) (vla-regen doc acallviewports) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
hmsilva Posted April 20, 2014 Share Posted April 20, 2014 Good concise solution Henrique - you could even combine those command expressions into one line, e.g.: Thank you Lee. I was just trying to demonstrate to the OP that it was possible just using two AutoCAD core commands. Henrique Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2014 Share Posted April 20, 2014 Thank you Lee.I was just trying to demonstrate to the OP that it was possible just using two AutoCAD core commands. Indeed - good thinking. 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.