Keeping a script active

Keeping a script active

Anonymous
Not applicable
1,042 Views
5 Replies
Message 1 of 6

Keeping a script active

Anonymous
Not applicable

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. 

Accepted solutions (1)
1,043 Views
5 Replies
Replies (5)
Message 2 of 6

ekinsb
Alumni
Alumni

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
0 Likes
Message 3 of 6

Anonymous
Not applicable

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. 

0 Likes
Message 4 of 6

ekinsb
Alumni
Alumni

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
0 Likes
Message 5 of 6

Anonymous
Not applicable

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. 

0 Likes
Message 6 of 6

ekinsb
Alumni
Alumni
Accepted solution

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
0 Likes