Changing layers of blocks, hatches, etc


I am currently working on a script for re-ordering everything in an imported .dwg file by layer colors. The issue here is, that often we will get files from clients or other stakeholders, which are very messy and can have hundreds of layers, and since colors most often correspond to line widths in CAD files, it is relevant to be able to sort objects by layer colors.

The issue here is, that while the Dynamic Geometry pipeline (which is just about my favorite component) can read all the geometry types we could wish for, the “Modify Object Attributes” component cannot change the layer of blocks, hatches, etc.

Can this be fixed relatively easily? Or is there a workaround that you can think of?

Thanks in advance!

Ah — a short script should sort this out. “Modify Object Attributes” actually takes object Guid as an input — for non-native-gh types (hatch, blockinstance, etc) this can be retrieved with a short script:


var obj = x as RhinoObject;
A = obj.Id;

Nice and simple! Thanks :slight_smile:

Is there a way to do this with CERTAIN blocks in the document. I have a lot of blocks in a document and want to ideally set a few of them to be analyzed from the document. Then I want to analyze each block and write a user key/value in it. Then in another file I want to read back those user keys/values.

Note: there was a bunch of text/images here to explain the problem I have since figured out. Explode Block and then Object Attributes gives you the attributes of everything INSIDE the block. I wasn’t aware you could get the Object Attributes of the Block by just connecting that straight to the geometry pipeline.

Is it possible to retrieve rather than modify the Attributes using the GUID? I have a bunch of GUIDs (around 10) of blocks and would like to get their attributes without having to filter through all blocks (there are more than 100.000 instances in the file).

Sorry, last question about attributes in Human:

How does the name input for Geometry pipeline relate to the name inside attributes. Aren’t they the same? Yet if I input the name it shows me from the attribute and try to filter with that I get no results!? Are they not the same?

I wish there were native block support in GH. Every plugin creates it’s own very similar but non-compatible data type for it.

1 Like

I agree, although I could do all the blocks operations I need with Human alone if only it could bake nested blocks… @andheum , any plans for that ?

The ability to retrieve sub-blocks from nested blocks would be fantastic too.
Currently, the way the “Explode Blocks Recursively” works is quite difficult to work with.
For example : how would one modify the “LAYER” property of sub-block instances inside nested blocks with the current toolset ?