
Not applicable
08-26-2021
12:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am very new to scripting and took a while to make a basic perspective changing api for modeling space. I want to speed up the workflow by adding an input slider to adjust the number after
camera.perspectiveAngle = 3.14/180 *
which is the number that changes the perspective angle (with an upper limit of 149). I also want to add a button on the tool bar to quickly launch the script. I have checked the documentation but failed due to my inexperience.
Thank you very much!
- Fei
Here's the full script:
import adsk.core, adsk.fusion, traceback, math
def move_camera(app, view):
try:
camera = view.camera
steps = 1
camera.perspectiveAngle = 3.14/180 * 50
ui = app.userInterface
for i in range(0, steps):
camera.isSmoothTransition = False
view.camera = camera
adsk.doEvents()
view.refresh()
except:
ui = app.userInterface
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def main():
ui = None
try:
print('hello, world')
app = adsk.core.Application.get()
move_camera(app, app.activeViewport)
except:
ui = app.userInterface
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
main()
Solved! Go to Solution.