My addin is causing Fusion to crash. Please advise

My addin is causing Fusion to crash. Please advise

tomas.bangoA2EPZ
Advocate Advocate
961 Views
6 Replies
Message 1 of 7

My addin is causing Fusion to crash. Please advise

tomas.bangoA2EPZ
Advocate
Advocate

Hello a couple of weeks ago I crossed a problem with importing files into Fusion. After the last update my addin started to cause a crash of Fusion. I tried to rewrite it to make it work, unfortunately I must have misunderstood how to do it.

 

Can someone please advise me how to rewrite/modify this addin so that the file import stops causing Fusion to crash? I'd be grateful for any help.

 

Addin attached. 

0 Likes
962 Views
6 Replies
Replies (6)
Message 2 of 7

kandennti
Mentor
Mentor
0 Likes
Message 3 of 7

tomas.bangoA2EPZ
Advocate
Advocate

Hello, thank you for your reply, unfortunately the sample addin you created for me is currently causing Fusion to crash.

 

I tried using CustomEvent the problem is that it throws me an error which I don't understand. (ADSC01)

 

But when i try it seperatly importToTarget is working.

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback
import os
handlers = []

class ImportS(adsk.core.CustomEvent):
    global ui
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        # f3d path
        filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Sroub2.f3d')

        # import f3d
        app: adsk.core.Application = adsk.core.Application.get()
        root: adsk.fusion.Component = app.activeProduct.rootComponent

        importManager: adsk.core.ImportManager = app.importManager
        importOptions: adsk.core.ImportOptions = importManager.createFusionArchiveImportOptions(filePath)
        importManager.importToTarget(importOptions, root)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def CustomE(context):
    global ui 
    try:
        mujCusE='MujCustomID'
        global customEvent
        app=adsk.core.Application.get()
        ui=app.userInterface
        customEdef=app.registerCustomEvent(mujCusE)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 Problem is i dont know how to connect CustomEvent so it fired by executing command

0 Likes
Message 4 of 7

KrisKaplan
Autodesk
Autodesk

Hi,

 

Please refer to the Custom Event Sample script in the documentation samples at https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-85edd118-c2a4-11e6-b401-3417ebc87622 for an example of how to use CustomEvents.

 

Kris



Kris Kaplan
0 Likes
Message 5 of 7

kandennti
Mentor
Mentor

Hi @KrisKaplan .

 

I tried a little, but due to my lack of knowledge about threading and Custom Event, I could not do what I wanted.

 

The sample is a custom event that will be fired repeatedly until the add-in is stopped.

What I am looking for is to call "importToTarget" only once in the custom event.

 

Can you please publish the test code that you say succeeds?

Message 6 of 7

tomas.bangoA2EPZ
Advocate
Advocate

So i end up with this. The problem is that firstly I don't know if my customEvent is correctly connected to CommandEvent. Secondly the customevent is called regardless of whether the commandEvent is triggered or not.

 

In sample code there is customevent firing an another event im trying to do oposit. Any advise please? I guess its same issue as @kandennti  mentioned

0 Likes