I have a hundred or so block definitions in my file, each block containing somewhere between one and ten curves and points. I just realised that what I really want is to have the display colour of all those curves and points be ‘By Parent’ instead of ‘By Layer’. I can make the change manually by using BlockEdit on each block, selecting the geometry, changing the attributes and saving the block, but that’s a lot of tedious work.
Is there a command or button somewhere that allows me to set these properties en-masse?
Hi David, hope this script works. If you already have instances in the file then you may have to re-insert these if I recall correctly. This could also be scripted.
Option Explicit
Sub SetBlockObjectsColorByParent()
Dim arrBlocks, strBlock, arrObjects
arrBlocks = Rhino.BlockNames(True)
If IsArray(arrBlocks) Then
For Each strBlock In arrBlocks
arrObjects = Rhino.BlockObjects(strBlock)
If IsArray(arrObjects) Then
Call Rhino.ObjectColorSource (arrObjects, 3)
End If
Next
End If
End Sub
SetBlockObjectsColorByParent()
Yeah we can program it, but that’s not an option for most users.
Anyway, I also had to move all block definition elements into a separate layer so they wouldn’t get hidden when I change regular layers. So I went with a slightly adapted version of the above script.
Option Explicit
Call SetBlockObjectsColorByParent()
Sub SetBlockObjectsColorByParent()
Dim blockNames
blockNames = Rhino.BlockNames(True)
If (Not IsArray(blockNames)) Then
Exit Sub
End If
Dim blockName
For Each blockName In blockNames
Dim blockObjects
blockObjects = Rhino.BlockObjects(blockName)
If IsArray(blockObjects) Then
Call Rhino.ObjectColorSource(blockObjects, 3)
Call Rhino.ObjectLayer(blockObjects, "Block Elements")
End If
Next
End Sub
I don’t think that there is a good “hard-coded” solution for all the properties the users may want to change. Like in your case… also changing the Layer. It is possible to change all properties manually which works for “most users”. If a user has to deal with more blocks than one can handle manually then it is time for a bit of scripting