The State Sets render pass management system was first introduced in the Subscription Advantage Pack extension to 3ds Max 2012 and is now integral part of 3ds Max 2013 and higher. In 3ds Max 2018 and higher, the compositing editor is a node-based system.
This feature is exposed to MAXScript via a DotNet object and its properties and methods.
The following example shows the basic steps involved in accessing and manipulating State Sets.
Getting Access To State Sets |
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin" --Get StateSets dotNet object. stateSets = stateSetsDotNetObject.Instance --Get the state sets instance from the dotNet object. |
Opening and closing State Sets window |
stateSets.ShowMainFrame() --Open the State Sets window. stateSets.HideMainFrame() --Close the State Sets window. |
Getting access to the Master state |
masterState = stateSets.EntityManager.RootEntity.MasterStateSet |
Adding and renaming a new state set |
stateSet = masterState.AddState() stateSet.Name = "MyStateSet" masterState.AssignUniqueName stateSet "MyMasterStateset" --Assigns a unique name to the state set |
Changing current state set, starting, and ending recording |
previousCurrentStateSet = masterState.CurrentState.Items[0] --Record current state set. masterState.CurrentState = #(stateSet) --Assign current state set. stateSet.BeginRecording() --Begin recording state set. stateSet.EndRecording() --End recording state set. masterState.CurrentState = #(previousCurrentStateSet) --Assign previous state set. |
Adding and rendering a child sub-state set, and doing other operations |
subStateSet = stateSet.AddState() subStateSet = stateSet.Render #(stateSet) --Render state set, note that we specify a path because this state set could be located under multiple parents. scriptedState = stateSet.AddScriptedState(false) --Add a scripted state. scriptedState.ApplyScript = "-- MaxScript executed when applying state set" --Assign the apply script. scriptedState.RevertScript = "-- MaxScript executed when reverting state set" --Assign the revert script. stateSet.CreateTemplate() --Create a template for this state set |
Deleting state set and first child |
masterState.RemoveChild stateSet --Removes the state set masterState.RemoveChild masterState.Children.Item[0] --Removes the first child |
Adding a compositor view |
masterState.CreateCompositingView true --Add compositor view with render elements masterState.CreateCompositingView false --Add compositor view without render elements |
Getting the nodes in the active compositor view |
cViewNodes = stateSets.CompositingViewNodes for i in 0 to (cViewNodes.Count - 1 ) do ( node = cViewNodes.Item(i) node.Collapsed = true print node.Tag.Name ) |
Rendering all state sets in the scene |
masterState.RenderAllStates() |
Getting access to objects state set |
objectStateSet = masterState.ObjectStateSet |
All properties and methods of all DotNet objects and classes implemented by the State Sets system are accessible to MAXScript using the DotNet inspector functions.
Exploring State Set Plugin Instance |
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin" dotNetObject:Autodesk.Max.StateSets.Plugin stateSets = stateSetsDotNetObject.Instance dotNetObject:Autodesk.Max.StateSets.Plugin showProperties stateSets .AbsentLayerStatesWereRemovedOnLoad : <System.Boolean> .ActiveViewId : <System.UInt16> .BitmapInfos : <System.Collections.Generic.Dictionary`2[System.Int32,Autodesk.Max.IBitmapInfo]>, read-only .ClassDescManager : <Autodesk.Max.StateSets.ClassDescManager>, read-only .CompositingView : <Ephere.Gui.NodeViews.NodeView>, read-only .CompositingViewNodes : <System.Collections.Generic.IList`1[Ephere.Gui.NodeViews.NodeView+Node]>, read-only .CompositorLink : <Autodesk.Max.StateSets.CompositorLink.CompositorLinkSettingsController>, read-only .CompositorLinkTargetViewId : <System.UInt16> .Configuration : <Autodesk.Max.StateSets.Configuration> .EntityManager : <Autodesk.Max.StateSets.Entities.EntityManager>, read-only .Global : <Autodesk.Max.IGlobal> .GlobalStringFormat : <System.Drawing.StringFormat>, read-only .HasRenderPreviewNode : <System.Boolean>, read-only .Instance : <Autodesk.Max.StateSets.Plugin>, static .InvokeRequired : <System.Boolean>, read-only .IsInSequencerMode : <System.Boolean> .IsMainFrameInitialized : <System.Boolean>, read-only .IsMainFrameVisible : <System.Boolean> .LoadedVersion : <System.Version> .MainFrameBounds : <System.Drawing.Rectangle> .NodeEvents : <Autodesk.Max.StateSets.Plugin+NodeEventCallback>, read-only .OpenViewCount : <System.Int32>, read-only .PluginWasRegistered : <System.Boolean> .PreviewRenderNode : <Autodesk.Max.IINode>, read-only .SequencerTreeView : <Ephere.Gui.NodeViews.NodeView>, read-only .Skin : <Ephere.Gui.NodeViews.Skin>, read-only .Sync : <System.ComponentModel.ISynchronizeInvoke> .ToolbarTreeView : <Ephere.Gui.NodeViews.NodeView>, read-only .TreeView : <Ephere.Gui.NodeViews.NodeView>, read-only .TreeViews : <Ephere.Gui.NodeViews.NodeView[]>, read-only .accumCallbacks : <System.Int32[]> true showMethods stateSets .<System.Int32>AccumCallbackCount <Autodesk.Max.StateSets.Plugin+AccumCallbackType>type .AccumCallbackIncrement <Autodesk.Max.StateSets.Plugin+AccumCallbackType>type .AccumCallbackIncrement <Autodesk.Max.StateSets.Plugin+AccumCallbackType>type <System.Int32>n .AccumCallbackReset <Autodesk.Max.StateSets.Plugin+AccumCallbackType>type -- Added in 3ds Max 2018: .<Ephere.Gui.NodeViews.NodeView>AddTreeView() .<System.IAsyncResult>BeginInvoke <System.Delegate>method <System.Object[]>args .Cleanup() .<T>CreateInstance() .<System.Runtime.Remoting.ObjRef>CreateObjRef <System.Type>requestedType .<System.Object>EndInvoke <System.IAsyncResult>result .<System.Boolean>Equals <System.Object>obj .[static]<System.Boolean>Equals <System.Object>objA <System.Object>objB .<System.Int32>GetHashCode() .<System.Object>GetLifetimeService() .<System.Type>GetType() .<System.Int32>GetUniqueBitmapInfoId() .HideMainFrame() .Initialize <Autodesk.Max.IGlobal>global <System.ComponentModel.ISynchronizeInvoke>sync .<System.Object>InitializeLifetimeService() .<System.Object>Invoke <System.Delegate>method <System.Object[]>args .<Autodesk.Max.IValue>LaunchBlank <Autodesk.Max.IValue[]>args .[static]Log <Autodesk.Max.StateSets.Plugin+LogType>logType <System.String>message .[static]Log <System.String>message <System.Boolean>newLine .LogLocal <Autodesk.Max.StateSets.Plugin+LogType>logType <System.String>message .PreviewRenderNodeReset() .[static]<System.Boolean>ReferenceEquals <System.Object>objA <System.Object>objB .RegisterAnchorCallbacks() .ReloadConfiguration() .ResetAndDelete() .ResetConfiguration() .ResetNodeEventCallbackMessages() .ShowMainFrame() .<Autodesk.Max.StateSets.Entities.StateSets.SetupRenderOutputs>ShowSetupRenderOutputsPanel() .ToggleMainFrame() .<System.String>ToString() .TriggerNodeEventCallbackMessages() .UnRegisterAnchorCallbacks()true true showEvents stateSets CameraSequencerModeChanged <System.Boolean>obj = ( ... ) CurrentLayerChanged <Autodesk.Max.IILayer>obj = ( ... ) CurrentStateSetChanged <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... ) ScenePostSave = ( ... ) StateApplied <Autodesk.Max.StateSets.Entities.StateSets.StateSet>arg1 <System.Boolean>arg2 = ( ... ) StateRecording <Autodesk.Max.StateSets.Entities.StateSets.StateSet>arg1 <System.Boolean>arg2 = ( ... ) StateSetAdded <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... ) StateSetChanged <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... ) StateSetRemoved <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... ) StateSetRenamed <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... ) TimeChange <System.Int32>obj = ( ... ) TimeRangeChanged = ( ... ) true |
Exploring MasterStateSet |
showProperties stateSets.EntityManager .RootEntity : <Autodesk.Max.StateSets.Entities.Root> true showProperties stateSets.EntityManager.RootEntity .AutomaticName : <System.String> .AutomaticTypeName : <System.String> .Children : <System.Collections.Generic.List`1[Autodesk.Max.StateSets.Entities.Entity]> .CustomAttributes : <System.Collections.Hashtable>, read-only .CustomChildren : <System.Collections.Generic.List`1[Autodesk.Max.StateSets.Entities.Entity]> .Description : <System.String> .DynamicInsertTarget : <System.Boolean> .HierarchyIndex : <System.Int32>, read-only .InternalName : <System.String>, read-only .MasterStateSet : <Autodesk.Max.StateSets.Entities.StateSets.Master>, read-only .Name : <System.String> .Parents : <Autodesk.Max.StateSets.Entities.Entity[]>, read-only .TypeName : <System.String> .UseNameForTypeName : <System.Boolean>, read-only .CustomChildrenToken : <System.String>, read-only, static true showProperties stateSets.EntityManager.RootEntity.MasterStateSet .AutomaticName : <System.String>, read-only .AutomaticTypeName : <System.String> .Children : <System.Collections.Generic.List`1[Autodesk.Max.StateSets.Entities.Entity]> .CompositorLinkFilePath : <System.String> .CurrentState : <Autodesk.Max.StateSets.Entities.StateSets.StateSet[]> .CustomAttributes : <System.Collections.Hashtable>, read-only .CustomChildren : <System.Collections.Generic.List`1[Autodesk.Max.StateSets.Entities.Entity]> .DefaultRenderOutputFilePattern : <System.String>, read-only, static .DescendantStateCount : <System.Int32>, read-only .Description : <System.String>, read-only .DynamicInsertTarget : <System.Boolean> .HierarchyIndex : <System.Int32>, read-only .InternalName : <System.String>, read-only .Name : <System.String> .ObjectStateSet : <Autodesk.Max.StateSets.Entities.StateSets.StateSet>, read-only .Parents : <Autodesk.Max.StateSets.Entities.Entity[]>, read-only .RenderOutputFilePattern : <System.String> .StatesWithErrors : <System.Collections.Generic.ICollection`1[Autodesk.Max.StateSets.Entities.StateSets.IState]>, read-only .TypeName : <System.String> .UseNameForTypeName : <System.Boolean>, read-only .CustomChildrenToken : <System.String>, read-only, static .StateNameToken : <System.String>, read-only, static true showMethods stateSets.EntityManager.RootEntity.MasterStateSet .<Autodesk.Max.StateSets.Entities.Entity>AddChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>wasAutoGenerated .<Autodesk.Max.StateSets.Entities.Entity>AddChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>wasAutoGenerated <System.Boolean>broadcastEvent .AddObjectState() .AddObjectState <System.Nullable`1[[System.UInt16, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>targetViewId .<Autodesk.Max.StateSets.Entities.StateSets.StateSet>AddState() .<Autodesk.Max.StateSets.Entities.StateSets.StateSet>AddState <System.Nullable`1[[System.UInt16, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>targetViewId <System.Boolean>addToCompositorView .AssignUniqueName <Autodesk.Max.StateSets.Entities.Entity>state <System.String>baseName .BeginRecordingStateSet <Autodesk.Max.StateSets.Entities.StateSets.StateSet>stateSet <Autodesk.Max.StateSets.Entities.StateSets.StateSet[]>path .CheckForStateErrors() .CollectDescendantStateSets <System.Collections.Generic.List`1[[Autodesk.Max.StateSets.Entities.StateSets.StateSet, Autodesk.Max.StateSets, Version=20.0.966.0, Culture=neutral, PublicKeyToken=null]]>destination .CollectDescendantsWithCustomAttribute <System.Object>customAttribute <System.Collections.Generic.List`1[[Autodesk.Max.StateSets.Entities.Entity, Autodesk.Max.StateSets, Version=20.0.966.0, Culture=neutral, PublicKeyToken=null]]>destination .CreateCompositingView <System.Boolean>includeRenderElements .<System.Runtime.Remoting.ObjRef>CreateObjRef <System.Type>requestedType .<Autodesk.Max.StateSets.Entities.StateSets.IParameter>CreateUserCreatableParameter <System.String>name .DefaultSetup() .Dispose() .<System.Boolean>Equals <System.Object>obj .[static]<System.Boolean>Equals <System.Object>objA <System.Object>objB .GenerateChildrenForTarget <Autodesk.Max.StateSets.Entities.Entity>target .<Autodesk.Max.StateSets.Entities.Entity>GetChild <System.String>name .<T>GetCustomAttribute <System.Object>key <T>defaultValue .<System.Boolean>GetCustomAttributeBoolean <System.Object>key .<Autodesk.Max.StateSets.Entities.Entity>GetDescendant <System.String>name .<Autodesk.Max.StateSets.Entities.Entity>GetDescendant <System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>hierarchyIndex .<System.Collections.Generic.IEnumerable`1[Autodesk.Max.StateSets.Entities.Entity]>GetDescendants() .<System.Int32>GetDescendantStateSetIndex <System.Collections.Generic.IEnumerable`1[[Autodesk.Max.StateSets.Entities.StateSets.StateSet, Autodesk.Max.StateSets, Version=20.0.966.0, Culture=neutral, PublicKeyToken=null]]>stateSetPath .<System.Collections.Generic.List`1[Autodesk.Max.StateSets.Entities.StateSets.StateSet[]]>GetDescendantStateSetPaths <System.Boolean>includeObjectStateSet .<System.Int32>GetHashCode() .<System.Collections.Generic.List`1[System.String]>GetHierarchyIndex <Autodesk.Max.StateSets.Entities.Entity>descendant .<System.Object>GetLifetimeService() .GetObjectData <System.Runtime.Serialization.SerializationInfo>info <System.Runtime.Serialization.StreamingContext>context .<Autodesk.Max.StateSets.Entities.StateSets.StateSet>GetStateById <System.Int32>id .<System.Type>GetType() .<System.String[]>GetUserCreatableParameterNames() .<System.Boolean>HasCustomAttribute <System.Object>key .<System.Boolean>HasDescendant <Autodesk.Max.StateSets.Entities.Entity>descendant <System.Collections.Generic.HashSet`1[[Autodesk.Max.StateSets.Entities.Entity, Autodesk.Max.StateSets, Version=20.0.966.0, Culture=neutral, PublicKeyToken=null]]>ignoreParents .<System.Boolean>HasDescendant <Autodesk.Max.StateSets.Entities.Entity>descendant <Autodesk.Max.StateSets.Entities.Entity[]>ignoreParents .<System.Object>InitializeLifetimeService() .<Autodesk.Max.StateSets.Entities.Entity>InsertChild <System.Int32>index <Autodesk.Max.StateSets.Entities.Entity>entity .<Autodesk.Max.StateSets.Entities.Entity>InsertChild <System.Int32>index <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>wasAutoGenerated <System.Boolean>broadcastEvent .InvalidateChildren() .<System.Boolean>IsDescendantOf <Autodesk.Max.StateSets.Entities.Entity>ancestor .[static]maxnrAssignStateSetJob <System.Int32[]>stateSetsHandles <System.Int32>numHandles .<System.Boolean>OnCreateChildForIndex <System.String>index <Autodesk.Max.IRepresentation>target .[static]<System.Boolean>ReferenceEquals <System.Object>objA <System.Object>objB .Refresh() .RemoveChild <Autodesk.Max.StateSets.Entities.Entity>entity .RemoveChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>entityChange .RemoveChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>entityChange <System.Boolean>broadcastEvent .RemoveCustomAttribute <System.Object>key .<System.Boolean>Rename <System.String>newName .RenderAllStates <System.Boolean>forceNetworkRender .RenderStates <System.Collections.Generic.IEnumerable`1[[System.Collections.Generic.IEnumerable`1[[Autodesk.Max.StateSets.Entities.StateSets.StateSet, Autodesk.Max.StateSets, Version=20.0.966.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>stateSetPaths <System.Boolean>useNetworkRender .Reset() .ResetCompositingView <System.Boolean>includeRenderElements .SetCurrentStateSet <Autodesk.Max.StateSets.Entities.StateSets.StateSet[]>path .SetCustomAttribute <System.Object>key <T>value .SetCustomAttributeBoolean <System.Object>key <System.Boolean>value .SetupRenderOutputsPath <System.String>value .<System.String>ToString() .UpdateHierarchyParents() true |