getOpenFileName for multiple files?

getOpenFileName for multiple files?

adnanmg
Advocate Advocate
2,569 Views
5 Replies
Message 1 of 6

getOpenFileName for multiple files?

adnanmg
Advocate
Advocate
Hi,

in Max 2010, I am using the getOpenFileName command via a button in a rollout to select files. Is there any way to select multiple files? I want the user to be able to use the file open dialog to ctrl select multiple files in a dir and for the command to return an array of values.

This way the user can perform a task on multiple files at once instead of one at a time.

Any ideas using this or other commands? I don't want to use all the files in the dir so it is important that the user can select specific ones in the open file dialog.

Thanks!

Adnan
0 Likes
2,570 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
This should be possible via DotNet.

Although I did try adding the following to a rollout but didn't have much luck. Can anyone work out why this wouldn't work?


Rollout Test "" width:400 height:400
(
DotNetControl Test_FileBrower "System.Windows.Forms.FileDialog" pos: width:400 height:400
)

CreateDialog Test ""
0 Likes
Message 3 of 6

Anonymous
Not applicable
Here is a function I wrote that works as a direct replacement for the built-in GetOpenFilename():

fn GetMultiOpenFilenames caption:"Open" filename:"" types:"All Files (*.*)|*.*" default:1 =
(
local dlg = DotNetObject "System.Windows.Forms.OpenFileDialog"
dlg.multiSelect = true
dlg.title = caption

local p = getFilenamePath filename
if doesFileExist p then
dlg.initialDirectory = p

-- MAXScript getOpenFilename uses trailing |;
-- OpenFileDialog filter does not.
if types == "|" then
dlg.filter = (substring types 1 (types.count - 1))
else
dlg.filter = types

dlg.filterIndex = default

local result = dlg.ShowDialog()
if (result.Equals result.OK) then
dlg.filenames
else
undefined
)
0 Likes
Message 4 of 6

Anonymous
Not applicable
Sorry, this new forum software converted all the double-dashes and quotes inside the 'code' tags.
0 Likes
Message 5 of 6

Anonymous
Not applicable
Here is a second attempt at posting my GetOpenFilename() replacement function, this time as an attachment.

Am I missing something, or can I neither delete nor edit replies in this new forum software?
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hm, attachments don't seem to work, either, at least not for .ms files. Trying with a zip.
0 Likes