Read blockname of object from outside Rhino (file3dmio)

Hi there,

I want to access a 3dm-file (or multiple) form a WPF-app.
Therefore I read the file and try to go into the object table.

        var file_path = @"C:\Dataextraction.3dm";
        var file_data = Rhino.FileIO.File3dm.Read(file_path);

        var objs = file_data.Objects;

        foreach (var item in objs)
        {
            var item_type = item.Geometry.ObjectType;

            if (item_type == ObjectType.InstanceReference)
            {
                 ....
            }
        }

Here I want to read the blockname of the object, but I cannot find anything in the documentation.
I am kind of desperate, as I know how it works in RhinoCommon. Is it possible at all - I guess so, but I am lost.

Thanks in advance,
T.

Hi @tobias.stoltmann,
You could do it in the following way

foreach(var item in objs)
{
    if(item.Geometry is InstanceReferenceGeometry instanceReferenceGeometry)
    {
        Guid parentDefID = instanceReferenceGeometry.ParentIdefId;
        InstanceDefinitionGeometry instanceDefinitionGeometry= file_data.AllInstanceDefinitions.FindId(parentDefID);
        if(instanceDefinitionGeometry!=null)
            string instanceDefinitionName = instanceDefinitionGeometry.Name;
    }
}
2 Likes

Working perfectly fine!
@Darryl_Menezes, thanks a lot.