Share

Adding Selection and Display Filters

In the Selection filters/Combos filter, you can add class id filters in addition to registering superclassid filters. The bottom left list box displays a list of all helper and geometry class ids. To add a filter, select an entry from the list and hit the add button below the list box. The filter will appear in the lower right list box. This list displays all of the current class id filters. Once OK is pressed, the select filter drop down contains those class ids that were added.

You can also register custom scripted functions as filters through a callback in MAXScript:

Methods

registerSelectFilterCallback <filterFunction> <name>

Registers a custom selection filter. The two parameters are the filter function to be registered and the name of the filter to appear in the selection filter drop down list.

The filter function itself expects one parameter which is the node to be checked.

FOR EXAMPLE

If you want to filter only objects that are renderable (in other words have their node-level Renderable property set to true / Renderable box checked in Properties dialog), you can register the following function:

fn filterRenderableCallback node = --the node to be filtered is passed as argument
(
node.renderable --return true if the node is renderable
)
--Register the function as Select filter Callback function
--The filter will appear under the name "Renderable":
registerSelectFilterCallback filterRenderableCallback "Renderable"
--To see how it works, execute the code below to generate 10 boxes
--with random .renderable state
for i = 1 to 10 do
b = box pos:[i*30,0,0] renderable:((random 0.0 1.0) < 0.5 )
--Now select the filter "Renderable" from the drop-down list and try
--to select all 10 boxes - only those that are renderable will
--be selected!
unregisterSelectFilterCallback ( <filterFunction> | undefined )

Removes the specified callback function from the list of selection filters.

FOR EXAMPLE

unregisterSelectFilterCallback filterRenderableCallback
<boolean> selectFilterCallbacksEnabled()

Returns whether selection filter callbacks are enabled. Available in 3ds Max 2021.1 Update and higher.

<boolean> enableSelectFilterCallbacks()
<boolean> disableSelectFilterCallbacks()

Enables or disables selection filter callbacks. These functions return the current callbacks enabled state. So, for example, calling disableSelectFilterCallbacks() when callbacks are already disabled will return false. Available in 3ds Max 2021.1 Update and higher.

showregisteredSelectFilterCallbacks [to:stream] [asArray:<boolean>]

Returns a list of registered selection filter callbacks, listing the function name, source file (if applicable) and line number in the source file where the function is defined. If the optional to argument is specified, the output is sent to that output stream. If the optional asArray argument is specified, the return value is formatted as an array of arrays, where for each registered callback function the first element is the callback function name, the second element is the source file name and line number where the callback function is defined (or an empty string if the function was not defined in a file), and the third element is the actual function value which can be used to de-register the callback. Available in 3ds Max 2021.1 Update and higher.

Display Filters

Display filters are used to show or hide nodes, and are accessed on the Hide by Category panel of the Display Tab in the command panel. New display filters can be added here, or through MAXScript.

registerDisplayFilterCallback <filterFunction> <name>

Registers a custom display filter. The two parameters are the filter function to be registered and the name of the filter to appear in the list of available categories.

The filter function itself expects one parameter which is the node to be checked, and returns true if the node is to be hidden, false if it is to be visible. If any registered function returns true, the node is hidden.

FOR EXAMPLE

If you want to display only objects with a name that starts with "B":

fn filterBCallback node = (node.name == "" or node.name[1] != "B") -- hide if no name or first character is not 'B'

registerDisplayFilterCallback filterBCallback "OnlyB!"
unregisterDisplayFilterCallback <filterFunction>

Removes the specified callback function from the list of display filters.

<boolean> displayFilterCallbacksEnabled()

Returns whether display filter callbacks are enabled. Available in 3ds Max 2021.1 Update and higher.

<boolean> enableDisplayFilterCallbacks()
<boolean> disableDisplayFilterCallbacks()

Enables or disables display filter callbacks. These functions return the current callbacks enabled state. So, for example, calling disableDisplayFilterCallbacks() when callbacks are already disabled will return false. Available in 3ds Max 2021.1 Update and higher.

showregisteredDisplayFilterCallbacks [to:stream] [asArray:<boolean>]

Returns a list of registered display filter callbacks, listing the function name, source file (if applicable) and line number in the source file where the function is defined. If the optional to argument is specified, the output is sent to that output stream. If the optional asArray argument is specified, the return value is formatted as an array of arrays, where for each registered callback function the first element is the callback function name, the second element is the source file name and line number where the callback function is defined (or an empty string if the function was not defined in a file), and the third element is the actual function value which can be used to de-register the callback.

Was this information helpful?