2

I adding to my Viewport3d a model (STL file) using HelixToolKit's ModelImporter function, but first nothing show up. To see added 3DModel I have to do zoom out. My question is, are there any way to do dynamically/programmatically zoom out or rotate camera to the newly added model or anything needed to show it immediately.

I am using helix toolkit with C# WPF for the project.

Ardahan Kisbet
  • 641
  • 1
  • 13
  • 33

1 Answers1

5

Update: There is a method called ZoomExtents for this purpose. Problem is resolved. Update#2: Thanks for the warning @sideshowbarker;

//in this case currModel= Model3D and mainViewport=HelixViewport3D    
ModelVisual3D device3D = new ModelVisual3D();
device3D.Content = currModel;
mainViewport.Children.Add(device3D);
mainViewport.ZoomExtents();
//after loading 3D-Model into viewport you can just call the ZoomExtents() method in namespace of HelixToolkit.Wpf
//Then your 3D Models will automatically fits into viewport frame.
Ardahan Kisbet
  • 641
  • 1
  • 13
  • 33
  • It’s great that you found a solution but for the benefit of others here, you might consider expanding on this answer a bit—maybe adding a short code example. – sideshowbarker Dec 25 '15 at 23:29
  • In Viewport there is a ZoomExtentsWhenLoaded property which will cause the view to do this automatically on load. – henon Jul 03 '16 at 08:58