Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How to add an input slider to my new script and adding it to the toolbar?

Anonymous

How to add an input slider to my new script and adding it to the toolbar?

Anonymous
Not applicable

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()

 

0 Likes
Reply
Accepted solutions (1)
401 Views
2 Replies
Replies (2)

kandennti
Mentor
Mentor
Accepted solution

Hi @Anonymous .

 

In the Japanese forum, there were several people who wanted to adjust the perspectiveAngle for rendering.
One of them created a script and published it.

https://github.com/skuramochi/Fusion360_SetCameraAoV 

 

Unfortunately, the slider is not used, and because it is a script, it cannot be registered in the Tools panel.

 

Instead, I created an add-in that uses the slider.
It only does the bare minimum, so please try to add any missing features.

1 Like

Anonymous
Not applicable

Thank you so much! Works exactly as I imagined, couldn't be happier as I have thought about this since last year.

 

-Fei

0 Likes