Base Point of a Block in c#

HI. I’m trying to get the base point of a block(instance definition) which exists in the active rhino file by c#. Any idea how can I get the base point of the block by its name??
Thanks

1 Like

Hi @Yasaman.ag,

I think this should be something like this:

Point3d point = Rhino.Geometry.Point3d.Origin;
point.Transform(block.InstanceXform);

T.

1 Like

thanks for your help!
I tried your solution but InstanceDefinition doesn’t contain ( .InstanceXform), but InstanceObject does. Is it possible to change the intstance definition to instance object?

Correct.

InstanceDefinition and InstanceObject are two completely different things.
You can have a InstanceDefinition withthout any InstanceObject in the document.
An InstanceObject is an instance of InstanceDefinition, thus, it have a location and orientation.
But InstanceDefinition do not need an orientation and position: any of its geometries are stored in absolute coordinates. Its origin? Simply the origin, 0,0,0.

2 Likes

Thanks a lot for your response! Now I understand.
I should have the instance object of my block not instance definition. For the last question, would you please help me how can I get the instance object of my block by its name?
This code gives me instance definition which is not helpful as you said.

InstanceDefinition block= doc.InstanceDefinitions.Find(blockName);

Any block definition can have many instances. Let’s find the first one.

    Rhino.DocObjects.InstanceDefinition block= RhinoDocument.InstanceDefinitions.Find(name);
    Rhino.DocObjects.InstanceObject obj = block.GetReferences(0)[0];

(0) is to specify only “top level” , (1) would find also nested blocks, (2) only nested (?)
[0] the first one

2 Likes

Thank you so much for your help @maje90 @tobias.stoltmann ! It works now.

1 Like