<?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: addDropDown control to ToolbarPanel in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7153023#M18004</link>
    <description>&lt;P&gt;Marshall,&lt;/P&gt;&lt;P&gt;Sorry for the delay.&amp;nbsp; I made a little trip to the hospital.&amp;nbsp; I had a stent last year and I thought it was happening again.&amp;nbsp; Turns out my heart is ok and they think my meds are wrong.&amp;nbsp; We will see.&amp;nbsp; In any case, I will make that new post now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 20:03:04 GMT</pubDate>
    <dc:creator>sgraves</dc:creator>
    <dc:date>2017-06-14T20:03:04Z</dc:date>
    <item>
      <title>addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7143357#M17997</link>
      <description>&lt;P&gt;I have been trying to find documentation on adding a dropdown control to a ToolbarPanel.&amp;nbsp;&amp;nbsp; The API user manual teases by showing examples without code.&amp;nbsp; Searching shows numerous examples of adding a button, but I haven't any for the dropdown.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The user manual implies that every control needs a command definition and it implies that the ListDefinition is the one for a dropdown.&amp;nbsp; But the addDropDown method is not like the addCommand method.&amp;nbsp; It does not have a parameter for a command definition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my code that doesn't work.&amp;nbsp; What is the right way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;# -*- coding: utf-8 -*-
"""
Created on Fri Jun  9 17:44:24 2017

Gear Generator
@author: Steve Graves
"""
import adsk.core, adsk.fusion, adsk.cam, traceback
import math

# Globals
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
_units = ''

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui  = _app.userInterface

        createPanel = _ui.allToolbarPanels.itemById('SolidCreatePanel')
        dropCmdDefGear = _ui.commandDefinitions.addListDefinition('smgDropGearGenList', 'Gear Generator', adsk.core.ListControlDisplayTypes.StandardListType)

        dropGear = createPanel.controls.addDropDown('Gear Generator','', 'smgDropGearGen') #Resources/GearGen

        cmdGearPlanetDef = _ui.commandDefinitions.addButtonDefinition('smgCmdGearGenPlanet', 'Planetary Gears', 'Creates a planetary gear component', '')   #Resources/GearGen     
        planetGearButton = dropGear.controls.addCommand(cmdGearPlanetDef)
        
        if context['IsApplicationStartup'] == False:
            _ui.messageBox('The "Gear Generator" commands have been added\nto the CREATE panel of the MODEL workspace.')
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def stop(context):
    try:
        createPanel = _ui.allToolbarPanels.itemById('SolidCreatePanel')
        planetGearButton = createPanel.controls.itemById('smgCmdGearGenPlanet')       
        if planetGearButton:
            planetGearButton.deleteMe()
        
        cmdDef = _ui.commandDefinitions.itemById('smgCmdGearGenPlanet')
        if cmdDef:
            cmdDef.deleteMe()
            
        cmdDef = _ui.commandDefinitions.itemById('smgDropGearGenList')
        if cmdDef:
            cmdDef.deleteMe()
            
            
        dropCtl = createPanel.controls.itemById('smgDropGearGen')
        if dropCtl:
            dropCtl.deleteMe()

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2017 17:52:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7143357#M17997</guid>
      <dc:creator>sgraves</dc:creator>
      <dc:date>2017-06-10T17:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7143548#M17998</link>
      <description>&lt;P&gt;I have my solution.&amp;nbsp; I have a VPN (Virtual Private Network) and I have been keeping the files I work on in folders on the VPN. That way I am working on the same file whatever I am.&amp;nbsp; It had appeared that this was allowed because my scripts were interacting with Fusion.&amp;nbsp; I was exploring the palette sample code and found that it didn't work from a folder on the VPN.&amp;nbsp; When I followed the instructions exactly and created an add-in from Fusion, it worked.&amp;nbsp; Turns out the same is true for my Gear Generator add-in.&amp;nbsp; The code below now works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have a question about the &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ListDefinition&lt;/STRONG&gt;&lt;/FONT&gt;.&amp;nbsp; It appears that I don't need it here.&amp;nbsp; The User Manual is either misleading or incomplete when it discusses the DropDown.&amp;nbsp; I would bet there is a use for &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ListDefinition&lt;/STRONG&gt;&lt;/FONT&gt; or that it is an obsolete object.&amp;nbsp; BTW, the documentation shows a property called &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;listItems &lt;/STRONG&gt;&lt;/FONT&gt;that doesn't appear to be available on the actual object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone fill us in on the uses for &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ListDefinition&lt;/STRONG&gt;&lt;/FONT&gt; ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;import adsk.core, adsk.fusion, adsk.cam, traceback
import math

# Globals
_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)
_units = ''

_handlers = []

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui  = _app.userInterface

        createPanel = _ui.allToolbarPanels.itemById('SolidCreatePanel')
        cmdGearPlanetDef = _ui.commandDefinitions.addButtonDefinition('smgCmdGearGenPlanet', 'Planetary Gears', 'Creates a planetary gear component', '')
        cmdGearTwoShafts = _ui.commandDefinitions.addButtonDefinition('smgCmdGearGen2Shaft', 'Gear Pair on 2 axises', 'Creates a pair of gears between two axises', '')

        dropGear = createPanel.controls.addDropDown('Gear Generator','resources/GearGen', 'smgDropGearGen') #Resources/GearGen
            
        planetGearButton = dropGear.controls.addCommand(cmdGearPlanetDef)
        twoAxisGearButton = dropGear.controls.addCommand(cmdGearTwoShafts)
                
        
        if context['IsApplicationStartup'] == False:
            _ui.messageBox('The "Gear Generator" commands have been added\nto the CREATE panel of the MODEL workspace.')
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def stop(context):
    try:
        createPanel = _ui.allToolbarPanels.itemById('SolidCreatePanel')
            
        dropCtl = createPanel.controls.itemById('smgDropGearGen')
        if dropCtl:
            planetGearButton = dropCtl.controls.itemById('smgCmdGearGenPlanet')       
            if planetGearButton:
                planetGearButton.deleteMe()
                print("planetGearButton deleted")
                
            twoAxisGearButton = dropCtl.controls.itemById('smgCmdGearGen2Shaft')       
            if twoAxisGearButton:
                twoAxisGearButton.deleteMe()
                print("twoAxisGearButton deleted")
                
            dropCtl.deleteMe()
            print("smgDropGearGen DropControl deleted")
        
        cmdDef = _ui.commandDefinitions.itemById('smgCmdGearGenPlanet')
        if cmdDef:
            cmdDef.deleteMe()
            print("smgCmdGearGenPlanet cmddef deleted")            
        
        cmdDef = _ui.commandDefinitions.itemById('smgCmdGearGen2Shaft')
        if cmdDef:
            cmdDef.deleteMe()
            print("smgCmdGearGen2Shaft cmddef deleted")            

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2017 21:46:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7143548#M17998</guid>
      <dc:creator>sgraves</dc:creator>
      <dc:date>2017-06-10T21:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7144786#M17999</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the following piece of codes how to create a drop-down(list) command definition. They are from our&amp;nbsp;sample "AddInSample" in "Scripts and Add-In" dialog and I did some modification(marked as red).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        # add a command button on Quick Access Toolbar
        toolbars_ = ui.toolbars
        toolbarQAT_ = toolbars_.itemById('QAT')
        toolbarControlsQAT_ = toolbarQAT_.controls
        toolbarControlQAT_ = toolbarControlsQAT_.itemById(commandIdOnQAT)
        if not toolbarControlQAT_:
            commandDefinitionQAT_ = commandDefinitions_.itemById(commandIdOnQAT)
            if not commandDefinitionQAT_:
&lt;FONT color="#FF0000"&gt;                commandDefinitionQAT_ = commandDefinitions_.addListDefinition(commandIdOnQAT, commandName, adsk.core.ListControlDisplayTypes.CheckBoxListType)
                listCtlDef = adsk.core.ListControlDefinition.cast(commandDefinitionQAT_.controlDefinition)
                listCtlDef.listItems.add('MyItem1', True)
                listCtlDef.listItems.add('MyItem2', False)
                listCtlDef.listItems.add('MyItem3', False)&lt;/FONT&gt;
            onCommandCreated = CommandCreatedEventHandlerQAT()
            commandDefinitionQAT_.commandCreated.add(onCommandCreated)
            # keep the handler referenced beyond this function
            handlers.append(onCommandCreated)
            toolbarControlQAT_ = toolbarControlsQAT_.addCommand(commandDefinitionQAT_)
            toolbarControlQAT_.isVisible = True
            ui.messageBox(_('A demo command button is successfully added to the Quick Access Toolbar'))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 06:10:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7144786#M17999</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-06-12T06:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7147096#M18000</link>
      <description>&lt;P&gt;Marshall,&lt;/P&gt;&lt;P&gt;Thank you for trying to document the &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ListDefinition&lt;/STRONG&gt;&lt;/FONT&gt; object.&amp;nbsp; I can't get the code to work.&amp;nbsp; I do see a little flash on the QAT, but no menu shows up.&amp;nbsp; I now see that there is a different object called &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListControlDefinition&lt;/FONT&gt;&lt;/STRONG&gt;.&amp;nbsp; It seems like the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ButtonDefinition&lt;/FONT&gt;&lt;/STRONG&gt; and the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListDefinition&lt;/FONT&gt;&lt;/STRONG&gt; do not follow the same pattern.&amp;nbsp; Fortunately, that doesn't seem to happen very often in the API.&amp;nbsp; It does seem that once one gets the API pattern i.e collections, input objects, etc. the concept can be applied in multiple areas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In any case, I have my solution.&amp;nbsp; At this point I don't see any value in the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListDefintion&lt;/FONT&gt;&lt;/STRONG&gt;, so I am not planning on spending time figuring out what is going wrong with the code.&amp;nbsp; I don't plan on marking this as a solution because it would be misleading to the users that follow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And actually, the problem was really operator error.&amp;nbsp; I didn't have the proper debug environment.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 21:24:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7147096#M18000</guid>
      <dc:creator>sgraves</dc:creator>
      <dc:date>2017-06-12T21:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7147417#M18001</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to attach whole sample in the thread so that developers can refer to in case they are interested at&amp;nbsp;using CommandDefinitions.addListDefinition and ListControlDefinition.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-------------------------&lt;/P&gt;
&lt;H1 class="api"&gt;CommandDefinitions.addListDefinition Method&lt;/H1&gt;
&lt;P class="api"&gt;Parent Object: &lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=CommandDefinitions" data-url="/cloudhelp/ENU/Fusion-360-API/files/CommandDefinitions.htm" target="_blank"&gt;CommandDefinitions&lt;/A&gt;&lt;/P&gt;
&lt;H2 class="api"&gt;Description&lt;/H2&gt;
&lt;P class="api"&gt;Creates a new command definition that can be used to create a list of check boxes, radio buttons, or text with an icon within a pop-up. &lt;BR /&gt;&lt;BR /&gt;When the list is of check boxes any combinations of items in the list can be checked. The drop-down also remains displayed allowing the user to check and uncheck multiple items however a CommandCreated event is fired for every change.&lt;BR /&gt;&lt;BR /&gt;When the list is of radio buttons or a list of text items, only one item in the list can be selected at a time. When an item is selected the drop-down is immediately dismissed.&lt;BR /&gt;&lt;BR /&gt;The items in the list and their initial state are defined using functionality on the associated ListControlDefinition, which is accessible through the returned CommandDefinition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-558e25b3-933f-4721-a674-711acd91e331" target="_blank"&gt;http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-558e25b3-933f-4721-a674-711acd91e331&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 01:52:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7147417#M18001</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-06-13T01:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7149188#M18002</link>
      <description>&lt;P&gt;Marshall,&lt;/P&gt;&lt;P&gt;Thank you, very good idea.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a quandary, the title of this post refers to the &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;addDropDown&lt;/STRONG&gt;&lt;/FONT&gt; function which doesn't appear to use the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListControlDefinition&lt;/FONT&gt;&lt;/STRONG&gt;.&amp;nbsp; For me it is the way to go for adding drop down menus to toolbars.&amp;nbsp; It is simpler and it definitely works.&amp;nbsp; But the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListControlDefinition&lt;/FONT&gt;&lt;/STRONG&gt; appears to have a place where it needs to be used.&amp;nbsp; Your post needs to get a little more exposure.&amp;nbsp; But if I accept your post as the solution, it sends the message that the &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;ListControlDefinition&lt;/FONT&gt;&lt;/STRONG&gt; is the way to go when adding a dropdown to a toolbar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I make another post with a different title that you can put your post on as the solution?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:32:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7149188#M18002</guid>
      <dc:creator>sgraves</dc:creator>
      <dc:date>2017-06-13T15:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7150621#M18003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the suggestion. Starting a new post is good idea. I would like to update our sample "AddInSample" and make sure developers can find out how to use "ListControlDefinition" from our help document. I will create a task to track that in our backlog.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Marshal&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 01:24:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7150621#M18003</guid>
      <dc:creator>marshaltu</dc:creator>
      <dc:date>2017-06-14T01:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: addDropDown control to ToolbarPanel</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7153023#M18004</link>
      <description>&lt;P&gt;Marshall,&lt;/P&gt;&lt;P&gt;Sorry for the delay.&amp;nbsp; I made a little trip to the hospital.&amp;nbsp; I had a stent last year and I thought it was happening again.&amp;nbsp; Turns out my heart is ok and they think my meds are wrong.&amp;nbsp; We will see.&amp;nbsp; In any case, I will make that new post now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 20:03:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/adddropdown-control-to-toolbarpanel/m-p/7153023#M18004</guid>
      <dc:creator>sgraves</dc:creator>
      <dc:date>2017-06-14T20:03:04Z</dc:date>
    </item>
  </channel>
</rss>

