Create "ListBox" & Check If Text Exists

Create "ListBox" & Check If Text Exists

isocam
Collaborator Collaborator
406 Views
1 Reply
Message 1 of 2

Create "ListBox" & Check If Text Exists

isocam
Collaborator
Collaborator

Can anybody help?

 

Using a Python script, does anybody have an example that does the following....

 

I want to create a listbox containing some text like:

 

001  Bearing Housing

 

The first 3 digits are the quantity, the remainder is the description.

 

1] Create an empty "ListBox"

 

2] Check, line by line, if the "ListBox" contains a wildcard search, for example "Bearing Housing"

 

3] If it does not, add a new line of text to the "ListBox" thus

 

001  Bearing Housing

 

4] If it does, update the quantity by adding 1

 

002 Bearing Housing

 

etc

 

Many thanks in advance!

 

Darren

0 Likes
407 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

Attached is a sample that I believe demonstrates what you want to do.

 

It turned out to be trickier than I thought. I don't know if it's a bug in Fusion or if it's expected behavior, but editing the name of an item in the drop-down does not update it in the dialog. If I change it and then get the name using the API I get the new name, but the old name is still shown in the dialog. 

 

As a workaround to this, I'm deleting the current item and then creating a new one in the same location that has the new name. This works. However, there is a limitation that I was aware and that is you can't delete a list item if it is the one selected. I check for this in the code and if it is selected, I temporarily select another one.

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