<?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: unable to determine why i cant get normalto to work without selecting a face, see code in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935551#M7931</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; Your 3 new code routines seem to be completely focused on the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ViewOrientationTypeEnum" target="_blank" rel="noopener"&gt;ViewOrientationTypeEnum&lt;/A&gt; and their hardcoded association to the origin axes, and not on any model faces.&amp;nbsp; Maybe I completely misunderstood your intentions (what you wanted to achieve) with this forum post.&amp;nbsp; Since you were using the term 'normal to', and were collecting model faces, and was checking their 'Normal' (direction), I assumed you wanted the code to find a model face where its 'Normal' was pointing as closely as possible back at the camera's eye, and aligned as closely as possible to the existing 'line of sight', then align the camera to that Face's 'Normal', so it is looking directly at that Face, and zoomed so that the whole model was in view.&amp;nbsp; Do you not care about any model faces, but only care about aligning the camera with the origin axes, in one of the ways 'named' by the&amp;nbsp;ViewOrientationTypeEnum?&amp;nbsp; If that was the case, then the codes could have been much simpler, as long as you do not mind having the origin axes to view cube orientation associations hardcoded into the code, similar to what you already have in those new routines.&amp;nbsp; Also, should this code only be making sure that the view/camera is aligned with one of the classic orientations, or should it also check if it is already aligned with one of them...and if it is already aligned, jump to one of the others, in a certain direction, such as rotating to one side, around the current up direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just trying to clarify all the details of the goal(s) here as much as possible, in as clear of language / wording as possible, to avoid more lost time and efforts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS:&amp;nbsp; It has been too many years since I worked with SolidWorks to remember how a specific command (that was not very memorable) did, or how it compared to an equivalent one in Inventor.&amp;nbsp; Also, in Message 7 above, when you say "without pressing a face", do you mean a model face, or the view cube face?&amp;nbsp; And when you say "guess&amp;nbsp;&lt;SPAN&gt;which plane is closest to the big planes and normal to it&lt;/SPAN&gt;", by 'big planes' do you mean the model's origin planes, or the largest flat faces of a model, or the view cube?&amp;nbsp; The view cube is only a visual aid, so it does not have any actual geometry or faces to compare with, which is why we would need to hardcode orientation associations.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2024 13:03:06 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-08-02T13:03:06Z</dc:date>
    <item>
      <title>unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12918093#M7918</link>
      <description>&lt;P&gt;please see code below, sometimes it works and most of the time it doesnt.&lt;BR /&gt;&lt;BR /&gt;what am i missing?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main()
    ' iLogic rule to set view orientation to the closest face normal in a part or assembly document

    Dim oDoc As Document = ThisDoc.Document
    Dim oCompDef As ComponentDefinition
    Dim oCamera As Camera = ThisApplication.ActiveView.Camera

    ' Determine the document type and get the ComponentDefinition
    If TypeOf oDoc Is PartDocument Then
        oCompDef = oDoc.ComponentDefinition
    ElseIf TypeOf oDoc Is AssemblyDocument Then
        oCompDef = oDoc.ComponentDefinition
    Else
        MsgBox("This script only works in Part or Assembly environment.")
        Exit Sub
    End If

    Dim maxDotProduct As Double = -1
    Dim closestFace As Face = Nothing

    ' Get the current view direction
    Dim currentViewVector As UnitVector = oCamera.Eye.VectorTo(oCamera.Target).AsUnitVector

    ' Collect faces
    Dim allFaces As New List(Of Face)()
    If TypeOf oCompDef Is PartComponentDefinition Then
        For Each oFace As Face In oCompDef.SurfaceBodies(1).Faces
            allFaces.Add(oFace)
        Next
    ElseIf TypeOf oCompDef Is AssemblyComponentDefinition Then
        allFaces.AddRange(GetAllFaces(oCompDef))
    Else
        MsgBox("Unsupported ComponentDefinition.")
        Exit Sub
    End If

    For Each oFace As Face In allFaces
        ' Get a point on the face
        Dim pointOnFace As Point = oFace.PointOnFace

        ' Get the normal vector of the face at the point
        Dim pointCoords(2) As Double
        pointCoords(0) = pointOnFace.X
        pointCoords(1) = pointOnFace.Y
        pointCoords(2) = pointOnFace.Z

        Dim normals(2) As Double
        Call oFace.Evaluator.GetNormalAtPoint(pointCoords, normals)

        ' Create a UnitVector from the normals array
        Dim faceNormal As UnitVector = ThisApplication.TransientGeometry.CreateUnitVector(normals(0), normals(1), normals(2))

        ' Calculate the dot product between the face normal and the current view direction
        Dim dotProduct As Double = Abs(currentViewVector.DotProduct(faceNormal))

        ' Find the face with the largest dot product (closest to being perpendicular to the view direction)
        If dotProduct &amp;gt; maxDotProduct Then
            maxDotProduct = dotProduct
            closestFace = oFace
        End If
    Next

    If Not closestFace Is Nothing Then
        ' Get a point on the closest face
        Dim closestPointOnFace As Point = closestFace.PointOnFace

        ' Get the normal vector of the closest face at the point
        Dim closestPointCoords(2) As Double
        closestPointCoords(0) = closestPointOnFace.X
        closestPointCoords(1) = closestPointOnFace.Y
        closestPointCoords(2) = closestPointOnFace.Z

        Dim closestNormals(2) As Double
        Call closestFace.Evaluator.GetNormalAtPoint(closestPointCoords, closestNormals)

        ' Create a UnitVector from the closestNormals array
        Dim closestFaceNormal As UnitVector = ThisApplication.TransientGeometry.CreateUnitVector(closestNormals(0), closestNormals(1), closestNormals(2))

        ' Set the camera to look along the closest face normal
        oCamera.Eye = ThisApplication.TransientGeometry.CreatePoint(closestPointOnFace.X - 100 * closestFaceNormal.X, closestPointOnFace.Y - 100 * closestFaceNormal.Y, closestPointOnFace.Z - 100 * closestFaceNormal.Z)
        
		oCamera.Target = closestPointOnFace
        oCamera.UpVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0) ' Y-axis as the up direction
        oCamera.Fit

        ' Refresh the view
        oCamera.Apply()
        ThisApplication.ActiveView.Update()
    Else
        MsgBox("No faces found.")
    End If
End Sub

' Function to get all faces in an assembly
Function GetAllFaces(oCompDef As AssemblyComponentDefinition) As List(Of Face)
    Dim allFaces As New List(Of Face)()

    ' Iterate through all occurrences in the assembly
    For Each oOccurrence As ComponentOccurrence In oCompDef.Occurrences
        Dim occurrenceCompDef As ComponentDefinition = oOccurrence.Definition
        For Each oSurfaceBody As SurfaceBody In occurrenceCompDef.SurfaceBodies
            For Each oFace As Face In oSurfaceBody.Faces
                allFaces.Add(oFace)
            Next
        Next
    Next

    Return allFaces
End Function&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Jul 2024 21:24:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12918093#M7918</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-07-24T21:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12919154#M7919</link>
      <description>&lt;P&gt;The issue is on line 83&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;oCamera.UpVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0) ' Y-axis as the up direction&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the vector from &lt;EM&gt;&lt;STRONG&gt;Eye&lt;/STRONG&gt;&lt;/EM&gt; to &lt;EM&gt;&lt;STRONG&gt;Target&lt;/STRONG&gt; &lt;/EM&gt;is parallel to&amp;nbsp; this vector the issue occurs. You need to comment out this line or choose different non-parallel vector for it.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 10:25:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12919154#M7919</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-07-25T10:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12919358#M7920</link>
      <description>&lt;P&gt;Also, have you reviewed the code examples on the following recent forum topic:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-programming-ilogic/kisotopleftvieworientation-but-from-the-back/m-p/12875780" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-programming-ilogic/kisotopleftvieworientation-but-from-the-back/m-p/12875780&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In our 'Logger' results, the 'Target to Eye' vector pretty much always seems to be perfectly perpendicular to the 'UpVector' direction.&amp;nbsp; And sometimes if you do not have a reference to another perpendicular Vector, you can create one using the CrossProduct method a couple times.&amp;nbsp; It requests two existing vectors as input, the outputs a new Vector that is perpendicular to both of those input vectors.&amp;nbsp; The second vector you use as 'input' does not need to be perpendicular to the first input one, but just in the correct direction (the two vectors are on the same plane as the vector you eventually want).&amp;nbsp; The first result will be 'pointing sideways' (perpendicular to that imaginary plane), but when you use that resulting Vector as input into another CrossProduct, the result will be perpendicular to your first Vector.&amp;nbsp; The order you put the Vectors into the CrossProduct method dictates the 'polarity' of the resulting Vector.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 12:31:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12919358#M7920</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-07-25T12:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12920210#M7921</link>
      <description>&lt;P&gt;Okay i think i might need to go this way instead:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if i am looking at top:

y axis points towards me
z axis points right, left, up, down
x axis points right, left, up, down

if i am looking at bottom:

y axis points away
z axis points right, left, up, down
x axis points right, left, up, down

If I am looking at front:

y axis points right, left, up, down
z axis points at me
x axis points right, left, up, down

If I am looking at back:

y axis points right, left, up, down
z axis points away
x axis points right, left, up, down

If I am looking at left:

y axis points right, left, up, down
z axis points right, left, up, down
x axis points away

If I am looking at right:

y axis points right, left, up, down
z axis points right, left, up, down
x axis points towards me&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 18:03:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12920210#M7921</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-07-25T18:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12929201#M7922</link>
      <description>&lt;P&gt;this might take me a while to return to making this code work. If anyone is interested in completing this i would be forever grateful.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 17:25:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12929201#M7922</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-07-30T17:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931109#M7923</link>
      <description>&lt;P&gt;To solve the issue &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt; reported, you need something like this:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'Check if closestFaceNormal is parallel to Y-axis
If closestFaceNormal.IsParallelTo(oCompDef.WorkAxes(2).Line.Direction.AsVector) = True Then
    'Do not pick Y-axis as upvector (pick X or Z, in this example X)
    oCamera.UpVector = ThisApplication.TransientGeometry.CreateUnitVector(1, 0, 0) 
Else
    'Pick Y-axis
    oCamera.UpVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
End If&lt;/LI-CODE&gt;&lt;P&gt;However, bear in mind that choosing an up-vector other than the Y-axis will rotate your view.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I ask about the practical purpose of this code? If I understand correctly, you're searching for the 'most perpendicular to the view'-face normal and then rotate the view so you can look along it. What do you use it for?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 14:02:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931109#M7923</guid>
      <dc:creator>_dscholtes_</dc:creator>
      <dc:date>2024-07-31T14:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931131#M7924</link>
      <description>&lt;P&gt;I want to be able to map normal to without pressing a face, i want the code to automatically guess which plane is closest to the big planes and normal to it. this way i can work efficiently just like in solidworks. I mapped the space bar to normal to in solidworks and am able to quickly switch views.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 14:10:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931131#M7924</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-07-31T14:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931192#M7925</link>
      <description>&lt;P&gt;Just another quick tip in passing...either when collecting the faces to work with, or when iterating through them later, you should probably check that:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Face_SurfaceType" target="_blank" rel="noopener"&gt;Face.SurfaceType&lt;/A&gt; =&amp;nbsp;SurfaceTypeEnum.kPlaneSurface&lt;/P&gt;
&lt;P&gt;, or&lt;/P&gt;
&lt;P&gt;If TypeOf &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Face_Geometry" target="_blank" rel="noopener"&gt;Face.Geometry&lt;/A&gt;&amp;nbsp;Is Plane&lt;/P&gt;
&lt;P&gt;...to avoid curved faces like round holes, fillets, and such.&amp;nbsp; Some faces may be internal ones too, such as the inside faces of rectangular/polygonal cutouts.&amp;nbsp; Those can be difficult to filter out.&amp;nbsp; Another somewhat simpler one to check for is the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=Face_IsParamReversed" target="_blank" rel="noopener"&gt;Face.IsParamReversed&lt;/A&gt;&amp;nbsp;property.&amp;nbsp; If that is True, it may mean that the 'Normal' of the Face is pointing 'inwards' instead of 'outwards'.&amp;nbsp; This is somewhat common with geometry that has been created due to mirror (and similar) features.&amp;nbsp; It could skip over those, as part of an overall filter system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; Another tip...&lt;/P&gt;
&lt;P&gt;In your GetAllFaces Function...you are getting the Face objects from within the 'definitions' of those components.&amp;nbsp; Those will be in different 'context' (3D coordinate system).&amp;nbsp; You would need to be working with their 'proxies' instead.&amp;nbsp; Try switching from getting them from ComponentOccurrence.Definition.SurfaceBodies.Item(1).Faces, to getting them from ComponentOccurrence.SurfaceBodies.Item(1).Faces.&amp;nbsp; I haven't tested with it yet, but I suspect that those should be the proxies that are in the context of the main assembly's definition.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 15:27:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931192#M7925</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-07-31T15:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931761#M7926</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; On my way out for the day, but I have something for you to check out.&amp;nbsp; Not sure if this is doing what you had in mind, but it does appear to work as 'I' had planned.&amp;nbsp; I planned for this to...if the 'Normal' of a flat face in my model is nearest to pointing right at me, then straighten the camera/view so that I am looking straight at it, while attempting to maintain the 'expected up' direction.&amp;nbsp; This does not go by any origin axes, but rather is based purely on whichever direction 'looked like up' when the rule starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 19:12:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12931761#M7926</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-07-31T19:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12932973#M7927</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I want to be able to map normal to without pressing a face, i want the code to automatically guess which plane is closest to the big planes and normal to it. this way i can work efficiently just like in solidworks. I mapped the space bar to normal to in solidworks and am able to quickly switch views.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm not sure what you mean by the 'big planes' but I think I get the idea. If you're looking after an automated version of the 'look at'-command (PageUp-button), shouldn't you be looking for the 'most parallel to camera view direction'-normal instead of the 'most perpendicular'?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imagine looking at a cube, straight to one of the faces. Then there are 4 faces with a normal perpendicular and 2 faces with a normal parallel to the viewing direction. And of the two faces, there's only one with a normal facing in your direction (direction opposite of the camera view direction)*.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;* When no normals are flipped, the cube is not hollow, all faces are flat, etc. etc.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 09:15:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12932973#M7927</guid>
      <dc:creator>_dscholtes_</dc:creator>
      <dc:date>2024-08-01T09:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12933918#M7928</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; I have a couple more updates for you.&amp;nbsp; One is just a slightly updated version of the code I posted earlier.&amp;nbsp; That one did not use model axis directions, just in case you have reset your ViewCube in a way that is not aligned with the origin axes, or something else odd like that.&amp;nbsp; The other one I will be attaching is still very similar to that one, but this one uses the model origin axis directions to 'help' with determining the new 'UpVector', based on which origin axis was aligned closest to the direction of the initial 'UpVector' from before the transition takes place, for alignment.&amp;nbsp; Then similar to before, it uses cross products to get the new real 'UpVector', that will be perpendicular to the 'target to eye' direction.&amp;nbsp; In this version, I included a whole new, separate Function just for finding a 'direction' that is aligned with the origin axes, and closest to the supplied direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I generally do not need to 'deep dive' into Vectors/UnitVectors and such.&amp;nbsp; I had used 'cross product' before on multiple occasions, so I was relatively familiar with how it works, but had not used 'dot product' that much before, so during this process I learned a couple things about its results that I did not have in my notes before.&amp;nbsp; Below are some of those notes.&amp;nbsp; I did have a ton of comments in my code about this sort of thing, but stripped it out, due to it being really long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Facts About 'dot product' (between two UnitVectors):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If angle between 2 vectors is zero (same direction), their 'dot product' will be (their lengths multiplied)(and always a positive value)&lt;/LI&gt;
&lt;LI&gt;If angle between 2 vectors is 180 degrees (opposite directions), 'dot product' will be (their lengths multiplied)(always a negative value)&lt;/LI&gt;
&lt;LI&gt;If 2 vectors are perpendicular (either 90 degrees or 270 degrees), their 'dot product' will be zero&lt;/LI&gt;
&lt;LI&gt;If angle between 2 vectors is (less than 90 degrees or more than 270 degrees), their 'dot product' will be greater than zero (positive)&lt;/LI&gt;
&lt;LI&gt;If angle between 2 vectors is (greater than 90 degrees but less than 270 degrees), their 'dot product' will be less than zero (negative)&lt;/LI&gt;
&lt;LI&gt;So, it essentially measures how far the two vectors are less than or greater than perpendicular to each other.&lt;/LI&gt;
&lt;LI&gt;The order you use the vectors when doing this calculation does not matter.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Edit:&amp;nbsp; One possible shortcut would be, once you have the Face object you want to look at, use the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=SelectSet_Select" target="_blank" rel="noopener"&gt;SelectSet.Select&lt;/A&gt; method, or the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_DoSelect" target="_blank" rel="noopener"&gt;CommandManager.DoSelect&lt;/A&gt; method to select it, then execute the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ControlDefinition" target="_blank" rel="noopener"&gt;ControlDefinition&lt;/A&gt; named "AppLookAtCmd".&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 17:58:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12933918#M7928</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-08-01T17:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12934330#M7929</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; I have a couple more updates for you.&amp;nbsp; One is just a slightly updated version of the code I posted earlier.&amp;nbsp; That one did not use model axis directions, just in case you have reset your ViewCube in a way that is not aligned with the origin axes, or something else odd like that.&amp;nbsp; The other one I will be attaching is still very similar to that one, but this one uses the model origin axis directions to 'help' with determining the new 'UpVector', based on which origin axis was aligned closest to the direction of the initial 'UpVector' from before the transition takes place, for alignment.&amp;nbsp; Then similar to before, it uses cross products to get the new real 'UpVector', that will be perpendicular to the 'target to eye' direction.&amp;nbsp; In this version, I included a whole new, separate Function just for finding a 'direction' that is aligned with the origin axes, and closest to the supplied direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I generally do not need to 'deep dive' into Vectors/UnitVectors and such.&amp;nbsp; I had used 'cross product' before on multiple occasions, so I was relatively familiar with how it works, but had not used 'dot product' that much before, so during this process I learned a couple things about its results that I did not have in my notes before.&amp;nbsp; Below are some of those notes.&amp;nbsp; I did have a ton of comments in my code about this sort of thing, but stripped it out, due to it being really long.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Facts About 'dot product' (between two UnitVectors):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If angle between 2 vectors is zero (same direction), their 'dot product' will be (their lengths multiplied)(and always a positive value)&lt;/LI&gt;&lt;LI&gt;If angle between 2 vectors is 180 degrees (opposite directions), 'dot product' will be (their lengths multiplied)(always a negative value)&lt;/LI&gt;&lt;LI&gt;If 2 vectors are perpendicular (either 90 degrees or 270 degrees), their 'dot product' will be zero&lt;/LI&gt;&lt;LI&gt;If angle between 2 vectors is (less than 90 degrees or more than 270 degrees), their 'dot product' will be greater than zero (positive)&lt;/LI&gt;&lt;LI&gt;If angle between 2 vectors is (greater than 90 degrees but less than 270 degrees), their 'dot product' will be less than zero (negative)&lt;/LI&gt;&lt;LI&gt;So, it essentially measures how far the two vectors are less than or greater than perpendicular to each other.&lt;/LI&gt;&lt;LI&gt;The order you use the vectors when doing this calculation does not matter.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Edit:&amp;nbsp; One possible shortcut would be, once you have the Face object you want to look at, use the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=SelectSet_Select" target="_blank" rel="noopener"&gt;SelectSet.Select&lt;/A&gt; method, or the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=CommandManager_DoSelect" target="_blank" rel="noopener"&gt;CommandManager.DoSelect&lt;/A&gt; method to select it, then execute the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-ControlDefinition" target="_blank" rel="noopener"&gt;ControlDefinition&lt;/A&gt; named "AppLookAtCmd".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;thank you, i will take a look. this seems promising.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 20:58:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12934330#M7929</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-08-01T20:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12934358#M7930</link>
      <description>&lt;P&gt;here is a clumsy solution. to get it really line up with the view. Now to make this work fluidly. and keep the view aligned correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 21:32:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12934358#M7930</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-08-01T21:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935551#M7931</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; Your 3 new code routines seem to be completely focused on the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ViewOrientationTypeEnum" target="_blank" rel="noopener"&gt;ViewOrientationTypeEnum&lt;/A&gt; and their hardcoded association to the origin axes, and not on any model faces.&amp;nbsp; Maybe I completely misunderstood your intentions (what you wanted to achieve) with this forum post.&amp;nbsp; Since you were using the term 'normal to', and were collecting model faces, and was checking their 'Normal' (direction), I assumed you wanted the code to find a model face where its 'Normal' was pointing as closely as possible back at the camera's eye, and aligned as closely as possible to the existing 'line of sight', then align the camera to that Face's 'Normal', so it is looking directly at that Face, and zoomed so that the whole model was in view.&amp;nbsp; Do you not care about any model faces, but only care about aligning the camera with the origin axes, in one of the ways 'named' by the&amp;nbsp;ViewOrientationTypeEnum?&amp;nbsp; If that was the case, then the codes could have been much simpler, as long as you do not mind having the origin axes to view cube orientation associations hardcoded into the code, similar to what you already have in those new routines.&amp;nbsp; Also, should this code only be making sure that the view/camera is aligned with one of the classic orientations, or should it also check if it is already aligned with one of them...and if it is already aligned, jump to one of the others, in a certain direction, such as rotating to one side, around the current up direction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just trying to clarify all the details of the goal(s) here as much as possible, in as clear of language / wording as possible, to avoid more lost time and efforts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS:&amp;nbsp; It has been too many years since I worked with SolidWorks to remember how a specific command (that was not very memorable) did, or how it compared to an equivalent one in Inventor.&amp;nbsp; Also, in Message 7 above, when you say "without pressing a face", do you mean a model face, or the view cube face?&amp;nbsp; And when you say "guess&amp;nbsp;&lt;SPAN&gt;which plane is closest to the big planes and normal to it&lt;/SPAN&gt;", by 'big planes' do you mean the model's origin planes, or the largest flat faces of a model, or the view cube?&amp;nbsp; The view cube is only a visual aid, so it does not have any actual geometry or faces to compare with, which is why we would need to hardcode orientation associations.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 13:03:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935551#M7931</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-08-02T13:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935662#M7932</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&amp;nbsp; Your 3 new code routines seem to be completely focused on the &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ViewOrientationTypeEnum" target="_blank" rel="noopener"&gt;ViewOrientationTypeEnum&lt;/A&gt; and their hardcoded association to the origin axes, and not on any model faces.&amp;nbsp; Maybe I completely misunderstood your intentions (what you wanted to achieve) with this forum post.&amp;nbsp; Since you were using the term 'normal to', and were collecting model faces, and was checking their 'Normal' (direction), I assumed you wanted the code to find a model face where its 'Normal' was pointing as closely as possible back at the camera's eye, and aligned as closely as possible to the existing 'line of sight', then align the camera to that Face's 'Normal', so it is looking directly at that Face, and zoomed so that the whole model was in view.&amp;nbsp; Do you not care about any model faces, but only care about aligning the camera with the origin axes, in one of the ways 'named' by the&amp;nbsp;ViewOrientationTypeEnum?&amp;nbsp; If that was the case, then the codes could have been much simpler, as long as you do not mind having the origin axes to view cube orientation associations hardcoded into the code, similar to what you already have in those new routines.&amp;nbsp; Also, should this code only be making sure that the view/camera is aligned with one of the classic orientations, or should it also check if it is already aligned with one of them...and if it is already aligned, jump to one of the others, in a certain direction, such as rotating to one side, around the current up direction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just trying to clarify all the details of the goal(s) here as much as possible, in as clear of language / wording as possible, to avoid more lost time and efforts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS:&amp;nbsp; It has been too many years since I worked with SolidWorks to remember how a specific command (that was not very memorable) did, or how it compared to an equivalent one in Inventor.&amp;nbsp; Also, in Message 7 above, when you say "without pressing a face", do you mean a model face, or the view cube face?&amp;nbsp; And when you say "guess&amp;nbsp;&lt;SPAN&gt;which plane is closest to the big planes and normal to it&lt;/SPAN&gt;", by 'big planes' do you mean the model's origin planes, or the largest flat faces of a model, or the view cube?&amp;nbsp; The view cube is only a visual aid, so it does not have any actual geometry or faces to compare with, which is why we would need to hardcode orientation associations.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;hello, yes, just the basic planes (view cube face), but on the sides I am actually looking at and keeping the same orientation of the model. the normalto command requires you to select a face to work, it was the closest command i could find that did what i wanted. but really at the end of the day all i want is the standard cube orientations without pressing the cube faces and none of the fancy angles. just the top, bottom, front, back, left, right. but also keeping the same orientation of the model.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I am driving myself mad with this, if there is an easier method, i would love to learn.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 13:34:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935662#M7932</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-08-02T13:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935676#M7933</link>
      <description>&lt;P&gt;OK.&amp;nbsp; That sounds much easier than what I have been attempting to do.&amp;nbsp; I'll see what I can come up with.&amp;nbsp; But today, I am busier than usual at work, with some stuff that needs to get done, so no guarantees that it will get done today.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 13:37:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935676#M7933</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-08-02T13:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935863#M7934</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11604891"&gt;@maxim.teleguz&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;The attached text file contains a simplified iLogic rule that will:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Make sure the active document is not a drawing, because that may have a bad result that may be difficult to undo.&lt;/LI&gt;
&lt;LI&gt;Gets the active view and its camera.&lt;/LI&gt;
&lt;LI&gt;Supplies that camera to a modified version of your custom Function which is supposed to determine which of the classic 6 main 'view orientation types' is the closest match to the camera's current 'line of sight', and return that 'view orientation type'.
&lt;UL&gt;
&lt;LI&gt;This routine does not take which direction is currently 'up' (up on the screen, not pointing at user) into consideration, only the current 'line of sight'.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Sets the current camera to that returned&amp;nbsp;'view orientation type'.&lt;/LI&gt;
&lt;LI&gt;Applies, updates,&amp;nbsp; &amp;amp; Fits the camera &amp;amp; view&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So, if&amp;nbsp;I am looking at the model, and the 'Top' face of the view cube is the 'nearest' one to being flat with the current view, but the word 'Top' on it is nearly upside down...then when I use the rule, the view/camera will be aligned/oriented so that the 'Top' face of the view cube is perfectly square with the view, and the word 'Top' us right-side up again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But due to the "&lt;SPAN&gt;but also keeping the same orientation of the model" phrase at the end of your last comment, I am not 100% sure if this is the way you wanted it to act or not.&amp;nbsp; Should the word 'Top' on the view cube have been perfectly upside down after the rule got ran?&amp;nbsp; If so, then there is no variation of the 'ViewOrientationTypeEnum' that would satisfy that condition.&amp;nbsp; And, in that case, my previous code may still be a better fit to your needs than this one...except that the 'model faces' portion of it should be replaced by something that only deals with the 'UpVector'.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 15:13:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12935863#M7934</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-08-02T15:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: unable to determine why i cant get normalto to work without selecting a face, see code</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12940787#M7935</link>
      <description>&lt;P&gt;that is much simplier, but for some reason top view still has trouble aligning. i will figure this out eventually. Thank you for moving the needle in this challenge.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2024 20:47:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/unable-to-determine-why-i-cant-get-normalto-to-work-without/m-p/12940787#M7935</guid>
      <dc:creator>maxim.teleguz</dc:creator>
      <dc:date>2024-08-05T20:47:35Z</dc:date>
    </item>
  </channel>
</rss>

