Is there a coerceblock()? how to manipulate Blocks in GH Python

I am able to import some Block instances into gh python, set type hint to GUID.
and find block names with

    sc.doc = Rhino.RhinoDoc.ActiveDoc
    name = rs.BlockInstanceName(blockid)
    #print(name)
    sc.doc = ghdoc

Now I want to rs.CopyObject() on one block instance or “Rhino Insert” the block definition to copy to new location. (Type keep at GUID so I can still do the above)

I used coercecurve() when I was did the same thing with curve:
type hint GUID → get object name → crv = rs.coercecurve(id) → CopyObject(crv)

Can I get some guidance on how to do that with block?

Sorry, I was trying to help in my little. But my answer was flagged and hidden.

lol not sure what happened but sorry to hear

Figured out. Worked around GH pipeline and baking.
It’s really slow tho when inserting blocks of crv type.

The same geometry I used with rs.CopyObject() on (exploded crvs) finished instantly, but this InsertBlock2 took quite a few seconds to do the same amount of copy.

Is there anyway to make it much faster? Is it slow cuz of no gh part of the rendering pipeline optimization?

sc.doc = Rhino.RhinoDoc.ActiveDoc
blockName = "A1"
movMatrix = rg.Transform.Translation(1,1,1)
newBlock = rs.InsertBlock2(blockName , movMatrix)

also dont know if I need a Redraw() at the end, it works

1 Like

Fixed the slow viewport with controlled redraw()

sc.doc = Rhino.RhinoDoc.ActiveDoc
rs.EnableRedraw(False)
while (...) {
  blockName = "A1"
  movMatrix = rg.Transform.Translation(1,1,1)
  newBlock = rs.InsertBlock2(blockName , movMatrix)
}
rs.EnableRedraw(True)