Hello Everyone and @pascal .
I’m trying to make a Python Script called “Kill Layer” the intent is to select a layer and delete all of it’s contents and then delete the layer itself. my biggest hurdle now is some blocks contains elements in that layer that prevents purging, Is there a line in Python “Select the blocks instances that has specific objects in that layer”?
From there, delete these instances and continue purging.
Thank you in advance.
No, not in one go as far as I know, you would need to make your own small definition for that. Its’s not complicated, one would simply need to get all the block definitions in the file to see if they have objects on that layer. If any are found, then use
rs.DeleteBlock(definition_name) which handily will delete all the instances plus the definition. After this, the layer itself should be delete-able.
Something like this maybe (not thoroughly tested):
import rhinoscriptsyntax as rs
for blk_name in blk_names:
for obj_id in obj_ids:
for blk_def in blk_defs:
@Helvetosaur Thank you Sir! I’m going to include these functions in my script.