You can use the selectByName()
function to open the standard 3ds Max Select By Name dialog allowing users to pick objects which are then returned as an array of MAXScript node values.
The form is:
selectByName [ title:<string>] [ buttonText:<string>] [ filter:<fn>] [ showHidden:<boolean>][ single:<boolean>]
The optional keyword arguments are interpreted as follows:
title:"string "
Specifies the dialog window title.
buttonText:"string "
Lets you specify the label text in the 'accept' button in the dialog. The default value is "Select".
showHidden:<boolean>
Controls whether hidden and frozen objects are eligible for display. The default value is false
. This option was broken in versions prior to 3ds Max 8. Now it works as expected.
single:<boolean>
Controls whether single or multiple objects may be selected in the selector. The default is false
, meaning multiple objects may be selected, and they are returned in an array. If single:true
is specified, a single object may be selected and is returned directly, not in an array.
filter:<fn>
Lets you specify a filter function that determines which objects should be displayed in the list. This is similar to the filter functions elsewhere in MAXScript. The function you supply should take one argument, which the current object being tested for inclusion and the function should return true
for include, false
for exclude. If you don't specify a filter, all objects are displayed.
FOR EXAMPLE,
the following function limits the choices to shape objects:
fn shape_filt obj = isKindOf obj Shape
Then you can call the Select By Name function to select multiple shapes including hidden ones:
theShapes =selectByName title:"Select Shapes" buttonText:"GET 'EM!" filter:shape_filt showHidden:true single:false
RESULT:
If the user cancels out of the dialog, the function returns the value undefined
.