Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAM.setupDestroying event broken

1 REPLY 1
Reply
Message 1 of 2
allan4EEKW
108 Views, 1 Reply

CAM.setupDestroying event broken

Title says it all. My CAM.setupDestroying handler (python) no longer triggers when a setup is deleted. I think it broke in the March 2024 release.

 

setupCreated, setupChanged and setupActivated all seem to work fine.
 
Also, loving the new CAM functionality. Would love to see some operation events (operationCreated, operationDestroying, etc.)
Labels (3)
1 REPLY 1
Message 2 of 2
kandennti
in reply to: allan4EEKW

Hi @allan4EEKW -San.

 

I created a simple add-in.

It seems that not only the setupDestroying event, but also the setupChanged event is not firing.

# Fusion360API Python Addins

import traceback
import adsk
import adsk.core as core
import adsk.cam as cam

_app: core.Application = None
_ui: core.UserInterface = None
_handlers = []


def run(context):
    try:
        global _app, _ui
        _app = core.Application.get()
        _ui = _app.userInterface

        camObj: cam.CAM = cam.CAM.cast(_app.activeProduct)
        if not camObj:
            _ui.messageBox("Change to Manufacture work space.")
            return

        global _handlers
        onSetupEvent = MySetupEventHandler()
        _handlers.append(onSetupEvent)
        camObj.setupActivated.add(onSetupEvent)
        camObj.setupActivating.add(onSetupEvent)
        camObj.setupCreated.add(onSetupEvent)
        camObj.setupDeactivated.add(onSetupEvent)
        camObj.setupDeactivating.add(onSetupEvent)
        camObj.setupDestroying.add(onSetupEvent)

        onSetupChanged = MySetupChangedHandler()
        _handlers.append(onSetupEvent)
        camObj.setupChanged.add(onSetupChanged)
        
        adsk.autoTerminate(False)

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


class MySetupEventHandler(cam.SetupEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args: cam.SetupEventArgs):
        dump_event(args.firingEvent.name)


class MySetupChangedHandler(cam.SetupChangeEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args: cam.SetupChangeEventArgs):
        dump_event(args.firingEvent.name)


def dump_event(msg: str) -> None:
    _app.log(msg)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums