Jump to content

Looking for lisp command to make all items colour 252


Sewdar1

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by hmsilva
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...