Changing Colour of Nested Block

Changing Colour of Nested Block

Sujan.Maharjan
Collaborator Collaborator
4,104 Views
7 Replies
Message 1 of 8

Changing Colour of Nested Block

Sujan.Maharjan
Collaborator
Collaborator

Hi Is there a Autolisp to change Colour of a Nested block Retaining other properties? 


"Revit Lies in the tension between what we want to do and what can be done!"
0 Likes
Accepted solutions (1)
4,105 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant

@Anonymous_ wrote:

Hi Is there a Autolisp to change Colour of a Nested block Retaining other properties? 


If all elements in the nested Block have ByBlock color assigned, you can, but it would change the color of it in all insertions of the Block in which that one is nested.  Or, you could give such a nested Block itself a ByBlock color assignment in its insertion in the definition of the host Block, in which case it would take on whatever color is assigned to the host Block, and that could be different in every insertion, as long as you're careful about the colors of other things that you might not want to be the same color as the nested one [if any].

Kent Cooper, AIA
0 Likes
Message 3 of 8

Sujan.Maharjan
Collaborator
Collaborator

Hi

I have this Autolisp.

The problem with this is it changes all the layers to 0. Is there a way to do without changing layer names


"Revit Lies in the tension between what we want to do and what can be done!"
0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous_ wrote:

....

The problem with this is it changes all the layers to 0. Is there a way to do without changing layer names


If I am correct [interpreting a combination of parts of Posts 1 & 3] that you want to change the color [only, and not the Layer] of all parts of a Block, including all parts of any nested Blocks, I think you should be able to do it by:

 

1)  removing [or commenting out with a semicolon at the beginning] this line, which puts them on Layer 0:

 

          (vla-put-layer obj "0"); to Layer 0

 

2)  changing this line:


          (vla-put-color obj 256); color ByLayer

 

to use the color you want instead:

 

          (vla-put-color obj YourDesiredColor)

 

If you want them to be ByBlock color as suggested earlier, use 0 in place of YourDesiredColor.

 

Be aware that for nested Blocks, since it changes the color of pieces in the Block definition, it will change the color of every insertion of them, even any that are inserted on their own and not nested in other Blocks.  So if you ever want the color to vary, use ByBlock instead of an explicit color.

Kent Cooper, AIA
0 Likes
Message 5 of 8

Sujan.Maharjan
Collaborator
Collaborator
Hi,
I'm having trouble with
-Annotative Hatches
-Attributed blocks/texts
Any Solution?

"Revit Lies in the tension between what we want to do and what can be done!"
0 Likes
Message 6 of 8

john.uhden
Mentor
Mentor

I dug this up from 15 or so years ago.  It creates the command function "ByBlock" or just "BB"

 

John F. Uhden

Message 7 of 8

Anonymous
Not applicable

@john.uhden wrote:

I dug this up from 15 or so years ago.  It creates the command function "ByBlock" or just "BB"

 


ByBlock is great but it only works on top level block, I need it to work on nested blocks (inside top level block) too

Also, choosing multiple blocks at once would be nice instead of choosing them one by one

0 Likes
Message 8 of 8

john.uhden
Mentor
Mentor
So, you want to pick them from a list? I could make it so that you can
pick a nested block. Or maybe you want to attack all the blocks? Or maybe
you want all those options?

John F. Uhden

0 Likes