ScriptSpot

Forum topic · Scripts Wanted

MAXScript and State Sets

By Lantsov · 2013-06-10

Description

Hi.

I need some help in working with MAXScript State Sets.
I have read page http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=fil…. But I could not find the answers to two questions.

1. How to find out the name of the State Set which the script is executed?
2. How to programmatically create a State Set the template?

I need to write a generic script that will change the names of files in the external render, depending on the names of State Set, which give a command to render.

For example this:

vr = renderers.current
sName = stateSet.Name
FullPathRAW = "D:/_"+ sName + ".exr"
FullPathCNL = "D:/_"+ sName + ".tif"
vr.output_rawFileName = FullPathRAW
vr.output_splitfilename = FullPathCNL
/* render outputwidth:640 outputheight:480 outputfile:("D:/test.png") vfb:on */

Comments (7)

Lantsov · 2013-06-10

On the first question I found a solution:

vr = renderers.current

stateSetsDotNetObject = dotNetObject "Autodesk.Max.StateSets.Plugin"
stateSets = stateSetsDotNetObject.Instance
masterState = stateSets.EntityManager.RootEntity.MasterStateSet
sName = masterState.CurrentState[1].Name as String

FullPathRAW = "D:/"+ sName + ".exr"
FullPathCNL = "D:/"+ sName + "_channel.tif"
vr.output_rawFileName = FullPathRAW
vr.output_splitfilename = FullPathCNL

The question remains 2.

Lantsov · 2013-06-10

Yes, I've read.
But I could not find there the answers to these questions.
By the way, the version that I have described, is only at the top level.
For Sub-State must change the index of the array.

barigazy · 2013-06-10

What about this

stateCount = masterState.Children.count
--create template for the first item ei. stateset
masterState.Children.item[0].CreateTemplate()

Lantsov · 2013-06-11

I do not speak English.
Maybe I did not put the question correctly. I do not want to create a template. How to do it I found.
I want to create a State Set using an already created template.

Lantsov · 2013-06-10

Thanks for the link. I will read.
But I am looking for information on State Sets, and not on the Scene State.