[Closed] Dropdownlist problem
Hi guys,
I’m trying to do something really simple but I’m having some problems, I think it has to do with the scope of my variable or something but I don’t seem to manage to fix it.
I’m trying to create a rollout with a dropDown list on it. The content ( items ) for the dropDown should be the contents of an INI file that I have on the HDD, each line on the INI should be an item on the dropdown, but I didn’t manage so far, the only thing I got was an empty items list…any idea what the problem is?
thanks a lot
INIContent =#()
rollout myprojects " My Projects"
(
fn readINI =
(
maxIniPath = "E:\jobs\3dsMaxProjects.ini"
inFile = openFile maxIniPath
while not eof inFile do
(
lineInfo = readLine inFile
append INIContent lineInfo
)
)
editText myProject "Enter Name"
button createButton "Create Project"
dropDownList storedProjects "change to project: " items:INIContent
)
createDialog myprojects 300 300
The problem is that when you run the script the fn is not executed, so the INIContent stays empty.
rollout myprojects " My Projects"
(
local INIContent =#()
fn readINI =
(
maxIniPath = @"E:\jobs\3dsMaxProjects.ini"
inFile = openFile maxIniPath
while not eof inFile do
(
lineInfo = readLine inFile
print lineInfo
append INIContent lineInfo
)
)
editText myProject "Enter Name"
button createButton "Create Project"
dropDownList storedProjects "change to project: "
on myprojects open do
(
readINI()
storedProjects.items = INIContent
)
)
createDialog myprojects 300 300
hey Thanks a lot Miauu, that did work!
SO i understand that is not enough with creating a function, you also need to call it for the variables in it to work?
thanks again, that was really helpful
if you want to update a scripted controller in real time you have to put it in dependency of anything that updates in real time too.
custom attribute is not this kind. so you have to use a controller (or subAnim) instead:
delete objects
t = teapot isselected:on
ScaleControlAttr = attributes ScaleControlAttr attribID:#(0x2feb1967, 0x77a9f6e6)
(
parameters params rollout:params
(
drop type:#integer default:1 animatable:on ui:ui_drop
)
rollout params "Parameters"
(
dropdownlist ui_drop "Drop:" width:130 height:6 align:#left items:#("1","2","3")
)
)
scl_holder = EmptyModifier name:"SCL Holder"
addmodifier t scl_holder
custattributes.add scl_holder ScaleControlAttr
t.scl_holder.drop.controller = linear_float()
sc = t.scale.controller = scale_script()
sc.addTarget "drop" t.scl_holder.drop.controller
ss = "[1,1,1]*drop"
sc.setexpression ss
BTW
the using of subAnim is more ‘pro’ way. And you have a chance to find how to use it yourself