Reset frontview in 3D without rotating model

Reset frontview in 3D without rotating model

LarsBJepsen
Advocate Advocate
792 Views
3 Replies
Message 1 of 4

Reset frontview in 3D without rotating model

LarsBJepsen
Advocate
Advocate

Hi,

 

I'm looking for some code to reset the frontview in a 3d model without turning the current view. It's possible to do manual by changing the "front view plane" in the view cube options and then "reset front". All the code snipplets i have found rotates the model and then sets current view as front. Can anyobe help? 

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

dutt.thakar
Collaborator
Collaborator

@LarsBJepsen 

 

I think this is possible with control definitions. Try below line and see if it works. 

 

ThisApplication.CommandManager.ControlDefinitions("AppViewCubeViewFrontCmd").Execute

 

Hope it helps.

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 4

LarsBJepsen
Advocate
Advocate

Thanks. That resets the front view to the current view. What Im't trying to do, is to set the front view to the XZ (-Y) Plane without rotating the model from its current view.

0 Likes
Message 4 of 4

J-Camper
Advisor
Advisor
Accepted solution

Is this what you are looking for?

 

Dim CURRENTcam As Camera = ThisApplication.ActiveView.Camera
Dim cam As Camera = ThisApplication.ActiveView.Camera
Dim tg As TransientGeometry = ThisApplication.TransientGeometry

'Set the target
cam.Target = ThisApplication.ActiveDocument.ComponentDefinition.MassProperties.CenterOfMass

' Define the distance between the eye and target.
Dim eyeDistance As Double = 200

' Calculate the x and y coordinates of the eye.
Dim x As Double = cam.Target.X
Dim y As Double = cam.Target.Y-eyeDistance
Dim z As Double = cam.Target.Z

'Set the eye
cam.Eye = tg.CreatePoint(x, y, z)

'Define the up vector as positive z.
cam.UpVector = tg.CreateUnitVector(0, 0, 1)

'Make sure full model is visible
cam.Fit

'Apply new camera View
cam.Apply

'Set current camera view as Front
cam.Parent.SetCurrentAsFront

'Return to original view position
CURRENTcam.Apply

 

 

Let me know if you have any questions or if this is not working as intended.

0 Likes