ステート セット MAXScript アクセス

ステート セットのレンダリング パス管理システムは、3ds Max 2012 に対する Subscription Advantage Pack 拡張機能で初めて導入され、現在、3ds Max 2013 以降では欠かせない機能となっています。

この機能は、DotNet オブジェクト、およびそのプロパティとメソッドを介して、MAXScript に公開されます。

   

次の例は、ステート セットへのアクセスおよび操作に関係する基本的な手順を示しています。

ステート セットへのアクセス

stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin" --Get StateSets dotNet object. 
stateSets = stateSetsDotNetObject.Instance --Get the state sets instance from the dotNet object. 

ステート セット ウィンドウを開く/閉じる

stateSets.ShowMainFrame() --Open the State Sets window. 
stateSets.HideMainFrame() --Close the State Sets window. 

マスター ステートへのアクセス

masterState = stateSets.EntityManager.RootEntity.MasterStateSet

新規ステート セットの追加と名前変更

stateSet = masterState.AddState()
stateSet.Name = "MyStateSet"
masterState.AssignUniqueName stateSet "MyMasterStateset" --Assigns a unique name to the state set 

現在のステート セットの変更、記録の開始と終了

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. 

子サブステート セットの追加とレンダリング、および他の操作の実行

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  

ステート セットと最初の子の削除

masterState.RemoveChild stateSet --Removes the state set 
masterState.RemoveChild masterState.Children.Item[0] --Removes the first child

コンポジタ ビューの追加

masterState.CreateCompositingView true --Add compositor view with render elements
masterState.CreateCompositingView false --Add compositor view without render elements

シーン内のすべてのステート セットのレンダリング

masterState.RenderAllStates()

オブジェクトのステート セットへのアクセス

objectStateSet = masterState.ObjectStateSet

   

ステート セット システムによって実装されたすべての DotNet オブジェクトとクラスのすべてのプロパティおよびメソッドには、DotNet 検査関数を使用して MAXScript からアクセス可能です。

ステート セット プラグイン インスタンスの探索

stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin"
dotNetObject:Autodesk.Max.StateSets.Plugin

stateSets = stateSetsDotNetObject.Instance
dotNetObject:Autodesk.Max.StateSets.Plugin

showProperties stateSets
  .AbsentLayerStatesWereRemovedOnLoad : <System.Boolean>
  .BitmapInfos : <System.Collections.Generic.Dictionary`2[System.Int32,Autodesk.Max.IBitmapInfo]>
  .ClassDescManager : <Autodesk.Max.StateSets.ClassDescManager>, read-only
  .CompositingViewNodes : <System.Collections.Generic.IList`1[Ephere.Gui.NodeViews.NodeView+Node]>, read-only
  .CompositorLink : <Autodesk.Max.StateSets.CompositorLink.CompositorLinkSettingsController>, read-only
  .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
  .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
  .Skin : <Ephere.Gui.NodeViews.Skin>
  .Sync : <System.ComponentModel.ISynchronizeInvoke>
  .TreeView : <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
  .<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

showEvents stateSets
   CurrentLayerChanged <Autodesk.Max.IILayer>obj = ( ... )
   CurrentStateSetChanged <Autodesk.Max.StateSets.Entities.StateSets.StateSet>obj = ( ... )
   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 = ( ... )
true

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]>
  .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
true

showMethods stateSets.EntityManager.RootEntity.MasterStateSet
  .<Autodesk.Max.StateSets.Entities.Entity>AddChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>autoGenerated
  .<Autodesk.Max.StateSets.Entities.Entity>AddChild <Autodesk.Max.StateSets.Entities.Entity>entity <System.Boolean>autoGenerated <System.Boolean>broadcastEvent
  .AddObjectState()
  .<Autodesk.Max.StateSets.Entities.StateSets.StateSet>AddState()
  .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=17.2.259.0, Culture=neutral, PublicKeyToken=null]]>destination
  .CollectDescendantsWithCustomAttribute <System.Object>customAttribute <System.Collections.Generic.List`1[[Autodesk.Max.StateSets.Entities.Entity, Autodesk.Max.StateSets, Version=17.2.259.0, Culture=neutral, PublicKeyToken=null]]>destination
  .CreateCompositingView <System.Boolean>includeRenderElements
  .<System.Runtime.Remoting.ObjRef>CreateObjRef <System.Type>requestedType
  .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.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]>hierarchyIndex
  .<Autodesk.Max.StateSets.Entities.Entity>GetDescendant <System.String>name
  .<System.Int32>GetDescendantStateSetIndex <System.Collections.Generic.IEnumerable`1[[Autodesk.Max.StateSets.Entities.StateSets.StateSet, Autodesk.Max.StateSets, Version=17.2.259.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.Boolean>HasCustomAttribute <System.Object>key
  .<System.Boolean>HasDescendant <Autodesk.Max.StateSets.Entities.Entity>descendant <Autodesk.Max.StateSets.Entities.Entity[]>ignoreParents
  .<System.Boolean>HasDescendant <Autodesk.Max.StateSets.Entities.Entity>descendant <System.Collections.Generic.HashSet`1[[Autodesk.Max.StateSets.Entities.Entity, Autodesk.Max.StateSets, Version=17.2.259.0, Culture=neutral, PublicKeyToken=null]]>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>autoGenerated <System.Boolean>broadcastEvent
  .InvalidateChildren()
  .<System.Boolean>IsDescendantOf <Autodesk.Max.StateSets.Entities.Entity>ancestor
  .<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
  .Reset()
  .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