Duplicate block from Worksession in RhinoCommon

Hi,

I just face a problem when trying to copy a block from a worksession.

What I did is the following:
I read the block from the InstanceDefinitionTable and got it’s objects.
Those objects’ Geometry and ObjectAttributes I tried to use as a content for a new block.

Result is, that I receive a new block in my document, but without content.
What am I missing here?

Thanks,
T.

I have an update here.

I just appended a Rhino.Geometry.LineCurve(Rhino.Geometry.Point3d(0,0,0), Rhino.Geometry.Point3d(10,10, 0)) to the list of geometries I retrieved from the worksession.
It adds this one particular geometry to the block and this is working fine.

So is the problem that I need to transfer the list of GeometryBases to the current document?
This would be the only idea I could think of.

Any input is highly appreciated!

Yes.

– Dale

My gosh.
I simply did not think of the layer I put the new geometry.
It was (of course) the layer from the worksession.

It works, I am embarrassed.

Thanks @dale for the help and the patience. :slight_smile:

1 Like

How do you Transfer the Geometry Bases?

Does it work with blocked Hatches as well?

hi @Sam_Vel_Kapp,

if you already have a RhinoDoc (let’s say document) you can do this:

for obj in document.Objects:
    geo = obj.Geometry
    dup = geo.Duplicate()

    scriptcontext.doc.Objects.Add(geo)

@Sam_Vel_Kapp
You mean blocks containing hatches?