Changing directories with an array

Hi, I'm tring to write a script that will access material libraries from different folders (much like Sigershader's VMPP). My first listbox is populated by an array of Material Categories and are defined as such...

MatSections = #()
append MatSections #("Metal","C:\Users\Alex\Documents\3dsMax\materiallibraries\Metal\\")
append MatSections #("Wood","C:\Users\Alex\Documents\3dsMax\materiallibraries\Wood\\")
append MatSections #("Glass","C:\Users\Alex\Documents\3dsMax\materiallibraries\Glass\\")

Which currently works. When I select an item in this listbox, I want the second listbox to be populated with a list of the matlibs that reside in the relevant folder. Here's what I have so far...

	on lbx_MatSection selected itm do
		(
		MatCatPath = getFiles "((MatSections[objList.selection][2])"+"*.mat")
		MatCatFiles = for i in MatCatPath collect ( filenamefrompath i )
		lbx_MatCat.items = MatCatFiles
)

Which doesn't work. I get an error saying "-- Syntax error: at =, expected name". Previously I had a simpler script that just loaded all matlibs from a folder (which worked)...

		allMatLibs = getFiles "C:\Users\Alex\Documents\3dsMax\materiallibraries\*.mat"
		list = for i in allMatLibs collect (getFilenameFile i)
		lbx_MatSection.items = list

But it was too simple for what I need now. Basically I'm trying to get the two bits of code to work together but I'm struggling, so any help would be greatly appreciated. Cheers,
Alex

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexcfarrell's picture

Brilliant! Cheers for the

Brilliant! Cheers for the help guys. Thought it would be a simple syntax issue, also would have helped if I renamed objList.selection to lbx_MatSection.selection! And thanks for the script recommendation Barigazy, looks really useful.
Thanks again.

Perfect_Storm's picture

MatCatPath = getFiles

MatCatPath = getFiles "((MatSections[objList.selection][2])"+"*.mat")

You mistyped the (, it should be in front of the ":

MatCatPath = getFiles ("(MatSections[objList.selection][2])"+"*.mat")

br0t's picture

MatCatPath = getFiles

MatCatPath = getFiles "((MatSections[objList.selection][2])"+"*.mat")

That line is wrong, isnt it? Why the quotation marks after getFiles? Maybe more like this:

MatCatPath = getFiles ((MatSections[objList.selection][2]) + "*.mat")

Never get low & slow & out of ideas

barigazy's picture

I suggest you to look inside

I suggest you to look inside the code where i use fixpath fn to collect some bitmap names into list.Hope this can help
http://www.scriptspot.com/3ds-max/scripts/select-objects-by-bitmaptex

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.