- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to zoom via the API while the camera type is orthographic type.
According to this blog post and some trial and error the only way to accomplish this is using the camera.viewExtents property. The documentation on the viewExtents property states: "Defines the area that's visible by the camera. This value is the radius of a sphere centered at the target point. The camera will display everything within that sphere and everything in front of and behind the sphere. [...]"
This is a script creating a unit sphere at the origin, setting camera.target to the origin and using 1 as viewExtents.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = adsk.fusion.Design.cast(
adsk.core.Application.get().activeProduct)
des.designType = adsk.fusion.DesignTypes.DirectDesignType
root = des.rootComponent
root.bRepBodies.add(
adsk.fusion.TemporaryBRepManager.get().createSphere(
adsk.core.Point3D.create(0, 0, 0), 1))
cam = app.activeViewport.camera
cam.cameraType = adsk.core.CameraTypes.OrthographicCameraType
cam.target = adsk.core.Point3D.create(0, 0, 0)
cam.eye = adsk.core.Point3D.create(0, -1, 0)
cam.upVector = adsk.core.Vector3D.create(0, 0, 1)
cam.viewExtents = 1
app.activeViewport.camera = cam
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I exspected that the sphere is displayed in a way so that it just fits into the viewport. That is defintivly not the case. (Using perspective camera type wont make a difference regarding viewport scale.)
Setting viewExtents to 3.25 will fit the sphere into the viewport at the vertical scale. However, when using a vertical algined screen the sphere wont fit into the viewport in the horizontal scale.
So what does the viewExtents property realy mean? Is it the vertical dimension of the viewport in cm mulitplied by 3.25??? This seems rather unlikely to me.
I would be very thankful if someone could point me in the right direction.
Solved! Go to Solution.