View Full Version : Material Names as array for dropdown box
Gibbz 11-08-2005, 09:39 AM im trying to get a list of the submaterials for a dropdown box for my script.
So far ive got the following
myMaterialList = ($.material.materialList as array)
dropdownlist myMaterialName items:myMaterialList
when it trys to load it gives the following error
" Unable to convert: Material #25:Standard to type: String"
obviously myMaterialList[1] outputs "Material #25:Standard"
Is it possible to remove the ':Standard' form the end of the material in all values in the array, via a loop.
|
|
j-man
11-08-2005, 10:02 AM
Hi Bronson,
You need to build a new array of materials by querying the materials names from your material array in a for loop
mymat.name
Josh.
Gibbz
11-08-2005, 10:24 AM
sweet, thanks again :)
Gibbz
11-08-2005, 11:02 AM
ok ive got the following
myMaterialListName = #("Material #25", "Material #25")
dropdownlist myMaterialName width:80 height:40 pos:[5,245] items:myMaterialListName
but they dont show in the list, also ill need to be able to update the list, i tryed the following.
dropdownlist.mymaterialname.items
but it doesnt allow me to update them.
EDIT: ok ive noticed it doesnt work the first time i load the script, but the scond time i load it it works as the array is in memory. So basically i need to get the dropdownlistbox to update... How do i do that?
Thanks
j-man
11-08-2005, 11:55 AM
ok,
So you need to build you list of strings when the rollout opens. So define a function that builds the list, and then call it when the rollout opens:
rollout myrollout "rollout"
(
fn collectmatnames=
(
...collect material names...
mydropdownlist.items=blahblah
)
on myrollout opens do collectmatnames()
)
You can then call this whenever the list might change (ie new materials added, etc)
Josh.
Gibbz
11-08-2005, 11:39 PM
ok when i use the following
dropdownlist myMaterialName "" width:80 height:40 pos:[5,245]
myMaterialName.items=myMaterialListName
i get the following error
>> MAXScript Rollout Handler Exception: -- Unknown property: "items" in undefined <<
Basically it seems as tho its not able to use the .items part :|
j-man
11-09-2005, 11:15 AM
Are you tring to change the items from outside the rollout? if so you will need to specify the rollout:
myrollout.myuidropdownlist.items
Oh, and my code above should read open, not opens.
If this doesn't help, maybe you should post some more code to look at.
Josh.
Gibbz
11-09-2005, 11:30 AM
Cool, that works well!
just need the extra myrollout. bit on there.
I was doing it from within a function.
CGTalk Moderation
11-09-2005, 11:30 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.