Notifications
Clear all

[Closed] Select multiple folders in maxscript?

Say I have a folder A.
Inside of that folder I have a lot of project folders.
Inside of those folders I have folders with max files.

Now I would like to select some, but not all of the folders inside of A.

GetSavePath() is not an option as it only allows me to select 1 folder.
GetOpenFilename() is not an option as it only allows for files to be selected.

5 Replies

try this one


or make a treeview representing the folder structure

I had the same issue while ago. Solved it using this – https://github.com/Willy-Kimura/BetterFolderBrowser

(
	global rol_
	try(destroyDialog rol_)catch()
	rollout rol_ ""
	(
		local dllpath = @"C:\BetterFolderBrowser.dll"
		local assembly = dotNetClass "System.Reflection.Assembly" 

		button btn_getFolders "Get Folders"
		
		on btn_getFolders pressed do
		(
			dnOFD = assembly.loadfrom dllpath
			bfbd = dotnetObject "WK.Libraries.BetterFolderBrowserNS.Helpers.BetterFolderBrowserDialog"				
			bfbd.AllowMultiselect = true		
			result = bfbd.showDialog()				
			print bfbd.FileNames
		)
	)
	createdialog rol_ 	
	
)

Until a couple of years ago, I would have done this using System.Windows.Forms OPenFileDialog…
Today I’m trying to find a Qt solution… something like this:

ps2 = python.import "PySide2"
widgets = ps2.QtWidgets
core = ps2.QtCore
maxwnd = widgets.QWidget.find (windows.getMAXHWND())

	
(
	file_dialog = widgets.QFileDialog maxwnd
	file_dialog.setFileMode file_dialog.DirectoryOnly
	file_dialog.setOption file_dialog.DontUseNativeDialog true

	file_dialog.setWindowFlag core.Qt.WindowContextHelpButtonHint false
	file_dialog.setWindowFlag core.Qt.WindowMinimizeButtonHint true
	file_dialog.setWindowFlag core.Qt.WindowMaximizeButtonHint true	
	
	file_listview = file_dialog.findChild widgets.QListView
	if file_listview != undefined do
	(
		file_listview.setSelectionMode widgets.QAbstractItemView.MultiSelection
	)

	file_treeview = file_dialog.findChild widgets.QTreeView
	if file_treeview != undefined do
	(
		file_treeview.setSelectionMode widgets.QAbstractItemView.MultiSelection
	)

	if (file_dialog.exec()) do
	(
		folders = file_dialog.selectedFiles() as array
	)
)

but I probably like this solution more than the others, since multiple directory selection is not a common and typical UI solution, so it requires a “deliberately” custom implementation.

Another “solution” – allow the users to drag and drop the selected folders(and files) onto your UI(most probably the list in which you will show the selected folders).

Edit: not a solution at all. I had to press [Reply] button 40 times.