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: 

Does Fusion plan on having Operation change events implemented like the Setup change event?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
alexeiE6G4T
413 Views, 7 Replies

Does Fusion plan on having Operation change events implemented like the Setup change event?

I did some digging around the api (python sdk) to see if there are any "change event" handler classes that could be used for logging changes to Operations and I didn't find any. I did find that you could listen for Setup changes (which is nice) but that's about it.

 

Perhaps it's ignorance and wishful thinking on my part but is it possible, in script, to be notified when an operation had changed? The only way I can think of, at this time, to do this is to check every interval but we can all agree that's just the worst way to do it. If push comes to shove, I'll might check the operation.operationState property before checking for changes so I'm not forced to check EVERY operation.

 

I had thought about tying into the adsk.core.DataEvent but this, while it does reduce the frequency of expensive operations, is too broad. That is, the script would have to traverse too many points where things didn't change. It would be SO much simpler to have the Operation base class implement a change event handler method so all the operations could be tracked as things change.

 

Let me know if I'm missing anything.

7 REPLIES 7
Message 2 of 8
kandennti
in reply to: alexeiE6G4T

Hi @alexeiE6G4T -San.

 

In Fusion360, most of the time when you perform an operation, a command is executed.

 

When a command starts executing, the UserInterface.commandStarting event is fired, and you will know what command was started by its ID.

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

 

After the command finishes, the UserInterface.commandTerminated event is generated.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-E381414E-1CFF-4007-B1DF-C413D7E6841A 

 

However, changes on the CAM dialog are not commands, so these events are not generated.

It may be possible to start monitoring only if the ID at the start of the commandStarting event is the command you need, and check the changes made in the commandTerminated event.


An add-in that uses the commandTerminated event and dumps the command ID is available here and may be of some help.

https://github.com/kantoku-code/Fusion360_Developers_Small_ToolKit 

Message 3 of 8
jeff.pek
in reply to: alexeiE6G4T

I do expect we will introduce events such as these in a future update. I can't give precise timing.

  Jeff

Message 4 of 8
alexeiE6G4T
in reply to: kandennti

@kandennti,

thank you for the tip! This is basically the closest thing to what I want. I just checked it out and it works great. All I have to do now is take a snapshot of all the parameters at "commandStarting" then compare the changes when the "commandTerminated" is fired. Easy peasy. The expense of checking all the parameters, to me, is a relatively small price to pay, all things considered. Also, thanks for sharing that toolkit, it will certainly be super helpful.

Message 5 of 8
alexeiE6G4T
in reply to: jeff.pek

That would be great! Thank-you! I will likely use what @kendennti had suggested as a starting point and later refactor it as needed when this becomes available.
Message 6 of 8
alexeiE6G4T
in reply to: alexeiE6G4T

After diving deeper, I may have spoke too soon. The handler does trigger but the cmdId seems to always be 'IronEditOperation' for some reason.

Message 7 of 8
kandennti
in reply to: alexeiE6G4T

@alexeiE6G4T -San.

 

In the case of the re-edit operation, it did indeed become 'IronEditOperation' and I could not tell the difference.

 

The following text command will give you information about the dialog you are running.

 

Toolkit.cmdDialog

 

If you run the following script while the dialog is displayed in the operations re-edit, you will get this result.

# Fusion360API Python script

import traceback
import adsk.core as core

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        res = app.executeTextCommand(u"Toolkit.cmdDialog")

        app.log(res)

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

1.png

The output also dumps the hidden information on the dialog. I think it is possible to determine the type of operation by checking the characteristics of the dialog in advance, because the information on the dialog probably differs depending on the type of operation.
It would be easiest if the title of the dialog is output as a text command, but it seems that the title is not output.

 

If you are using the add-in I have published, here is the button for this feature.

1.png

Message 8 of 8
alexeiE6G4T
in reply to: kandennti

This is wonderful, thank you again for the solid tip!

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report