Open leuyvo opened 5 years ago
There's no particular sample docs for this apart from how Xbim Xplorer does it. Note that most of the implementation is in the re-usable Xbim.Presentation library (in DrawingControl.xaml)
I'd take a look at https://github.com/xBimTeam/XbimWindowsUI/blob/87e33a9f61469caa7a8a8af81a33eb7a97e8f943/Xbim.Presentation/DrawingControl3D.xaml.cs#L958
... and work your way up from there.
Note this also supports multiple selection.
Hello.
DrawingControl3D have protected method HighlighSelected. Create your own DrawingControl3D and new method with protected method HighlighSelected
public class MyDrawingControl3D : DrawingControl3D
{
public void HighlightS(IPersistEntity ent)
{
HighlighSelected(ent);
}
private XbimRect3D _viewBounds
{
get
{
return ModelPositions.ViewSpaceBounds;
}
}
public void Zoom()
{
if (SelectedEntity == null || Highlighted.Content == null || Highlighted.Content.Bounds.IsEmpty)
return;
var r3D = Highlighted.Content.Bounds;
MyZoomTo(r3D);
}
private void MyZoomTo(Rect3D r3D)
{
if (r3D.IsEmpty)
return;
var bounds = new Rect3D(
_viewBounds.X, _viewBounds.Y, _viewBounds.Z,
_viewBounds.SizeX, _viewBounds.SizeY, _viewBounds.SizeZ
);
if (r3D.IsEmpty)
return;
var actualZoomBounds = r3D.Contains(bounds) ? bounds : r3D;
Viewport.ZoomExtents(actualZoomBounds, 500);
}
}
Now, call this in your viewmodel
DrawingControl.Dispatcher.Invoke(() =>
{
DrawingControl.Selection = SelectedEntities;
DrawingControl.HighlightS(SelectedEntities.First());
DrawingControl.ModelOpacity = 0.1;
Thread.Sleep(100);
DrawingControl.Zoom();
});
where DrawingControl is your object of type MyDrawingControl3D, SelectedEntities is your EntityCollection.
I'm still new, but it works for me. GoodLuck :)
I have adopted the above code by SapcePurr and then manipulated it by introducing a DataGrid. Each row of the DataGrid has a bunch of objects (mixed properties) behind it. I can get the model to highlight multiple objects (selected from the DataGrid) but when it is more than a few dozen it becomes painfully slow and even throws up a memory problem.
Any ideas on how to speed it up or a different approach to 'grouping' the objects so they can be highlighted at once? Am willing to consider feeding the grouping components model from say MySql
Hello,
I'm using XbimWindowsUI to build Winform 3D View from ifc file. Now I want to highlight some elements, I wonder is it possible and how to do it?
(Similiar to this: http://docs.xbim.net/XbimWebUI/tutorial-5_Colourful_building.html)
Thank you.