CAM.setupDestroying event broken

CAM.setupDestroying event broken

27Fusion2
Contributor Contributor
364 Views
1 Reply
Message 1 of 2

CAM.setupDestroying event broken

27Fusion2
Contributor
Contributor

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.)
0 Likes
365 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi @27Fusion2 -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)
0 Likes