- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
The code below controls the camera in Fusion 360. The code works properly but there are some additional assignments that I have to do which to my knowledge should not be necessary and should be possible to replace them by just one assignment.
In the code I have to assign (part of the code below):
cam.eye = adsk.core.Camera.eye cam.target = adsk.core.Camera.target cam.upVector = adsk.core.Camera.upVector cam.isSmoothTransition = adsk.core.Camera.isSmoothTransition
It seems to be necessary to make the assignment property by property in order to get the code working. It would be much easier if I could make the assignment for all properties att the same time by
cam = adsk.core.Camera
but if I try to execute the code with this assignment I get the error code: Is there anybody that can explain what I am doing wrong ?
Error Code
#Author- #Description- import adsk.core, adsk.fusion, traceback, math app = adsk.core.Application.get() def run(x): try: cam = app.activeViewport.camera target = adsk.core.Point3D.create(0,0,100) up = adsk.core.Vector3D.create(0,0,1) eye = adsk.core.Point3D.create(500,500,100) steps = 500 adsk.core.Camera.eye = eye adsk.core.Camera.target = target adsk.core.Camera.upVector = up adsk.core.Camera.isSmoothTransition = False cam.eye = adsk.core.Camera.eye cam.target = adsk.core.Camera.target cam.upVector = adsk.core.Camera.upVector cam.isSmoothTransition = adsk.core.Camera.isSmoothTransition app.activeViewport.camera = cam ViewDist = adsk.core.Camera.target.distanceTo(adsk.core.Camera.eye) for i in range(0, 2*steps): eye = adsk.core.Point3D.create(2*ViewDist * math.cos((math.pi*2) * (i/steps)),\ ViewDist * math.sin((math.pi*2) * (i/steps)), 100) cam.eye = eye app.activeViewport.camera = cam adsk.doEvents() app.activeViewport.refresh() except: ui = app.userInterface if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Best Regards
Peter
Solved! Go to Solution.