Picking Scene Nodes By Hit

pickObject [ message:<string> ] [ prompt:<string> ] \

           [count:n|#multiple] [ filter:fn ] \

           [ select:<boolean> ]

The pickObject() function lets the user pick one or more scene objects in the 3ds max viewports. It takes several optional keyword arguments. The message: argument takes a string value which is displayed in the status bar prompt line. The prompt: argument takes a string value which is displayed in the Listener window. The count: argument takes either a positive integer or the symbol #multiple to specify how many objects are to be picked (default is 1). If the count specified is greater than 1 or the value #multiple, an array is returned containing the picked objects. The symbol #multiple indicates that any number of objects can be selected and the user terminates the selection with a right mouse click or, if the Listener window has focus, any character key of the keyboard. If the ESC key is pressed while the Listener windows has focus, an #escape value will be returned. If the ESC key is pressed while a viewport has focus, selection is terminated and the selection result is returned.

If #multiple was specified, and no objects had been selected when the selection was terminated, an empty array is returned. If #multiple was not specified, and an object had not been selected when the selection was terminated, a value of undefined is returned.

The filter: function takes a MAXScript function of one argument that is called whenever the cursor is over an object in the scene and is passed that object under the cursor. It returns true if the object is eligible for picking, or false if not. Typically, the function would contain some object class testing, for example:

   fn shapeFilt o = superClassOf o == Shape

which you could use like this:

      pickObject prompt:"enter a shape" filter:shapeFilt

The optional keyword argument select: controls whether the picked objects become the new current selection in the 3ds max scene. If you supply true for that argument, the current selection is replaced with the objects that you pick. The default is false in which case the picker doesn't affect the selection set.