Change view like command LookAt

Change view like command LookAt

Anonymous
Not applicable
689 Views
5 Replies
Message 1 of 6

Change view like command LookAt

Anonymous
Not applicable
Hello guys!...

I would like to know how i can make the view be at on the Sketch.
It should work like "LookAt" command.

Thanks for your attention.

Luizoo from Brazil
0 Likes
690 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Try the macro below that programmatically selects the object to be "viewed"
(in this case, the Y-Z workplane) and executes the 'Look At' command.

Sanjay-


Sub LookAt()

Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition

Dim oWorkplane As WorkPlane
Set oWorkplane = oDef.WorkPlanes.Item(1)

oDoc.SelectSet.Clear
oDoc.SelectSet.Select oWorkplane

Dim oCtrlDef As ControlDefinition
Set oCtrlDef =
ThisApplication.CommandManager.ControlDefinitions("AppLookAtCmd")

oCtrlDef.Execute
End Sub
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thank you Sanjay for your suggest.

In this way i know, but i would like to make that without use an inventor command.

Thank for your attention.
Luizoo from Brazil
0 Likes
Message 4 of 6

Anonymous
Not applicable
That is possible to do by manipulating the view's camera. You'll need to set
the appropriate eye, target and up vector.

Sanjay-


Dim oView As View
Set oView = ThisApplication.ActiveView
Dim oCamera As Camera
Set oCamera = oView.Camera
oCamera.Eye = ...
oCamera.Target = ...
oCamera.UpVector = ...
oCamera.Apply
0 Likes
Message 5 of 6

Anonymous
Not applicable
Ok, thanks a lot.

I understood that.

Thanks for your attention again.

Luizoo from Brazil
0 Likes
Message 6 of 6

FRFR1426
Collaborator
Collaborator

Here is the C# code to do that for a sketch based on a work plane:

 

  var workPlaneObject = (WorkPlane)sketch.PlanarEntity;
  Plane plane = workPlaneObject.Plane;
  camera.Target = plane.RootPoint;
  Point eye = plane.RootPoint.Copy();
  eye.TranslateBy(plane.Normal.AsVector());
  camera.Eye = eye;
  camera.UpVector = plane.Normal.CrossProduct(sketch.AxisEntityGeometry.Direction);
  camera.Apply();

  

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes