0

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}");
SONA
  • 1
  • 2

1 Answers1

1

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...

  • Yes, this will definitely work and should be accepted as an answer. Just use the inheritance hierarchy of IFC entities in the query. – Martin Cerny Oct 13 '22 at 10:37