I was wondering if I could ask you regarding some sample code you posted back in 2018 that might be obsolete or changed.
Here you specify how to insert a block instance into the document.
I can’t find a method called
InsertBlock in the RhinoCommon API.
I basically have some blocks defined in the BlockManager and I want to place them around in my model with some transformations and attributes.
Do you have any information that can help?
RhinoScript in VB was ported to the rhinoscriptsyntax package in Python.
InsertBlock is available there:
If you have a look at its
source code, you can also see it uses the RhinoCommon method
I see that the source code uses RhinoCommon functions that I can use myself, without resorting to
InsertBlock (i.e. I can just use what ever is in that function).
What I am getting from
AddInstanceObject(Int32, Transform) is a
GUID, which means it was ‘successful’, but no actual Block Instance appeared in the document.
Do you know why this may be…?
You probably need to refresh the display (
rhinoscriptsyntax/block.py at c49bd0bf24c2513bdcb84d1bf307144489600fd9 · mcneel/rhinoscriptsyntax · GitHub
If you are using Python you can use rhinoscriptsyntax (instead of re-coding it from the RhinoCommon SDK), it will be very close to the RhinoScript VB examples.
Here is the Python example from
import rhinoscriptsyntax as rs
objs = rs.GetObjects("Select objects to define block")
point = rs.GetPoint("Block base point")
block = rs.AddBlock(objs, point, None, True)
I’m using Python but outside GH, using
I am executing the code inside of the
InsertBlock2 functions, which already includes:
(I am using here
file.Views.Redraw() to the same effect)
Shouldn’t this work as you suggest or am I missing something…?
We’ll probably need to see code and have instruction on how to repeat what you are (not) seeing.
What are you running Rhino in?
I am using Hops service, so after playing with it, I think the issue is solved using the .Save() on the RhinoDoc.
For those following this thread, here are Python versions of the RhinoScript samples that were linked above.
ReplacePointsWithBlocks.py (805 Bytes)
ReplaceBlocksWithPoints.py (533 Bytes)