Driving Camera with API

Driving Camera with API

spencer
Advocate Advocate
1,076 Views
2 Replies
Message 1 of 3

Driving Camera with API

spencer
Advocate
Advocate

I'm trying to add camera controls through the Inventor API but am not having any luck getting the camera to move whatsoever. Everything I've tried results in nothing happening (Not even an error cropping up), and I'm wondering if the API controls are simply not working for some reason.

Ex.

inventorApplication.ActiveView.Camera.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
inventorApplication.ActiveView.Camera.Perspective = True
inventorApplication.ActiveView.Camera.Fit()
inventorApplication.ActiveView.Camera.Target = inventorApplication.TransientGeometry.CreatePoint(0, 0, 0)
inventorApplication.ActiveView.Camera.Eye.TranslateBy(inventorApplication.TransientGeometry.CreateVector(0, 0, -(inventorApplication.ActiveView.Camera.Eye.Z) + inch2database(72)))
inventorApplication.ActiveView.Camera.Apply()

The above will do absolutely nothing, nor will any combination of them do anything. The only things I've found so far that do work are:

inventorApplication.ActiveView.GoHome()
inventorApplication.UserInterfaceManager.ShowCleanScreen = True

Am I missing something here?

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

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@spencer,

 

Hoping that suggestions in below blog link may be helpful.

 

https://modthemachine.typepad.com/my_weblog/2013/09/working-with-cameras-part-1.html

 

https://modthemachine.typepad.com/my_weblog/2013/09/working-with-cameras-part-2.html

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 3

spencer
Advocate
Advocate

That second link told me exactly what I needed to know, 

"The behavior of the View.Camera property is that every time you call it, it returns a new camera. This behavior makes it easy to run into a very common problem when working with cameras."

 

That should probably be included in the API docs somewhere, regardless I've got it working now.

0 Likes