Event handler for all commands

Event handler for all commands

weissgeorg33
Observer Observer
128 Views
1 Reply
Message 1 of 2

Event handler for all commands

weissgeorg33
Observer
Observer

I am trying to use Python script and attach an event handler to all Fusion commands, which would count invoked commands in my Fusion session. Is it possible to use this event? What will be the "command_var"?

onActivate = MyActivateHandler()
command_var.activate.add(onActivate)
handlers.append(onActivate)

 

0 Likes
129 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor

Hi @weissgeorg33 -san.

I understand that you want to count all commands invoked.

 

In Fusion360, the command is called for almost every operation.
Therefore, the “UserInterface.commandStarting” event is fired.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-EBB6C82A-A256-4AB7-9A86-0F7A9653A7E9 

The event handler receives “ApplicationCommandEventArgs” as an argument.

 

The ApplicationCommandEventArgs object has a commandId property.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-9BC745EE-4EAC-417F-97D5-68830BCC0EF9 
In other words, it can tell what command was invoked.

 


By creating a dictionary with CommandID as a key and counting it, you can keep track of what commands the user has used and how many times.