<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Smart face zoom (LookAt &amp;amp; ZoomToSelected) in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9279588#M105083</link>
    <description>&lt;P&gt;I wish somebody explain me what is Evaluator.ParamRangeRect for the Face...&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jan 2020 13:57:32 GMT</pubDate>
    <dc:creator>Maxim-CADman77</dc:creator>
    <dc:date>2020-01-28T13:57:32Z</dc:date>
    <item>
      <title>Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9276816#M105034</link>
      <description>&lt;P&gt;I'm now working on app that is supposed to zoom some face-of-interest (mainly spheric) smartly (rotate and zoom part body so that the face was clearly distinguished).&lt;/P&gt;&lt;P&gt;Initially my intent was to calculate coordinates of two RangeBox Center-Points (Part's and Face Evaluator's) and&amp;nbsp; use them as Target and Eye for setting Camera also doing FindInWindow and ZoomTo commands.&lt;/P&gt;&lt;P&gt;I did this succsessfully just to find out that this behaviour is faulty for internal faces of shell-like parts - the Face is shown from the wrong (inner) side.&lt;/P&gt;&lt;P&gt;I now understand that what I need is closer to combination of LookAt &amp;amp; ZoomToSelected commands while the Perspective mode is on.&amp;nbsp;Yet, LookAt command can be applied to plain faces only.&lt;/P&gt;&lt;P&gt;I believe that to achieve my goal I need to get just one more stuff - positive direction of the Face at a given point (its Center). I then should somehow be able to transform that Vector to new Eye-Point.&lt;/P&gt;&lt;P&gt;I thought I need to use FaceProxy but I see this object relates to Assemblies.&lt;/P&gt;&lt;P&gt;So I don't know where to look at now.&lt;/P&gt;&lt;P&gt;Could, please somebody hint me a bit?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;PS: I've attached a sample IPT with the only spheric Face marked red&lt;/P&gt;&lt;P&gt;My current code (iLogic)&lt;/P&gt;&lt;PRE&gt;If ThisDoc.Document.DocumentType=DocumentTypeEnum.kPartDocumentObject then
	Dim oTG As TransientGeometry=ThisApplication.TransientGeometry
	Dim oCam As Camera=ThisApplication.ActiveView.Camera
	Dim oIPT As PartDocument=ThisDoc.Document
	Dim oCD As ComponentDefinition=oIPT.ComponentDefinition
	Dim oSB As SurfaceBody=oCD.SurfaceBodies(1) ' usage of a smarter way of choosing "Body-of-Interest" is supposed !!!
	Dim oBMP As Point= oTG.CreatePoint((oSB.RangeBox.MinPoint.X+(oSB.RangeBox.MaxPoint.X-oSB.RangeBox.MinPoint.X)/2),(oSB.RangeBox.MinPoint.Y+(oSB.RangeBox.MaxPoint.Y-oSB.RangeBox.MinPoint.Y)/2),(oSB.RangeBox.MinPoint.Z+(oSB.RangeBox.MaxPoint.Z-oSB.RangeBox.MinPoint.Z)/2)) ' Body Mid-Point
	Dim oFRB as Box ' Face-of-Interest RangeBox
	Dim oFMP As Point ' Face Mid-Point
	oCAM.Target=oBMP
	For Each oFace As Face in oSB.Faces
		If oFace.SurfaceType=SurfaceTypeEnum.kSphereSurface then
			oIPT.SelectSet.Select(oFace)
			oFRB=oFace.Evaluator.RangeBox
			oFMP=oTG.CreatePoint((oFRB.MinPoint.X+(oFRB.MaxPoint.X-oFRB.MinPoint.X)/2),(oFRB.MinPoint.Y+(oFRB.MaxPoint.Y-oFRB.MinPoint.Y)/2),(oFRB.MinPoint.Z+(oFRB.MaxPoint.Z-oFRB.MinPoint.Z)/2))
			oCam.Eye = oFMP
			oCam.Perspective=True
			oCam.ApplyWithoutTransition
			ThisApplication.CommandManager.ControlDefinitions("AppZoomSelectCmd").Execute
			' oIPT.SelectSet.Clear
	Exit For
		End if 
	Next
Else
	MsgBox ("IPT should be active")
End if&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jan 2020 14:15:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9276816#M105034</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-01-27T14:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9278022#M105073</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;&lt;PRE&gt;Dim doc As PartDocument = ThisDoc.Document
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

'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))

' next line is only for debug to show what the camera target is 
doc.ComponentDefinition.WorkPoints.AddFixed(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)
Dim normal As Vector = ThisApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
Dim eye As Point = target
eye.TranslateBy(normal)

' next line is only for debug to show what the camera eye is 
doc.ComponentDefinition.WorkPoints.AddFixed(eye)
camera.Eye = eye

'you might want to set also the upvector to rotate the view to something more sensible.
'but i dont know how....
'camera.UpVector = ???

camera.ApplyWithoutTransition()

' i tryed to soom 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()&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jan 2020 21:47:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9278022#M105073</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-01-27T21:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9279588#M105083</link>
      <description>&lt;P&gt;I wish somebody explain me what is Evaluator.ParamRangeRect for the Face...&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 13:57:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9279588#M105083</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-01-28T13:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9279992#M105088</link>
      <description>&lt;P&gt;have a look at this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://modthemachine.typepad.com/files/mathgeometry.pdf" target="_blank" rel="noopener"&gt;https://modthemachine.typepad.com/files/mathgeometry.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;at page 9 you will find more info. (but i needed to read page 1 to 8 to understand it.)&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2020 16:00:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9279992#M105088</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-01-28T16:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9294561#M105376</link>
      <description>&lt;P&gt;Oops!&lt;/P&gt;&lt;P&gt;The life occured to be a bit more complicated.&lt;/P&gt;&lt;P&gt;I've just found at least one IPT where the solution doesn't work (tries to show the face from the side of material).&lt;/P&gt;&lt;P&gt;It is one of ContentCenter Files.&lt;/P&gt;&lt;P&gt;It is even more interesting that the very close looking part from another CC family doesn't have this issue.&lt;/P&gt;&lt;P&gt;Please find the two samples attached&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 08:08:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9294561#M105376</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-02-04T08:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318262#M105806</link>
      <description>&lt;P&gt;After diging a bit I've found that there is some uncertanty in the part of code responsible for target point coordinates calculation.&lt;/P&gt;&lt;P&gt;It does not take into a count the real geometry of a (?spheric?) face and thus can give a point opposite* to the point-of-interest (not belonging to surface of the solid).&lt;/P&gt;&lt;P&gt;It is declared that "The SurfaceEvaluator object can be obtained either&amp;nbsp;from the Face object or from any of the surface geometry objects. It’s generally better to use the&amp;nbsp;evaluator on the Face object since it takes into account additional information provided by the solid."&lt;/P&gt;&lt;P&gt;The tiny-little-thing remained unclear - how the code should be modified in order&amp;nbsp;Face.Evaluator.GetPointAtParam return only Point belonging to the Face.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* transient geometry surfaces are boundless&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 11:13:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318262#M105806</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-02-14T11:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318375#M105810</link>
      <description>&lt;P&gt;After adding line&lt;/P&gt;&lt;PRE&gt;MsgBox ("Real solution found - " &amp;amp; face.Evaluator.IsParamOnFace(params))&lt;/PRE&gt;&lt;P&gt;before " 'get point on surface at param" I'm getting&amp;nbsp;&lt;/P&gt;&lt;P&gt;"True" - for "NORMAL" IPT-sample&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;"False" - for "FAULTY" IPT-sample&amp;nbsp;&lt;/P&gt;&lt;P&gt;...thus face.Evaluator.ParamRangeRect is for blame?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 12:09:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318375#M105810</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-02-14T12:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318681#M105824</link>
      <description>&lt;P&gt;After executing API Helps "3D Curve from Parametric Curve API Sample"&amp;nbsp;code on both IPT-samples I beging to doubt that&amp;nbsp;ParamRangeRect is worth to use for solving initial task. Problem It's not just opposit direction of point. In fact zero-parameter curve doesn't fit the edge of real face:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ParamRangeRect_OnSphericFace_Visualisation.png" style="width: 499px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/729815i28A3AD9A10FF0934/image-size/large?v=v2&amp;amp;px=999" role="button" title="ParamRangeRect_OnSphericFace_Visualisation.png" alt="ParamRangeRect_OnSphericFace_Visualisation.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 14:02:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9318681#M105824</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-02-14T14:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9320412#M105872</link>
      <description>&lt;P&gt;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:&lt;/P&gt;&lt;PRE&gt;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&lt;BR /&gt;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()&lt;/PRE&gt;&lt;P&gt;I believe it is far from ideal, yet, It does the trick for the partipular FAULTY sample I've uploaded earlier...&lt;/P&gt;</description>
      <pubDate>Sat, 15 Feb 2020 15:25:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/9320412#M105872</guid>
      <dc:creator>Maxim-CADman77</dc:creator>
      <dc:date>2020-02-15T15:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Smart face zoom (LookAt &amp; ZoomToSelected)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/13306103#M176404</link>
      <description>&lt;P&gt;I too had struggled with changing camera view to a face and searching the web hasn't been very fruitful short of this post.&amp;nbsp; For myself, I'm looking just to change a camera view while in the model.&amp;nbsp; Piecing together codes from a couple of posts and examples I've found, sharing below my particular blend of code to accomplish my goal and posting in the event someone else can find it useful.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'find focus face and UP direction
Dim params(1) As Double
Dim normals(2) As Double
Dim oCam As Camera = ThisApplication.ActiveView.Camera
Dim oBox As Box
Dim oNormal As Vector
Dim oUp As UnitVector
Dim Eye As Point
Dim Pnts(1) As Point
Dim oLine(1) As Line
oFace1 = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document).TryGetEntity("Flat " &amp;amp; CStr(fMin))			'find first flat
oFace2 = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document).TryGetEntity("Start Edge")					'find adjacent starting edge
For i = 1 To oFace1.Edges.Count
	For j = 1 To oFace2.Edges.Count
		If oFace1.Edges.Item(i).GeometryType = 5123 And oFace2.Edges.Item(j).GeometryType = 5123 Then		'Find only Line Segment types on outside faces
			Pnts(0) = oFace1.Edges.Item(i).StartVertex.Point
			oLine(0) = oTG.CreateLine(Pnts(0), oFace1.Edges.Item(i).StartVertex.Point.VectorTo(oFace1.Edges.Item(i).StopVertex.Point))
			Pnts(0) = oFace2.Edges.Item(j).StartVertex.Point
			oLine(1) = oTG.CreateLine(Pnts(0), oFace2.Edges.Item(j).StartVertex.Point.VectorTo(oFace2.Edges.Item(j).StopVertex.Point))
			If oLine(0).IsColinearTo(oLine(1)) Then
				If oFace1.Edges.Item(i).StartVertex.Point.Y &amp;lt; oFace1.Edges.Item(i).StopVertex.Point.Y Then
					oUp = oTG.CreateLineSegment(oFace1.Edges.Item(i).StartVertex.Point, oFace1.Edges.Item(i).StopVertex.Point).Direction
				Else
					oUp = oTG.CreateLineSegment(oFace1.Edges.Item(i).StopVertex.Point, oFace1.Edges.Item(i).StartVertex.Point).Direction
				End If
			End If
		End If
	Next
Next

oFace = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document).TryGetEntity("Flat " &amp;amp; CStr(fMin))
oBox = oFace.Evaluator.RangeBox
oCam.Target = oTG.CreateLineSegment(oBox.MinPoint, oBox.MaxPoint).MidPoint
oFace.Evaluator.GetNormal(params, normals)
oNormal = ThisApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
Eye = oCam.Target
Eye.TranslateBy(oNormal)
oCam.Eye = Eye
oCam.UpVector = oUp
oCam.Apply
ThisApplication.ActiveView.Fit
InventorVb.DocumentUpdate(True)
oUnFold = oCompDef.Features.UnfoldFeatures.Add(oFace)
oUnFold.Name = "CNC Flat Layout"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 14:55:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/smart-face-zoom-lookat-amp-zoomtoselected/m-p/13306103#M176404</guid>
      <dc:creator>llorden4</dc:creator>
      <dc:date>2025-02-10T14:55:50Z</dc:date>
    </item>
  </channel>
</rss>

