Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey there everyone.
I am thinking of changing the Camera.cameraType Property in an add-in.
I have created the following script for my next test.
# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
_CAMERA_TYPES = [
'OrthographicCameraType',
'PerspectiveCameraType',
'PerspectiveWithOrthoFacesCameraType'
]
_CAMERA_TYPES_LIST = [
adsk.core.CameraTypes.OrthographicCameraType,
adsk.core.CameraTypes.PerspectiveCameraType,
adsk.core.CameraTypes.PerspectiveWithOrthoFacesCameraType,
]
def run(context):
ui: adsk.core.UserInterface = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
des: adsk.fusion.Design = app.activeProduct
root: adsk.fusion.Component = des.rootComponent
vp: adsk.core.Viewport = app.activeViewport
cam: adsk.core.Camera = vp.camera
backupCameraType = cam.cameraType
backupOriginFolderLight = root.isOriginFolderLightBulbOn
root.isOriginFolderLightBulbOn = True
for ct in _CAMERA_TYPES_LIST:
cam.cameraType = ct
cameraUpdate(vp, cam)
cam = vp.camera
ui.messageBox(_CAMERA_TYPES[cam.cameraType])
cam.cameraType = backupCameraType
cameraUpdate(vp, cam)
root.isOriginFolderLightBulbOn = backupOriginFolderLight
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def cameraUpdate(
vp: adsk.core.Viewport,
cam: adsk.core.Camera):
vp.camera = cam
vp.refresh()
vp.fit()
Here is the result.
"adsk.core.CameraTypes.PerspectiveWithOrthoFacesCameraType" is very different from the one I set in the GUI.
Is this the correct display?
I am using Fusion360 Ver2.0.10940.
Solved! Go to Solution.