Fusion crashes when using threading

Fusion crashes when using threading

a.wendler
Explorer Explorer
685 Views
1 Reply
Message 1 of 2

Fusion crashes when using threading

a.wendler
Explorer
Explorer

My add-in runs in the background and receives messages from an external second program. Therefore a thread is created which constantly listens and in the event of a new message runs Fusion360-commands.

Unfortunately Fusion crashes when it has to interact with the UI for example if it has to create a new document.

 

Here an example:

 

import adsk.coreadsk.fusionadsk.cammaththreading

def run(context😞
    thread = threading.Thread(target=CreateNewDocument)
    thread.start()

def CreateNewDocument():
    app = adsk.core.Application.get()
    doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
 
Is there a way to interact with the UI within the thread?
0 Likes
Accepted solutions (1)
686 Views
1 Reply
Reply (1)
Message 2 of 2

KrisKaplan
Autodesk
Autodesk
Accepted solution

You can use a CustomEvent to post a custom event from your background thread, to your main/UI thread custom event handler to perform actions that are limited to the UI thread.

 

Kris



Kris Kaplan