How to use CommandControl.isPromoted and isPromotedByDefault?

How to use CommandControl.isPromoted and isPromotedByDefault?

thomasa88
Advocate Advocate
579 Views
4 Replies
Message 1 of 5

How to use CommandControl.isPromoted and isPromotedByDefault?

thomasa88
Advocate
Advocate

My add-ins usually set isPromoted and isPromotedByDefault to true on init for controls that I want to be visible in the Fusion toolbars (without opening a menu).

 

However, I just noticed that this seems to break the user's preferences, set by right-clicking a control and pinning it.

 

What is the correct way to use these options? When to use which one?

 

The built-in controls in the Fusion panels all seem to behave well. Do they all store the value of isPromoted on exit, and restore it on launch?

 

0 Likes
Accepted solutions (1)
580 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

It sounds like you understand the purpose of these properties and are using them correctly. I use them in some add-ins I've written too. What is it you're seeing that makes you think something is broken? I'm not aware of any issues with it.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 5

thomasa88
Advocate
Advocate

 

 

Steps:

  1. Create new Python add-in in Fusion
  2. Edit the add-in, by commenting out this line in commandDialog/entry.py:
    control.isPromoted = IS_PROMOTED
  3. Run the add-in. The "Command Dialog Sample" entry is not promoted in Design->Utilities->Add-ins.
  4. Select the triple dots on the command and select "Pin to Toolbar".
  5. The command is now pinned.
  6. Reload the add-in. The command is no longer pinned - overriding the user's preference!

 

If you do the same thing with a built-in command (e.g. Inspect->Zebra analysis) and restart Fusion 360, the pinning is remembered.

 

Is this intended? From this result, it sounds like add-ins should store their "isPromoted" state on exit and restore it when they are loaded.

 

"isPromotedByDefault" seem to exert the exact same behavior. My belief was that isPromotedByDefault would dictate the promotion state until the user overrides it (while isPromoted was an option to force a value). Right now, I don't understand the difference between isPromoted and isPromotedByDefault.

0 Likes
Message 4 of 5

BrianEkins
Mentor
Mentor
Accepted solution

It works for me if the add-in is set to "Run on Startup" in the "Scripts and Add-Ins" dialog. If I don't have it set to "Run on Startup" then the setting is not remembered. However, if I disable the "Run on Startup" and then restart Fusion, the command is no longer promoted. I think that's OK because typically you would install the add-in on someone's computer with the default of "Load on Startup" defined in the manifest file. Unless they specifically disable it, the add-in will always be loaded and the promoted setting will be honored.

 

Here's the difference between isPromoted and isPromotedByDefault. The isPromoted provides exactly the same behavior as "Pin to Toolbar" option in the user interface. It promotes it to be displayed in the main toolbar. However, if the user runs one of the reset commands by right-clicking within the toolbar, Fusion will reset the specified panel or the entire toolbar. Resetting restores the layout to default. By setting the isPromotedByDefault property to True, your command will remain promoted even after the reset.

 

While I was looking at the isPromoted, I noticed a bug. I had set the add-in to not load on start-up and then once Fusion was running, I manually loaded it. It's not promoted, as I described above. However, when I went to promote, the "Pin to Toolbar" option in the pop-up is disabled. I believe it thinks it's already enabled. So it appears that if you load an add-in manually and any of the commands are set to be promoted, the promotion doesn't happen. It only works when the add-in is loaded at startup. I think this is a bug, but I don't think it's critical since that would not be a common workflow.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 5

thomasa88
Advocate
Advocate

Thanks for your detailed explanation!

0 Likes