Way to select/insert all block definitions defined on x layer and change them to correct layer?

Hi everyone!

  • I am currently working on a team of a couple of people, utilizing block definitions inside Rhino.
  • I often encounter layers that I do no need, but do not get purged because a block definition was defined on that layer.
  • My workflow to deal with this is, try to delete layer>get name of block that is defined there>insert command>find block name>insert it> double click to edit>change layer on which block lays.

This is already a very time cosuming workflow for a simple task, but what is worse, when you try to delete the layer, Rhino does not name all block definition that are actually there, it tells you one at a time. So if you change the layer of one block and try to delete the layer, you then get a new message telling you there is another block on that same layer!

How can I deal with this? I was thinking a script that could identify all blocks that are defined on x layer, insert them, and change them to a correct user defined layer… Is this possible?

Thanks in advance,
Shynn

Any ideas if this is possible?

Hi @ShynnSup,

This sample script dumps the contexts of a instance definition:

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinopython/SampleDumpInstanceDefinition.py

You can modify this to get the definition object’s layers too.

– Dale

Hi @dale

I get following error when running the script :frowning: :

File “C:\Users\Shynn\AppData\Local\Temp\TempScript.py”, line 49
SampleDumpInstanceDefinition() # Call the function defined above
^
SyntaxError: expected an indented block

Hi @ShynnSup,

The script works here in Rhino 6.

It’s a simple error - make sure intending is correct on that line…

– Dale

Great, it run. Seems that Ctrl + C and Ctrl + V into Rhino PythonEditor deletes that indentation.

Not sure what the script is doing though, what do you mean by “dumps the contexts of a instance definition”? Can you help me modify it to change the layer of definition of all selected blocks?