[Closed] Return StateSet Name using C#
Hey guys,
When I’m using maxscript, to return the name of the pass from State Sets I usually use this code:
GetStateSets_Names=#()
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin"
stateSets = stateSetsDotNetObject.Instance
masterState = stateSets.EntityManager.RootEntity.MasterStateSet
for i = 1 to masterState.Children.Count do
(
PushStateSet = masterState.Children.Item[(i-1)]
append GetStateSets_Names PushStateSet.name
)
This script return an Array containing all the names of my render passes from State Sets.
Ok, my question is: How can i use this particular code using C#?
masterState.Children.Item[(i-1)]
I am using Visual Studio 2010, also I added the dll references from 3ds max: Autodesk.Max.dll and Autodesk.Max.StateSets.dll
basically I using this code in VS:
var stateSetsObject = Autodesk.Max.StateSets.Plugin.Instance;
var masterState = stateSetsObject.EntityManager.RootEntity.MasterStateSet;
stateView.BeginUpdate();
stateView.Items.Clear();
for (int i = 1; i <= masterState.Children.Count; i++)
{
ListViewItem row = new ListViewItem((i-1).ToString());
stateView.Items.Add(row);
}
stateView.EndUpdate();
stateView.Refresh();
What this code does is add to a listview (called stateView) all my state sets, this code returns only the state set ID, that’s fine and works great, but what I want is return the name of the pass by state set ID, but the dll has no “.Children.Item” definition.
can anyone help me, please?
yes Denis.
I’m trying to figure out how can I do a loop to get the childrens name from masterStateSet using C#.
Just guessing but:
masterStateSet.Children must be an Array or List. So you are accessing it by an index,
something like:
masterStateSet.Children[i].whateverproperty
one more question.
what about set the currentState via C#?
in maxscript i use:
masterState.CurrentState = #(masterState.Children.Item[x])
but in c# I can’t use:
masterState.CurrentState = masterState.Children[x]
someone know how can I use .CurrentState in C#?