Reply
Highlighted
Observer
3 Posts
Accepted Solution

Keeping a script active

69 Views, 5 Replies
4 weeks ago

Hello everyone,

 

I have a question about what adsk.autoTerminate() capabilities are in a script.

I am working on running a script through an add-in. The script creates a new occurrence with a simple cube. However, right after running the script, the design disappears. I was thinking perhaps this command may help my design stay active for further integrations. 

What you're seeing is a result of how commands work. Whatever you do in events besides the execute event will be aborted.  The command framework is designed to collect a set of input and then create the single final result at execution.  However, we are enhancing the command functionality in the future in a way that I think you might be able to accomplish your desired affect, but not exactly in the same way as you're currently trying to do it.  These new enhancements should be out in the update at the end of May.

Autodesk Support
1262 Posts
353 Kudos
369 Solutions

Re: Keeping a script active

4 weeks ago in reply to: jgmunoz2

I'm curious how you're executing a script from an add-in. My only guess is that your somehow starting a script from the execute event of a command and that's terminating your command, which aborts anything that it's done so far.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Observer
3 Posts

Re: Keeping a script active

3 weeks ago in reply to: ekinsb

Is there ways to stop the termination process for these side scripts, without disconnecting them from the execution event. The execution event is needed to run the code with it's sub-processes. 

Autodesk Support
1262 Posts
353 Kudos
369 Solutions

Re: Keeping a script active

3 weeks ago in reply to: jgmunoz2

I don't understand what your trying to do.  What do you mean by a "side script" and "disconnecting"?  How are you executing the scripts?


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Observer
3 Posts

Re: Keeping a script active

3 weeks ago in reply to: ekinsb

I am working with a friend. And we are importing the script into the add-in with the simple 'import script' line. In our add-in we have CommandCreatedEvent, ExecuteCommandEvent, and InputChangedEvent. We connected the CommandCreatedEvent to the other two events, and added some addBoolValueInput commands to create a GUI with buttons. In the InputChangedEvent we have :

 Capture.PNG

Then outside the InputChangedEvent we have :

def place1():

      try:

           script.run(context)

 

Our script just creates a rectangular sketch. As soon as we run the add-in it does run the script and creates the sketch. However right after it creates it,it disappears but we want it to stay in the design. 

Autodesk Support
1262 Posts
353 Kudos
369 Solutions

Re: Keeping a script active

3 weeks ago in reply to: jgmunoz2

What you're seeing is a result of how commands work. Whatever you do in events besides the execute event will be aborted.  The command framework is designed to collect a set of input and then create the single final result at execution.  However, we are enhancing the command functionality in the future in a way that I think you might be able to accomplish your desired affect, but not exactly in the same way as you're currently trying to do it.  These new enhancements should be out in the update at the end of May.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog