[Closed] State Sets – Activate a state with Maxscript
Hi all,
I would greatly appreciate some advice – I’m trying to use the fantastic “LPM” Render pass manager alongside state sets.
All I want to do is activate a particular state with a maxscript.
I have referred to this document in the 3ds Max help:
http://help.autodesk.com/view/3DSMAX/2016/ENU//?guid=__files_GUID_A2F530D0_628D_48DA_A126_6752A525E1FF_htm
And tried to put together this script:
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin" --Get StateSets dotNet object.
stateSets = stateSetsDotNetObject.Instance --Get the state sets instance from the dotNet object.
masterState = stateSets.EntityManager.RootEntity.MasterStateSet --Get Access to master state.
masterState.CurrentState = #(testStateSet) --Assign current state set.
Every time I activate a certain pass in LPM, I want the above script to run, and a certain state ‘testStateSet’ to become the active state (green arrow lit up).
If anyone could provide any advice or assistance it would be much appreciated!
Just wanted to follow up, I ended up getting in contact with Sergey Nezhentsev, the creator of LPM 2.0 and he setup an example scene for me.
If anyone is interested in the future, this is the code he used:
Pre-render script (To activate a state)
needStateNumber = 0
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin"
stateSets = stateSetsDotNetObject.Instance
masterState = stateSets.EntityManager.RootEntity.MasterStateSet
needState = masterState.Children.Item[needStateNumber]
masterState.CurrentState = #(needState)
print masterState.Children.Item[needStateNumber].Name
Post-render script (De-activate current state)
stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin"
stateSets = stateSetsDotNetObject.Instance
masterState = stateSets.EntityManager.RootEntity.MasterStateSet
masterState.CurrentState = undefined
The above would activate/de-activate the top-most state – the state at the top of the list.
To activate the 3rd state down in the list, you would change needStateNumber to ‘2’ instead of ‘0’. Note that this is ‘activating’ a state. Not recording (which is great).
Big thanks to Sergey for the help, I have hardly any scripting knowledge and for me this was very tough.
Has anyone used LPM 2.0 much? LPM 2 website
I’m just getting into it now and it is fantastic. Together with State Sets, it’s very powerful.
StateSets support for original LPM will already done with StateSets operator which was included in original update of LPM https://github.com/LPassManager/LPM_3DS_MAX
p.s. LPM 2.0 it is a fork of original LPM and Sergey rejected join to original team of LPM and promised rename his fork of LPM so as not to mislead with original version.
Thanks Mike – Well there you go – I actually was confused. The last I saw of LPM on scriptspot was 3 years ago and so I did think that Sergey’s ‘LPM’ 2 was the new continuation of LPM, not a fork. Thanks for letting me know.
I think Sergey’s LPM 2 is great but I will now check out the main fork of LPM too.