<?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 Clear dropdownlist Issues in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/clear-dropdownlist-issues/m-p/6805986#M18709</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am starting my first fusion add-in and cannot get a dropdownlist to clear its contents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have a couple of dropdownlists, which dynamically update to reflect the user's selections. These dropdowns are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. A "section library" dropdown to choose from standard steel section libraries (i.e. hot rolled, welded, hollow etc.)&lt;/P&gt;&lt;P&gt;2. A "section type" dropdown to choose from more specific sections (i.e. square hollow, circular hollow)&lt;/P&gt;&lt;P&gt;3. A "section" dropdown to choose the specific section (i.e. "100x6 Square Hollow")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the user changes their selections from a higher dropdown (1 or 2) the lower dropdowns should clear their contents and replace with the relevant options. However, I can't seem to get anything to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the code I am using to try and clear the dropdowns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()
                for i in range(0, secttype.listItems.count):
                    secttype.listItems.item(0).isSelected = False
                    secttype.listItems.item(0).deleteMe()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is a larger section of code from the InputChangedHandler. Note that the code for adding values to the dropdown lists works fine - i get ever expanding dropdown lists.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            if changedInput.id == 'sectlib':
                #if its the section library selection, update the section type box
                
                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()
                for i in range(0, secttype.listItems.count):
                    secttype.listItems.item(0).isSelected = False
                    secttype.listItems.item(0).deleteMe()

                lib = sectlib.selectedItem.name
                           
                if lib != '':
                    #next add the libraries to sectlib
                    
                    lines = readFile(getAddInFolder() + '\\Resources\\' + lib + '\\' + lib + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            secttype.listItems.add(l,False)
                            
            elif changedInput.id == 'secttype':
                #need to add sections to the section dropdown                
                
                #ClearList(sect).
                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()                
                
                lib = sectlib.selectedItem.name
                styp = secttype.selectedItem.name  
                
                if lib !='' and styp !='':
                    lines = readFile(getAddInFolder()+'\\Resources\\' + lib + '\\' + styp + '\\' + styp + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            sect.listItems.add(l, False)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Jan 2017 21:31:21 GMT</pubDate>
    <dc:creator>SeanKane88</dc:creator>
    <dc:date>2017-01-14T21:31:21Z</dc:date>
    <item>
      <title>Clear dropdownlist Issues</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/clear-dropdownlist-issues/m-p/6805986#M18709</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am starting my first fusion add-in and cannot get a dropdownlist to clear its contents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have a couple of dropdownlists, which dynamically update to reflect the user's selections. These dropdowns are:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. A "section library" dropdown to choose from standard steel section libraries (i.e. hot rolled, welded, hollow etc.)&lt;/P&gt;&lt;P&gt;2. A "section type" dropdown to choose from more specific sections (i.e. square hollow, circular hollow)&lt;/P&gt;&lt;P&gt;3. A "section" dropdown to choose the specific section (i.e. "100x6 Square Hollow")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the user changes their selections from a higher dropdown (1 or 2) the lower dropdowns should clear their contents and replace with the relevant options. However, I can't seem to get anything to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the code I am using to try and clear the dropdowns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()
                for i in range(0, secttype.listItems.count):
                    secttype.listItems.item(0).isSelected = False
                    secttype.listItems.item(0).deleteMe()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is a larger section of code from the InputChangedHandler. Note that the code for adding values to the dropdown lists works fine - i get ever expanding dropdown lists.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            if changedInput.id == 'sectlib':
                #if its the section library selection, update the section type box
                
                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()
                for i in range(0, secttype.listItems.count):
                    secttype.listItems.item(0).isSelected = False
                    secttype.listItems.item(0).deleteMe()

                lib = sectlib.selectedItem.name
                           
                if lib != '':
                    #next add the libraries to sectlib
                    
                    lines = readFile(getAddInFolder() + '\\Resources\\' + lib + '\\' + lib + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            secttype.listItems.add(l,False)
                            
            elif changedInput.id == 'secttype':
                #need to add sections to the section dropdown                
                
                #ClearList(sect).
                for i in range(0, sect.listItems.count):
                    sect.listItems.item(0).isSelected = False
                    sect.listItems.item(0).deleteMe()                
                
                lib = sectlib.selectedItem.name
                styp = secttype.selectedItem.name  
                
                if lib !='' and styp !='':
                    lines = readFile(getAddInFolder()+'\\Resources\\' + lib + '\\' + styp + '\\' + styp + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            sect.listItems.add(l, False)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jan 2017 21:31:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/clear-dropdownlist-issues/m-p/6805986#M18709</guid>
      <dc:creator>SeanKane88</dc:creator>
      <dc:date>2017-01-14T21:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Clear dropdownlist Issues</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/clear-dropdownlist-issues/m-p/6806021#M18710</link>
      <description>&lt;P&gt;I've found a work-around that isn't really a fix. The approach is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. When selection changes, add all the new items to the dropdown list&lt;/P&gt;&lt;P&gt;2. Make sure the selected item is one of the new items.&lt;/P&gt;&lt;P&gt;3. Delete all the original items from the start of the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This seems very kludgy to me so I'm not happy calling it a "solution" - a simple "clear list" method would be more appropriate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            if changedInput.id == 'sectlib':
                #if its the section library selection, update the section type
                #and section boxes
                
                #need to add sections to the section dropdown first before
                #clearing out old sections as currently there is no "clear"
                # method for a dropdownlist                
                
                #get current no. items in each list
                sectN = sect.listItems.count
                secttypeN = secttype.listItems.count                
                
                #get library type
                lib = sectlib.selectedItem.name
                           
                if lib != '':
                    #next add the libraries to sectlib
                    
                    lines = readFile(getAddInFolder() + '\\Resources\\' + lib + '\\' + lib + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            secttype.listItems.add(l,False)

                # if dropdown was already populated, clear original values 
                if secttypeN &amp;gt; 0:
                    #select a value outside original values
                    secttype.listItems.item(secttypeN).isSelected = True
                    
                    #get rid of everything in list except 1 selected value
                    for i in range(0, secttypeN):
                        secttype.listItems.item(0).deleteMe()
                
                #select the first new element
                secttype.listItems.item(0).isSelected = True                
                
                #add new sections to section list before clearing it.
                
                #get section type selected
                styp = secttype.selectedItem.name 
                
                #update the sect dropdown with new lines
                if lib !='' and styp !='':
                    lines = readFile(getAddInFolder()+'\\Resources\\' + lib + '\\' + styp + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            sect.listItems.add(l, False)
                                   
                
                #select the first new element (i.e. 1 after old list)
                sect.listItems.item(sectN).isSelected = True                    
                
                #delete old list items
                for i in range(0, sectN):
                    sect.listItems.item(0).deleteMe()
                    
                #ensure first new item is selected
                sect.listItems.item(0).isSelected = True
                            
            elif changedInput.id == 'secttype':
                #if it's the section type selection, update the 'sect' dropdown                
                
                #need to add sections to the section dropdown first before
                #clearing out old sections as currently there is no "clear"
                # method for a dropdownlist
                
                #get current no. of items
                sectN = sect.listItems.count
                
                #get library and section type
                lib = sectlib.selectedItem.name
                styp = secttype.selectedItem.name  
                
                #add new elements
                if lib !='' and styp !='':
                    lines = readFile(getAddInFolder()+'\\Resources\\' + lib + '\\' + styp + '.txt')
                    if lines.count != 0:
                        for l in lines:
                            sect.listItems.add(l, False)
                            
                #select first element of new list items (i.e. 1 after old list)
                sect.listItems.item(sectN).isSelected = True

                #clear out original items.
                
                for i in range(0, sectN):
                    sect.listItems.item(0).deleteMe()                            

                #make sure first new item is selected
                sect.listItems.item(0).isSelected = True&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Jan 2017 22:33:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/clear-dropdownlist-issues/m-p/6806021#M18710</guid>
      <dc:creator>SeanKane88</dc:creator>
      <dc:date>2017-01-14T22:33:21Z</dc:date>
    </item>
  </channel>
</rss>

