Notifications
Clear all

[Closed] Update Dropdownlist with appended array "on the fly"

Hi guys,

I’m pretty stuck with a fairly simple command –

My script creates new materials and applies them to objects in the scene.
Alongside this, it looks at materials that are already in the scene, and allows you to choose these from a dropdown list, and apply these to the selected objects. The dropdown list is using an array of material names within the scene.

When I create a new material (text box for name_of_new_material + button to assign material to selection), I append the material_name array with name_of_new_material.

To check to see if this is working, I have added this:

print material_name

so that, in the listener, I can see that the material_name array has been updated properly.

I am now stuck!

  • I can’t seem to be able to update the dropdown list with the appended Material_Name array, unless I close and restart the script (which kind of makes the append material_name command useless in this case, as it re-calculates everything from scratch).

can you see what I’m trying to do…? kind of?

Any advice or suggestions? I don’t know how to do this! :shrug:

3 Replies

This should do it:


append material_name [i]newMaterial[/i].name
[i]yourdropdownlist[/i].items = material_name

Note:
You probably already noticed this, but the .items collection of a dropdownlist/listbox/multilistbox cannot be altered dynamically. ie: you cannot use append on this collection directly.

  • Martijn

Yep …I tried the “append item” approach, and “append dropdownlist <name> items:<array>”.

Thanks for the reply – I will try it out now!

Geri

:bounce:

…et voila!

Cheers mate – A great help