[Closed] Drop-down list
I’m writing a little script that will create a simple dropdown list and within the list I want to it to display the scripts in a given directory. Then when you select your script, you press the button and it will run that script. I can figure out how to run the scripts once selected but I can’t seem to get the drop down list to read in the folder of scripts.
So I have it setup as follows:
rollout Roll_1 “WorkScripts” width:300 height:57 Rolledup:true
(
dropdownlist WorkScripts “WorkScripts Directory”
button Run_btn “Run Selected script” enabled:true
on button Run_btn pressed do
(
run blah blah script
)
)
I’m not sure how I get it to read in the scripts from the desired folder. Anyone care to offer a hint of advice?
thanks in advance.
You are missing the “items” parameter when declaring the dropdownlist. You need to pass it an array of strings to appear in the list.
dropdownlist WorkScripts "WorkScripts Directory" items:#("Here","Are","The","Items")
You will also need to get a list of the script files. Read up on “getFiles” in the maxscript reference.
Hi Mathieson! Sorry to put a dampaner on your suggestion, yes it is correct, but in order to make it work (they way Intrinsia wants it to) you’d have to build the rollout dynamically.
Intrinsia you could try something like this…
fn configureMaxScriptList thePathToTheScripts = (
-- List all the maxscripts files in the a folder...
local lstFiles = getFiles (thePathToTheScripts + "\\*.ms") -- You will need to check how the path string is built, as it may already end in "\" depending on how you obtained it...
local lstNames = #()
for fFile in lstFiles do (
-- Get only the name of the file in question...
append lstNames (getFilenameFile fFile)
)
WorkScripts.items = lstNames
)
on roll_1 open do (
configureMaxScriptList "C:\Program Files\Autodesk\3ds Max 9\Scripts"
)
Shane
No worries Shane, I was just pointing in the general direction. You’ve got it bang on there.
Hi! I’ve actually made a script for work that does exactly this only it works slightly differently. I’ve always intended to release it, just never got around to it. I’ll fix it for public release after work and post it here and on scriptspot so you can check it out and hopefully get some ideas from it.
ok the script is too large to just copy the code so i zipped it along with a macro and hopefully attached it to this post. It’s designed to startup with max so i recommend putting it in your <max root>\stdplugs\stdscripts folder and put the macro in the <max root>\ui\macroscripts folder (as i’m sure you guessed ;)) then restart max and check it out!
you might want to check this one out as well: http://oferz.com/maxscripts.php#QuuickRun
cheers,
o