I’m trying to update a block via python. When I run the test code below, the block only updates as long as none of the newobj are blocks. I want to nest the selected blocks into the updated block, but it fails. There is not error or warning or anything. The block just doesn’t update.
import rhinoscriptsyntax as rs
block = rs.GetObject("Block", 4096)
blockname = rs.BlockInstanceName(block)
newobj = rs.GetObjects("New Objects")
rs.AddBlock(newobj,(0,0,0),blockname,True)
dale
(Dale Fugier)
January 31, 2019, 10:38pm
2
Hi @kyle_faulkner ,
In this case, it may be easier to just script the _-Block command.
– Dale
Thanks Dale.
I replaced
rs.AddBlock(newobj,(0,0,0),blockname,True)
with
rs.Command('-Block 0,0,0 "{}" Yes _Enter _Enter _Enter'.format(blockname))
and that seemed to work.
Is this a bug that’s causing the AddBlock() method to fail?
dale
(Dale Fugier)
January 31, 2019, 11:56pm
4
No, just a limitation with Rhino.AddBlock. Creating nested blocks take a bit more work than this simple function can handle.
Here is a sample of creating a nested block in C#. You can adapt this to Python if you want.
https://github.com/mcneel/rhino-developer-samples/blob/6/rhinocommon/cs/SampleCsCommands/SampleCsCreateNestedBlock.cs
– Dale