Notifications
Clear all

[Closed] Reloading DropDownList-Items

hi,

i’m writing a script, where the material ids of an object are displayed in a dropdownlist.
if i select another object, i want to refresh the dropdownlist, so that there are the ids of the new object.
but i don’t know, how to refresh the list :shrug:

any suggestions? thanks

4 Replies

You should look into callbacks in the MAXScript help. You need to add a callback for when the selection changes to redo your dropdownlist. Something like…

callbacks.addScript #selectionSetChanged “setupDropDownList()”

which calls a function called setupDropDownList() everytime the selection set changes. All you need to do is write that routine (which you should already have most of).

could you explain it a little bit more detailed? i’m quite new to maxscript.

do i have to copy my

dropdownList matids "MaterialIDs" pos:[33,18] items:IDarray width:122 height:40 selection:1

from my rollout definition into the setupDropDownlist function? IDarray is the array where the material ids are written into.

my script works like this:

    1. rollout with selectionbutton to select object
    1. rollout with dropdownlist to choose material id

so i have to call the callbackscript in my first rollout just after selecting the object, right?

OK. In brief the structure of your script will look something like this – bear with me here as I don’t have MAX in front of me at the moment.


global rolloutName       -- This is needed so that you can access your dropdownlist from outside of the rollout


function SetupDropDownList = (
   ...
   array gathering routine
   ...

   return newArray
)

function RefreshList = (
   rolloutName.matids.items = SetupDropDownList()
)


rollout rolloutName
   dropdownlist matids "MaterialIDs" pos:[33,18] width:1222 height:40

   on rolloutName open do (
      matids.items = SetupDropDownList()
   )
)

callbacks.addScript #selectionSetChanged "RefreshList()"

I hope that makes it clearer. Callbacks are a pretty advanced topic and if you’re new to MAXScript they can be quite tricky, but read the help files they tell you pretty much everything you need to know.

You’ll probably also want to remove the callback once you close your rollout to stop the routine being called all the time.

hey, great, thanks.:applause:
ok, it didn’t work like that but your refresh-function solved my problem, too. so my script seems to go a step further until the next problem appears.:hmm:

so again, thanks a lot!!!