Jump to content

Block won't Change Colour!


Bobzy20

Recommended Posts

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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...