I am currently having some complications working with blocks and I was wondering if anyone could recommend a workaround for my situation, or help me develop a script that could make my life easier…
A week ago I posted at the scripting category but maybe it wasn’t the relevant category to do so.
Below I describe my current situation and problem:
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?
Mmm, I don’t want to change the layer the block is on, but the one on which it was defined. The one that shows when you enter block edit and select the geometry.
Hello - are the blocks simple, not nested, and you simply want to change the layer of all the objects contained in the block to one layer that you can specify?
Hi Pascal, some are nested, but most of the times the problem arises because one of the simple blocks that create the bigger blocks was created on the wrong layer.
So… I mean, I guess it is probably possible to make a script for this, I just need to know what you want to do exactly - can you give me a simple (but with nesting) example of the start and end situation that you want?
Here I upload both situations, hope it is clear. You will stumble across my problem if you try to delete any of the “unwanted layers” on the “start situation” Try to at least delete the “Red Blocks” sublayer from the “Unwanted” layer and you will see how tedious it can become when dealing with bigger files.
Ok, so all objects, from all blocks, go on one layer,and all the instances go on another layer. If that’s it, I should be able to help, though not right this minute - it’s a holiday here, it’s not raining, and my bike beckons…
@ShynnSup - Here’s a quick first cut - see how it works for you. So far it is a bigger hammer - it does all embedded blocks, no questions asked other than what layers to put things on. Linked block instances are moved to the instance layer, but not the objects to the definition layer of course.
To use the Python script use RunPythonScript, or a macro:
_-RunPythonScript "Full path to py file inside double-quotes"
Note this can be fancier - you could select blocks rather than do them all, delete the empty layers; that sort of thing. It could also be made ‘macro-able’ and not show you the GetLayer dialogs… etc.
I am afraid it isn’t working on my side.
I get the following error:
Message: Find() takes exactly 2 arguments (1 given)
Traceback:
line 29, in SimplifyEmbeddedBlockLayers, "C:\Users\Shynn\Desktop\SimplifyEmbeddedBlockLayers.py"
line 53, in <module>, "C:\Users\Shynn\Desktop\SimplifyEmbeddedBlockLayers.py"
I run the script, pressed select on the dialog, selected the object, then double clicked to select the layer. Then repeated for Instance Layer, resulting in the error message above.
It seems the script can run with no object being selected at no time, resulting in the same error message.
As a plus, could it be done to take multiple blocks at the same time?
Hi Shynn - if you just select a layer in the list and then OK, i.e. do not use the ‘Select’ button, just highlight a layer - does that work? I’ll deal with selecting an object to set the layer, I confess, I did not actually type that code.