Notifications
Clear all

[Closed] Multiple selection in Dialog Box?

When I pressed a button ,then open a Dialog Box which is to select bitmap. The problem is that I only can select only one bitmap ( using selectBitmap()). However, select multiple files is better.
Any way to get it?

Thanks anyway

10 Replies

I may be misunderstanding the question, but why not create a MultilistBox[size=2], which will allow the user to select multiple items, and then you can run whatever command you want on the resulting array?

  • Neil[/size]

mr soulburn is correct. Lookup “Multilistbox”, populate the listbox with the array of string names you want it to read and then based on the multilistbox.selection use that to iterate over.

-Colin

Sorry I used the wrong title to misunderstand everyone.
My idea is to use the function selectBitmap() to select multiple files to put them into array. But selectBitmap() only can select one file at one time. If I want to select more than one file , I have to repeat this action many times. Window Explorer let us select multiple files by pressing Shift key or Ctrl key. So that selection way is my wish.

Thanks for reply.

1 Reply
 eek
(@eek)
Joined: 11 months ago

Posts: 0

Then a “Multilistbox” it still is!

He wants the to use a function like getMAXOpenFileName() but allow the user to select multiple files like you can do in photoshop. So I want “A.tif, B.tif, C.tif” by ctrl clicking in the explorer window. And then when you press “open” have it return an array.

Which no, is not possible. I don’t have the code here but I did make a primitive file browser for a script a while back. That would be my recommendation. Write your own image explorer/opener script. Bonus points for using .net

So I have to learn dot net in Maxscript. Maybe that is the proper way to achieve the work.
Thanks everyone’s suggestion.

maybe you could loop the open file dialog to fill the array?


(
FilesArray = #()

for f in 1 to 200 do 
	( 
	i=getMAXOpenFileName()
	if i==undefined then exit
	append FilesArray i 
	)

)

but no … you can’t select multiple files at once 🙁

You could obtain an array of the bitmaps through an openfile dotnet control. This could be used to filter out which ever images files you wanted to work with as you browse folders (just like the max open file dialogue), but the joys of DOT net allow you select multiple files! An array is then returned with them all in.

This has proved invaluable to me on many occasions, since it can speed things up so much. I am by no means a DOT NET expert, in fact I am completely lame at it, but Mr Bobo has been nice enough to write out this neat web page:

http://www.scriptspot.com/bobo/mxs9/dotNet/OpenFileDialog.html

I have pasted the Code below for convenience, but all the credit goes to Bobo.



theDialog = dotNetObject  "System.Windows.Forms.OpenFileDialog"  --create a OpenFileDialog
theDialog.title = "PLEASE Select One Or More Files" --set the title

//This is the awesome bit! Activate the multi select :)
theDialog.Multiselect = true --allow multiple files to be selected

//Change this section as you would a normal max file open dialogue to filter the required image types
theDialog.Filter = "HTML Files (*.html)|*.html|All Files (*.*)|*.*" --specify the filter
theDialog.FilterIndex = 2 --set the filter drop-down list to All Files
result = theDialog.showDialog() --display the dialog, get result into variable

result.ToString() --when closed, convert the result to string
result.Equals result.OK --returns TRUE if OK was pressed, FALSE otherwise
result.Equals result.Cancel --returns TRUE if Cancel was pressed, FALSE otherwise

//And there you go, a nice need Array with all the filenames contained
theFilenames = theDialog.fileNames --the selected filenames will be returned as an array



Hope I have understood your problem correctly! Let us know if this is along the right lines!

Good luck,

Rich

Just one note to add to the above incredibly thorough response:

You will need to add a

   
for o in arrayvar do o = (openbitmap o)

after the .net window closes to

to perfectly match the behavior of the selectBitmap() function.

Finally , I am happy with more people touching my idea. Anyway , thanks for every response. Now I already understood what to do.