Closed ShehabFekry closed 11 months ago
To get the element by GlobalId you want something like :
// yourGlobalId is defined
var element = modelTwo.Instances.OfType<IIfcElement>().FirstOrDefault(e => e.GlobalId == yourGlobalId)
To highlight entities, just add / remove the entities to the Selection
collection on the DrawingControl3D instance
e.g.
drawingControl.Selection.Add(element);
Thank You, I really appreciate your concern, this answers half of my question, the other have is how to open that IFC viewer application from a desktop application by clicking a button and give it a specific file path to load it? It would be very helpful if you could help me with that concern
I have managed to use the DrawingControl3D and view my model in my WPF application and it works very well. now I'm trying to select a list of IIfcElements but it's not selecting anything I have tried
IfcStore ifcModel = IfcStore.Open(@"FilePath");
var context = new Xbim3DModelContext(ifcModel);
context.CreateContext();
var instances = ifcModel.Instances.OfType<IIfcElement>().Take(5).ToList();
DrawingControl.Model = ifcModel;
DrawingControl.LoadGeometry(ifcModel);
DrawingControl.SelectionBehaviour = DrawingControl3D.SelectionBehaviours.MultipleSelection;
DrawingControl.AddRange(instances);
I have also tried
DrawingControl.Add(instances[0]);
the only thing that is working and selecting is
DrawingControl.SelectedEntity = instances[0];
but I need to select multiple elements not only one;
Check that instances
contains some entities. (if not make sure you're importing the Ifc4 namespace for IIfcElement type)
Add the instances to the
DrawingControl.Selection.Add(instances[0]);
or
DrawingControl.Selection.AddRange(instances);
That solves the problem I was using Xbim.Ifc2x3.Interfaces;
when I used ifc4 it worked very well .. thank Andy I appreciate it.
Short summary describing the issue. (3-5 sentences) I have created a desktop application that compares the changes between two IFC files now I want to open the IFC windows viewer from that desktop application and press a button to highlight some global Ids that I already have.
Assemblies and versions affected:
Xbim.Essentials 4.0.29__*
Steps (or code) to reproduce the issue:
A simple set of steps to reproduce the issue. Provide a small sample file is required and/or a small sample of the failing code (or reference a commit / gist)