Adjusting Camera View to Workplane

Adjusting Camera View to Workplane

Martin-Winkler-Consulting
Advisor Advisor
658 Views
2 Replies
Message 1 of 3

Adjusting Camera View to Workplane

Martin-Winkler-Consulting
Advisor
Advisor

Hi,

i read a lot of stuff concerning Views, Camera and so on and tried much more.....

I want to use or rebuild the implemented feature in Inventor "Adjusting View to a Workplane" with vb.net. It's enclosed in the ViewCube

 

3DCS_2017.09.04_09h57m29s_001_.jpg

 

One part works in my code: Setting the Camera Eye in the right Position to the normal auf the workplane.

The second part, rotating like the inventor feature does, don't works. I have no idea how to create the right UpVector concerning to the workplane.

I recognized also that the original feature as different behavior dependent on how the actual camera view is positioned to the screen.

 

Here is my code:

The Workplane comes from the selected Plane

 

 Sub Adjust_Camera(oWorkPlane As WorkPlane)
            Dim oTG As TransientGeometry = InventorApp.TransientGeometry
            Dim oView As View = InventorApp.ActiveView
            Dim oCamera As Camera = oView.Camera
            'Vektor der Normalen
            Dim oNormalEye As Inventor.Vector = oWorkPlane.Plane.Normal.AsVector
            'set camera Target to Root Point
            oCamera.Target = oWorkPlane.Plane.RootPoint
            'set camera Eye
            Dim pEye As Point = oCamera.Target
            pEye.TranslateBy(oNormalEye)
            oCamera.Eye = pEye
            'until here it works fine

            'How can i get the right upVector for adjusting the camera like Inventor does it?
            Dim oUpvector As UnitVector = InventorApp.TransientGeometry.CreateUnitVector(0, 0, 1) 'example
            oCamera.UpVector = oUpvector
            'apply camera settings
            oCamera.Apply()
        End Sub
    End Class

In Sample eye.ipt (Inventor2017) for example i want to adjust "Arbeitsebene3"

 

Hoping for your help.

 

Best Regards Martin

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes
Accepted solutions (1)
659 Views
2 Replies
Replies (2)
Message 2 of 3

HermJan.Otterman
Advisor
Advisor

Hello Martin,

 

Look at how the workplane is created,

You used  two Ases, The S.Axis and the Work.Axis1.

If you look at the square that represents the workplane it is aligned with the Work.Axis1.

you Up vector is the direction of that Work.Axis1...

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 3

Accepted solution

Hello Herm Jan,

thanks for your Tip.

Now i figured out this solution and it works fine:

 

Sub Adjust_Camera(oWorkPlane As WorkPlane)
            Dim oView As View = InventorApp.ActiveView
            Dim oCamera As Camera = oView.Camera
            'Vector from Normal
            Dim oNormalEye As Inventor.Vector = oWorkPlane.Plane.Normal.AsVector
            Dim oPosPoint As Point = Nothing
            Dim oPosVectorX As UnitVector = Nothing
            Dim oPosVectorY As UnitVector = Nothing
            Try
                oWorkPlane.GetPosition(oPosPoint, oPosVectorX, oPosVectorY)
                'set camera Target to Root Point
                oCamera.Target = oPosPoint
                'set camera Eye by changing oPosPoint
                oPosPoint.TranslateBy(oNormalEye)
                oCamera.Eye = oPosPoint
                oCamera.UpVector = oPosVectorY
                'apply camera settings
                oCamera.ApplyWithoutTransition()
            Catch ex As Exception
                MsgBox("Kamera Einstellung nicht erfolgreich", vbCritical, "Ausrichten nach Arbeitsebene")
            End Try
        End Sub

Martin Winkler
CAD Developer
Did you find this post helpful? Feel free to like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature

0 Likes