I want to select a Revit element from a given IFC guid.
The following code is working as expected. But is there a more efficient way to find the Element Id?
Document doc = uiDoc.Document; FilteredElementCollector collector = new FilteredElementCollector(doc).WhereElementIsNotElementType(); foreach (Element ele in collector) { var ids = new List<ElementId>(); Guid elemGuid = ExportUtils.GetExportId(ele.Document, ele.Id); String exportGuid = IfcGuid.ToIfcGuid(elemGuid); if (ifcGuid.Equals(exportGuid)) { ids.Add(ele.Id); uiDoc.Selection.SetElementIds(ids); break; } }
Solved! Go to Solution.
I want to select a Revit element from a given IFC guid.
The following code is working as expected. But is there a more efficient way to find the Element Id?
Document doc = uiDoc.Document; FilteredElementCollector collector = new FilteredElementCollector(doc).WhereElementIsNotElementType(); foreach (Element ele in collector) { var ids = new List<ElementId>(); Guid elemGuid = ExportUtils.GetExportId(ele.Document, ele.Id); String exportGuid = IfcGuid.ToIfcGuid(elemGuid); if (ifcGuid.Equals(exportGuid)) { ids.Add(ele.Id); uiDoc.Selection.SetElementIds(ids); break; } }
Solved! Go to Solution.
Solved by peter.kolbe. Go to Solution.
Solved by jeremytammik. Go to Solution.
It depends on your situation.
If you know you will have this requirement ahead of time, for instance at the point of time when the IFC export takes place, you could create a dictionary mapping all export ids to the corresponding element ids and store that somewhere for future use. It could be inside the RVT model in extensible storage, or in a text file, database, or whatever.
The this operation would require one single super efficient dictionary lookup and nothing else.
I can imagine other approaches as well... depending on your situation and needs.
Cheers,
Jeremy
It depends on your situation.
If you know you will have this requirement ahead of time, for instance at the point of time when the IFC export takes place, you could create a dictionary mapping all export ids to the corresponding element ids and store that somewhere for future use. It could be inside the RVT model in extensible storage, or in a text file, database, or whatever.
The this operation would require one single super efficient dictionary lookup and nothing else.
I can imagine other approaches as well... depending on your situation and needs.
Cheers,
Jeremy
Thanks Jeremy,
I also think that a separate Dictionary<IFCguid, ElementId> is the solution.
I just wanted to make sure that there is no comparable API method for the same task.
Greetings Peter
Thanks Jeremy,
I also think that a separate Dictionary<IFCguid, ElementId> is the solution.
I just wanted to make sure that there is no comparable API method for the same task.
Greetings Peter
Can't find what you're looking for? Ask the community or share your knowledge.