Running Secondary Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Firstly, huge shoutout to @kandenntifor your enormous help and work into understand textCommands, you've helped me and my colleague Svitlana a LOT!
Is there a way to call another Fusion360 script from within a script? Or perhaps a way to alter my current workflow to prevent Fusion360 crashing?
I'm experiencing the following issue:
I'm trying to use app.executeTextCommand to do the following sequence of steps:
- create a thermal simulation and switch to simulation menu
- load up a thermal loads menu
For whatever reason, if I execute all of those commands separately within the TextCommand window in Fusion360, they work perfectly. However in script, Fusion360 immediately crashes if I try to open the thermal loads menu immediately after creating a thermal study. Here's the script that crashes:
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
app.executeTextCommand(u'Commands.Start CreateSimulationModelCommand')
app.executeTextCommand(u'Commands.Start FinishSimplifyCommand')
app.executeTextCommand(u'NuCommands.CommitCmd')
#crashes right here VV if you comment the next two lines it works until then
cmd = ui.commandDefinitions.itemById("SimThermalLoadConvectionCmd")
cmd.execute()
Here's the exact sequence I enter into the Txt environment within TextCommands that works perfectly:
Commands.Start CreateSimulationModelCommand
Ok
Commands.Start FinishSimplifyCommand
Ok
Commands.Start SimThermalLoadConvectionCmd
Ok
My solution at the moment is that I created two scripts. First script generates a thermal study and then prompts the user to manually run my second script. The second script switches into the simulation environment which has an active study and then pulls up the thermal loads menu. It achieves the goal but I really don't like the need for user interaction in such a small step.