Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

As far as I don't understand how to workaround smartly I've added the simple check with camera points inversion if necessary. The updated code is:

Dim doc As PartDocument = ThisDoc.Document
Dim oCD As ComponentDefinition=doc.ComponentDefinition
Dim face As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "")
Dim camera As Camera = ThisApplication.ActiveView.Camera

'get the midpoint param from selected surface
Dim paramRangeRect As Box2d = face.Evaluator.ParamRangeRect
Dim params(1) As Double
params(0) = (paramRangeRect.MaxPoint.X + paramRangeRect.MinPoint.X) / 2
params(1) = (paramRangeRect.MaxPoint.Y + paramRangeRect.MinPoint.Y) / 2

Dim IsSolved As Boolean = True
IsSolved = face.Evaluator.IsParamOnFace(params) 'get point on surface at param Dim points(2) As Double face.Evaluator.GetPointAtParam(params, points) Dim target As Point = ThisApplication.TransientGeometry.CreatePoint(points(0), points(1), points(2)) Dim NewPoints(2) As Double If Not IsSolved And face.SurfaceType=SurfaceTypeEnum.kSphereSurface Then NewPoints(0)=points(0)-2*(points(0)-face.Geometry.CenterPoint.X) NewPoints(1)=points(1)-2*(points(1)-face.Geometry.CenterPoint.Y) NewPoints(2)=points(2)-2*(points(2)-face.Geometry.CenterPoint.Z) target = ThisApplication.TransientGeometry.CreatePoint(NewPoints(0), NewPoints(1), NewPoints(2)) End If ' ' this section is only for debug to show what the camera target is ' Try ' oCD.WorkPoints("Target").Delete ' Catch ' End Try ' oWP=oCD.WorkPoints.AddFixed(target) ' oWP.Name="Target" camera.Target = target 'get the normal of the surface at target point 'translate target point with normal-vector to eye point Dim normals(2) As Double face.Evaluator.GetNormal(params, normals) If Not IsSolved then normals(0)=-normals(0) normals(1)=-normals(1) normals(2)=-normals(2) End If Dim normal As Vector = ThisApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2)) Dim eye As Point = target eye.TranslateBy(normal) ' ' this section is only for debug to show what the camera eye is ' Try ' oCD.WorkPoints("Eye").Delete ' Catch ' End Try ' oWP=oCD.WorkPoints.AddFixed(eye) ' oWP.Name="Eye" camera.Eye = eye 'you might want to set also the up-vector to rotate the view to something more sensible. 'but i don't know how.... 'camera.UpVector = ??? camera.ApplyWithoutTransition() ' i tried to zoom to selected surface with the camera but did not manage ' therefor this hack doc.SelectSet.Clear() doc.SelectSet.Select(face) ThisApplication.CommandManager.ControlDefinitions.Item("AppZoomSelectCmd").Execute()

I believe it is far from ideal, yet, It does the trick for the partipular FAULTY sample I've uploaded earlier...

Please vote for Inventor-Idea Text Search within Option Names