Jump to content
Bobzy20

Block won't Change Colour!

Recommended Posts

Bobzy20
Posted (edited)

Hi

This 3D block doesn't wont to change colour at all, it wont allow me to go into Block Editor either.

I'm trying to put it on the block onto layer: G541-M_General lighting so it matches that layer colour.

Seems easy?

Block-Test.dwg

Edited by Bobzy20

Share this post


Link to post
Share on other sites
rkmcswain

It's an anonymous block

Can you explode it, change the properties as needed, then make it into a regular named block? Would that work for you?

Share this post


Link to post
Share on other sites
Cad64

I'm pretty sure it's because of the block name, *U1. Blocks with an asterisk preceding the name cannot be modified. I would explode the block and then reblock it.

Share this post


Link to post
Share on other sites
Bobzy20

Thanks, I could do that but I have 100's more that will need changing, perhaps a script to force it would be good.

Set by layer does nothing in this case.

Share this post


Link to post
Share on other sites
Cad64

You could do a search for a lisp routine to rename anonymous blocks. There are some out there, but I haven't used any so I can't recommend one.

Or, post a question in the Lisp section. I'm sure someone could probably write one or point you to one.

Share this post


Link to post
Share on other sites
Jef!
On 8/23/2018 at 10:03 AM, Bobzy20 said:

Thanks, I could do that but I have 100's more that will need changing, perhaps a script to force it would be good.

Set by layer does nothing in this case.

Hi there. Nah, for entities inside a block, if you want them to be of the color of the layer on which the block is inserted, the entities need to be "byblock"!
Here's a snippet that will modify all blocks named *U* and put everything inside by block. It might have unwanted effects if you have other *u blocks that you don'T want to handle like that (like modified dyn blocks). It also doesn'T go inside nested blocks, but it works fine on your drawing sample.

(defun c:ufix ( / acdoc regen)
  (vlax-for blk (vla-get-Blocks (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))))
    (if (wcmatch (vlax-get-property blk 'name) "`*U*")
      (vlax-for ent blk
        (if (and (vlax-property-available-p ent 'color T)
                 (not (= 0 (vlax-get-property ent 'color)))
            )
            (progn
              (vlax-put-property ent 'color 0)
              (setq regen T)
            )
        )
      )
    )
  )
  (if regen (vla-regen acdoc acAllViewports))
  (princ)
)

Try it and let me know how it works for you

Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×