59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
# Author-
|
|
# Description-
|
|
|
|
import math
|
|
import adsk.core
|
|
import adsk.fusion
|
|
import adsk.cam
|
|
import traceback
|
|
|
|
|
|
def run(context):
|
|
ui = None
|
|
try:
|
|
print('hello, world')
|
|
app = adsk.core.Application.get()
|
|
|
|
move_camera(app, app.activeViewport)
|
|
|
|
ui = app.userInterface
|
|
# ui.messageBox('Hello script')
|
|
|
|
except:
|
|
if ui:
|
|
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
|
|
|
|
|
|
def move_camera(app, view):
|
|
try:
|
|
camera = view.camera
|
|
|
|
# target = adsk.core.Point3D.create(0, 0, 0)
|
|
up = adsk.core.Vector3D.create(0, 0, 1)
|
|
steps = 1000
|
|
|
|
eye = camera.eye
|
|
dist = camera.target.distanceTo(eye)
|
|
x_eye = eye.x
|
|
y_eye = eye.y
|
|
|
|
for i in range(0, steps):
|
|
x = dist * math.cos((math.pi*2) * (i/steps)) + x_eye
|
|
y = dist * math.sin((math.pi*2) * (i/steps)) + y_eye
|
|
z = eye.z
|
|
|
|
eye = adsk.core.Point3D.create(x, y, z)
|
|
|
|
camera.eye = eye
|
|
# camera.target = target
|
|
# camera.upVector = up
|
|
|
|
# camera.isSmoothTransition = False
|
|
view.camera = camera
|
|
adsk.doEvents()
|
|
view.refresh()
|
|
except:
|
|
ui = app.userInterface
|
|
if ui:
|
|
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
|