Interface: ViewportFilter
This core interface exposes the Viewport Filter feature introduced in 3ds Max 2022.3 Update.
Properties:
.Enabled : boolean : Read|Write
Enables or disables the viewport filter for the current viewport (the viewport index corresponding to the ViewportID
property).
.ShowRenderable : boolean : Read|Write
Specifies what is filtered. When true
, only renderable objects are shown in the viewport. When false
, the viewport contents are filtered by category.
.SceneContentsMode : boolean : Read|Write
Specifies what appears in the Show By Category list. When true
, only types of objects that appear in the current scene appear in the list. When false
, all categories are displayed, regardless of whether they exist in the current scene.
.ViewportID : index : Read|Write
Returns the index of the viewport to which the current settings apply. Normally this is the active viewport, or the same as viewport.activeViewport
, and will change when the user activates different viewports. However, this value can be set, and settings for non-active viewports can be accessed and modified. Once this property is set, it no longer changes to reflect the currently active viewport.
Methods
<boolean>AddFilteredSuperClassID <integer64>superClassID
Adds the specified superClassID to the list of filtered (hidden) categories.
For example, to hide all Cameras:
ViewportFilter.AddFilteredSuperClassID 32L
<boolean>RemoveFilteredSuperClassID <integer64>superClassID
Removes the specified superClassID from the list of filtered super classes.
<boolean>ClearFilteredSuperClassIDs()
Removes all filtered super classes from the Show By Category list. This means all categories are visible in the viewport.
<integer>GetNumFilteredSuperClassIDs()
Returns the number of SuperClassIDs (corresponding to top-level categories) that are hidden (deselected) in the Show By Category list.
This method returns the total number of hidden categories, regardless of the state of the Filter UI. For example, the user might hide 4 categories while showing all categories, then change the mode to Scene Contents, reducing the list to only 3 items. This method will still return 4.
<integer64>GetFilteredSuperClassID <index>index
Gets the superclass ID for the hidden category at the specified index, or 0 if the index is not hidden. The index is for the list of hidden categories, not the list of all categories, and is empty if no categories are hidden.
<boolean>AddFilteredClassID <integer64 array>classID
Adds the specified classID to the list of filtered categories.
For example, to hide all Geosphere objects in the viewport:
ViewportFilter.AddFilteredClassID #(0L, 32670L)
<boolean>RemoveFilteredClassID <integer64 array>classID
Removes the specified classID from the list of filtered class IDs.
<boolean>ClearFilteredClassIDs()
Clears the list of all filtered Class IDs. This will clear all class IDs even if they have different superclass IDs.
<integer>GetNumFilteredClassIDs()
Returns the number of filtered (hidden) class IDs.
This method returns the total number of hidden categories, regardless of the state of the Filter UI. For example, the user might hide 4 categories while showing all categories, then change the mode to Scene Contents, reducing the list to only 3 items. This method will still return 4.
<integer64 array>GetFilteredClassID <index>index
Returns the filtered class ID at the specified index, or 0 if the index is not hidden. The index is for the list of hidden sub-categories, not the list of all sub-categories, and is empty if no categories are hidden.
<boolean>Copy()
Copies the current filter settings. This is equivalent to clicking the Copy button on the filter UI.
<boolean>Paste()
Pastes the current filter settings. This is equivalent to clicking the Paste button on the filter UI.
<boolean>Reset()
Resets the viewport settings to the defaults.
<boolean>IsNodeShown <node>node
Returns true of the specified node is visible in the viewport, false if it is hidden.
<boolean>OpenDialog()
Opens the viewport filter settings dialog for the currently active viewport.
<boolean>CloseDialog()
Closes the viewport filter settings dialog, if it is currently open.
<boolean>ShowCategory <value>category <boolean>show
Sets the viewport filter for the specified category
to the specified show
value. For example, to hide geometry:
ViewportFilter.ShowCategory GeometryClass false
<boolean>ShowCategories <&value array>categories <boolean>show
categories is In and Out parameter
Sets the viewport filter for the specified categories to the specified show value. For example, to hide teapots, bones and boxes:
cats = #(Teapot, Bone, Box)
ViewportFilter.ShowCategories cats false
-->true
<value array>GetCategories <boolean>show
Returns an array of categories that match the specified show
value. For example, passing show
as true returns all categories currently set to be visible in the viewport.
<boolean>CategoriesShowAll()
Sets all categories for the current viewport filter to show (display).
<boolean>CategoriesShowNone()
Sets all categories for the current viewport to hide.
<boolean>CategoriesShowInvert()
Inverts the current show/hide settings, so categories that were set to hide now show, and categories set to show are now hidden.
<boolean>RegisterFilterChangeCallback <value>filterChangeCallback
Registers a callback to execute whenever the filter settings change.
For example:
fn myViewportFilterCBK vid filteredNodes =
(
format "vid: %\n" vid
for n in filteredNodes do (
format "filtered: %\n" n.name
)
)
ViewportFilter.UnRegisterFilterChangeCallback myViewportFilterCBK -- in case it's already registered
ViewportFilter.RegisterFilterChangeCallback myViewportFilterCBK
<boolean>UnRegisterFilterChangeCallback <value>filterChangeCallback
Unregisters the specified filter change callback.
<value>ShowRegisteredFilterChangeCallbacks to:<value> asArray:<boolean>
to default value: undefined
asArray default value: false
Actions
None