I have a property manager page that adjusts the position of a tool. The tool defines three points and therefore a plane. After adjusting the tool I would like the view to reorient so that I am looking normal to that plane and then zoom to fit around the three points. How can I do that with the API?
Hi Brad,
You have two options, easy or hard. If you create a plane through the three points in the first place, the following code will do the job. Easy! Change your plane name in the SelectByID2 line if it isn't named "Plane1".
'----------------------------------------
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Plane1", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ShowNamedView2 "*Normal To", -1
Part.ViewZoomToSelection
'------------------------------------------
If you don't create the plane, and you're comfortable with direction vectors and math transforms, you could use the Orientation3 method of the ModelView interface. You can find some good starter code in the API help here.
2016 SOLIDWORKS API Help - Orientation3 Property (IModelView)