Get object with the GloabId

239 Views Asked by At

Is it possible to find an object in an IFC file using Xbim.Essentials with the GlobalId value? I saw this kind of code supposing I know the type...But I'd like to first find the object without knowing the type.

var id = "2AswZfru1AdAiKfEdrNPnu";
var theDoor = model.Instances.FirstOrDefault<IIfcDoor>(d => d.GlobalId == id);
Console.WriteLine($"Door ID: {theDoor.GlobalId}, Name: {theDoor.Name}");
1

There are 1 best solutions below

1
On

I think you can use IIfcProduct interface from

Xbim.Ifc4.Interfaces

like:

var ifcProduct = model.Instances.FirstOrDefault<IIfcProduct>(d => d.GlobalId == id);

should work on walls, slabs, columns etc...