Longer Script List, or Script Panel with Buttons

info83PHN
Advocate

Longer Script List, or Script Panel with Buttons

info83PHN
Advocate
Advocate

As I am learning the API and how it can help many tasks that I do in Fusion, I am finding the list growing longer.

 

I now have to scroll to find the Script that I want to run. I understand that we can't assign keyboard shortcuts to Scripts.

 

Is there either : a way to increase the depth of the visible list, to reduce scrolling, or create a separate panel with button / shortcuts to regular used scripts ?

 

Would this be an add-in ?Can buttons on an addin be used to run a script ( different file to make code changes easier ? )

 

I am thinking of a panel that can stay down the right side of my screen, with 2 or 3 columns of square buttons - maybe a text code or icon on each button, to indicate which script would be run when pressed ?

 

Anything like this been done yet ?

0 Likes
Reply
1,311 Views
13 Replies
Replies (13)

BrianEkins
Mentor
Mentor

I know exactly what you're talking about because my list of scripts is _VERY_ long.  Unfortunately, there isn't anything currently exposed to make using them easier.  I know some things have been discussed but nothing has been done so far.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
1 Like

info83PHN
Advocate
Advocate

Couldn't an addin contain buttons, with the Click event starting an import or include of a script file, and execute the script ?

0 Likes

BrianEkins
Mentor
Mentor

An add-in can certainly create buttons but it's not currently possible to execute a script through the API.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
1 Like

info83PHN
Advocate
Advocate

so what's the purpose of an addin, if it can't execute a script ( or is that : can't execute a script from another file, but can execute script built in to the addin ) ?

0 Likes

JeromeBriot
Mentor
Mentor

@info83PHN  a écrit :

so what's the purpose of an addin


I think that you should read the documentation : Creating a Script or Add-In

1 Like

tykapl.breuil
Advocate
Advocate

You can import the run function of the script you want to run and then call script.run(context), that works really well !

1 Like

info83PHN
Advocate
Advocate

@tykapl.breuilwould that be importing the script to an addin, and calling the Run on a button Click event ?

0 Likes

tykapl.breuil
Advocate
Advocate

Yes, what I did for my use was create the scripts as scripts then put them in a sub folder of my addin to call them, (that means they weren't in my script list anymore). But you can certainly import the run function of the script while it is still in the right folder.

1 Like

info83PHN
Advocate
Advocate

@tykapl.breuil   that sounds like what I am looking for. Any possibility of you sharing the addin code so I have a starting point ?

If you want to keep if off forum, I'm on fb : david.obrien.338

0 Likes

tykapl.breuil
Advocate
Advocate

Here's an example with a quick sample I threw together where the main file, "CodeSample.py" runs the script "test.py" that is in the same folder.

The script could be in the fusion script folder if you change the import a bit.

https://drive.google.com/drive/folders/1vAVGA14dus75kooKcX8i3pukf0T63PA4?usp=sharing

 

2 Likes

info83PHN
Advocate
Advocate

@tykapl.breuil  Thank You. I will work thru that and see if I can understand it, and how to add additional items to the list.

Appreciate you sharing the code.

0 Likes

kandennti
Mentor
Mentor

I was curious about this problem and worked on it a bit.

 

My idea was to use the tree view and make it collapsible.

1.png

I actually worked on this as an add-in, but there were a few problems that stopped the development.
(If I'm honest, I've given up on it now.)
I've attached it if you're interested, but it's still under development and lacks a lot of stuff.

 

 

When you launch the add-in, "Script Launcher" will be added to "Tools" - "ADD-INS".

3.png

 

When you run it, the palette will be displayed.
Since it is currently under development, only the "Sample Scripts (Python)" included in the installation will be displayed in a tree, divided into several groups based on the alphabet.

2.png

By expanding the tree and double-clicking on each script name, you can execute the script.
However, only simple scripts can be executed.

 

For example, "Bottle" can be executed without any problem.

If it is "Bolt", an error occurs. I haven't checked the cause in detail, but I think it's because I'm using the resources folder.

The other problem is "ApplyAppearanceToSelection" which does not use the resources folder.

 

When I press "OK" or "Cancel" to finish running the script, the add-in palette disappears.
And not only the palette, but also the add-in itself will be terminated.
If the add-in is terminated, there will be no benefit at all, so we have stopped development.

I'm guessing it's because I'm importing the script as a module and running it.
I couldn't think of any other way to do it.

 

I hope the standard "Scripts and Add-ins" dialog will add the ability to display them in a compact format.

0 Likes

bryan_martin_morris
Contributor
Contributor

@kandennti 

I realize this is reviving an old thread, but just thought I should say that I tried your 'script manager' and it works pretty nicely, so thanks! I replaced the path to samples with the path to my script folder, and for the script I need to run, it works, the palette stays active, and I can re-run the script I want to use. 

It's actually super useful for me at the moment, as what I need to do is write all assembly occurrence transform2 matrices in a motion study to text, using the motion study>edit (as motion study is still not exposed to API...). 

 

As soon as you try run a script from the add-ins and script button, the Motion study palette disappears, but with your script manager it doesn't! 🙂

 

So now I have a way to at least write out occurrence transform matrices frame by frame or interpolated if I'm feeling lazy, which I can then use to animate in other software. Sure I could probably do the same with a rigged model in a different software, but I would need to learn that software, and probably buy it, so meh.

 

So cheers!

1 Like