<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Pin Feature to toolbar in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8118301#M15860</link>
    <description>&lt;P&gt;The shortcut menu and the "Pin to&amp;nbsp;Shortcuts" functionality was just recently added.&amp;nbsp; The "Pin to&amp;nbsp;Toolbar" functionality has always been available but was previously accessed through the promote option next to each command.&amp;nbsp; The API equivalent of this is the isPromoted&amp;nbsp;property of the CommandControl object.&amp;nbsp; You can also use the isPromotedByDefault so that if the user resets all toolbar customization, it will stay promoted.&amp;nbsp; This in the discussed in this API help topic:&amp;nbsp;&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "Pin to Shortcuts" capability is not supported by the API.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Jul 2018 16:49:04 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2018-07-09T16:49:04Z</dc:date>
    <item>
      <title>Pin Feature to toolbar</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8118142#M15859</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Is there&amp;nbsp;a way to&amp;nbsp;pin a control (e.g. a Chamfer Feature) to a toolbar panel (for example to a created toolbar panel) through the API in an addin?&lt;/P&gt;&lt;P&gt;(as&amp;nbsp;described in the attached picture)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 15:51:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8118142#M15859</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-09T15:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Pin Feature to toolbar</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8118301#M15860</link>
      <description>&lt;P&gt;The shortcut menu and the "Pin to&amp;nbsp;Shortcuts" functionality was just recently added.&amp;nbsp; The "Pin to&amp;nbsp;Toolbar" functionality has always been available but was previously accessed through the promote option next to each command.&amp;nbsp; The API equivalent of this is the isPromoted&amp;nbsp;property of the CommandControl object.&amp;nbsp; You can also use the isPromotedByDefault so that if the user resets all toolbar customization, it will stay promoted.&amp;nbsp; This in the discussed in this API help topic:&amp;nbsp;&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-F31C76F0-8C74-4343-904C-68FDA9BB8B4C&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "Pin to Shortcuts" capability is not supported by the API.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jul 2018 16:49:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8118301#M15860</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2018-07-09T16:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pin Feature to toolbar</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8119870#M15861</link>
      <description>&lt;P&gt;Thanks, that was exactly what I was looking for!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did not&amp;nbsp;find a way to directly pin a command to another toolbar panel, but&amp;nbsp;adding the command to a new toolbar and pinning it afterwards works just fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code snippet for anyone wondering for the Chamfer Command:&lt;/P&gt;&lt;PRE&gt;# create new toolbar 
workSpace = ui.workspaces.itemById('FusionSolidEnvironment')
tbPanels = workSpace.toolbarPanels
global tbPanel
tbPanel = tbPanels.itemById('ShaftPanel')
if tbPanel:
    tbPanel.deleteMe()
tbPanel = tbPanels.add('NewPanelID', 'NewPanelName', 'SelectPanel', False)

# get existing command by ID
cmdDefChamfer = ui.commandDefinitions.itemById('FusionChamferCommand')

# add and pin the command to new toolbar
button = tbPanel.controls.addCommand(cmdDefChamfer)
button.isPromoted = True&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jul 2018 08:47:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8119870#M15861</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-07-10T08:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Pin Feature to toolbar</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8213643#M15862</link>
      <description>&lt;P&gt;Dear Stefan. Good afternoon, Could you send a full page with the python code for the Pin Feature to toolbar solution. I try to understand a similar problem and your script would help me a lot. Thank you in advance Dmitri&lt;/P&gt;&lt;DIV class="TnITTtw-translate-selection-button"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Aug 2018 11:22:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/8213643#M15862</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-21T11:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Pin Feature to toolbar</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/9975091#M15863</link>
      <description>&lt;P&gt;For who is interested, an addIn example to pin a command to a toolbar pane (the ./resources folder needs to be created with optional icon png's)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core, adsk.fusion, adsk.cam, traceback

handlers = []
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

commandId = 'myTest'

class ReloadModulesCommandExecuteHandler(adsk.core.CommandEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        try:
            _ui.messageBox('Test succesfull')
        except:
            _ui.messageBox('ReloadModulesCommandExecuteHandler executed failed: {}'.format(traceback.format_exc()))

# Event handler for the commandCreated event.
class ReloadModulesCommandCreatedHandler(adsk.core.CommandCreatedEventHandler):
    def __init__(self):
        super().__init__()              
    def notify(self, args):
        try:
            command = args.command
            onExecute = ReloadModulesCommandExecuteHandler()
            command.execute.add(onExecute)
            handlers.append(onExecute)                                     
        except:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))     

def deletePanel(id :str):
    workSpace = _ui.workspaces.itemById('FusionSolidEnvironment')
    panels = workSpace.toolbarPanels
    panel = panels.itemById(id)

    if panel:
        panel.deleteMe()

def run(context):
    try:
        global _ui, _app, commandId
        _app = adsk.core.Application.get()
        _ui  = _app.userInterface

        # Add reload modules command.
        reloadModulesCmdDef = _ui.commandDefinitions.itemById(commandId)
        if not reloadModulesCmdDef:
            reloadModulesCmdDef = _ui.commandDefinitions.addButtonDefinition(
                commandId,
                'Test',
                'Test description',
                './resources'
            )

            # Connect to Command Created event.
            onCommandCreated = ReloadModulesCommandCreatedHandler()
            reloadModulesCmdDef.commandCreated.add(onCommandCreated)
            handlers.append(onCommandCreated)

        # delete panel (if exists)
        deletePanel(commandId + 'Panel')

        # create new toolbar 
        workSpace = _ui.workspaces.itemById('FusionSolidEnvironment')
        panels = workSpace.toolbarPanels
        panel = panels.add(commandId + 'Panel', 'NewPanelName', 'SelectPanel', False)

        # add and pin the command to new toolbar
        button = panel.controls.addCommand(reloadModulesCmdDef)
        button.isPromoted = True

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def stop(context):
    try:        
        # Delete controls and associated command definitions created by this add-ins

        panel = _ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
        cmdControl = panel.controls.itemById(commandId)

        if cmdControl:
            cmdControl.deleteMe()

        cmdDef = _ui.commandDefinitions.itemById(commandId)
        if cmdDef:
            cmdDef.deleteMe()

        deletePanel(commandId + 'Panel')

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jan 2021 18:58:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/pin-feature-to-toolbar/m-p/9975091#M15863</guid>
      <dc:creator>wh6Q9NU</dc:creator>
      <dc:date>2021-01-03T18:58:26Z</dc:date>
    </item>
  </channel>
</rss>

