Bug. Impossible to save named view with perspective camera. Resulting camera has very different eye.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is the simplest code:
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
import math
from adsk.core import *
from adsk.fusion import *
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = Design.cast(app.activeProduct)
camera = app.activeViewport.camera
camera.perspectiveAngle = math.radians(35)
design.namedViews.add(camera)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
When I execute this, it creates named view for the current camera position and orientation. But when I click on that view it moves far away from where camera was/is.
So it that was the original position when script is ran:
then after clicking on saved named view it goes way back:
Did some debugging and logging.
# Example of current camera when saving as named view:
current camera details. eye: x: 209.2645 mm, y: -27.2470 mm, z: 97.5599 mm target: x: -8.3656 mm, y: -10.8403 mm, z: 15.7369 mm up_vector: x: -2.7197 mm, y: 4.9824 mm, z: 8.2328 mm
# CAmera that is attached to saved named view
saved view camera details. eye: x: 3442.8070 mm, y: -271.0171 mm, z: 1313.2829 mm target: x: -8.3656 mm, y: -10.8403 mm, z: 15.7369 mm up_vector: x: -2.7197 mm, y: 4.9824 mm, z: 8.2328 mm
Even if I construct camera myself from scratch:
camera = app.activeViewport.camera
new_camera = Camera.create()
new_camera.cameraType = CameraTypes.PerspectiveCameraType
new_camera.perspectiveAngle = math.radians(40)
new_camera.isFitView = False
new_camera.isSmoothTransition = True
new_camera.eye = camera.eye.copy()
new_camera.target = camera.target.copy()
new_camera.upVector = camera.upVector.copy()
app.activeViewport.camera = new_camera
design.namedViews.add(new_camera)
It would still stores much farther camera