Validate value of property

Hello everyone.
My task is to find out valid integer range of some property. For example some material has an integer property and I need to know which values are valid for this property. The problem is that if I set invalid value (for example valid range is 0-2 and I set it to 3) then 3dsMax can even crash.

One man told me that I can get ParamBlockDesc2 from paramblock, with GetDesc(), then call GetParamDef, and it has max/min values. But it's for C++.

Can this be achieved in maxscript anyway?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

Sure. Google ParamDef Struct Reference (in c++ sdk reference) for more info on param checking

myMaterialName = "jah"
 
g = (dotNetClass "Autodesk.Max.GlobalInterface").instance
mtlName = dotNetObject "system.string" myMaterialName asdotnetobject:true
mtl = g.COREInterface7.FindMtlNameInScene mtlName
 
if mtl != undefined do (
 
	for i=0 to mtl.NumParamBlocks-1 do (
 
		pb = mtl.GetParamBlock i
		numParameters = pb.NumParams
 
		format "------- Paramblock % ---------\n" i
		for j=0 to numParameters-1 do (
 
			paramDef = pb.getParamDef j
			format "Parameter: %\nRange: min:%  max:%\n\n" paramDef.IntName paramDef.rangeLow.F paramDef.rangeHigh.F
 
		)
 
	)
 
)
NiK684's picture

One more question. How to get

One more question.
How to get classof ParamDef value? I need to know is it float or integer because then I need to get "paramDef.rangeLow.F" or "paramDef.rangeLow.I".
I know how to get class of maxscript value, but not dotnet value.

jahman's picture

.

Do you know a way to determine if a paramdef is of spinner type? I tried without any luck.

Here's the SpinType enum.
You can simply use paramdef.SpinType == paramdef.SpinType.float to determine the type

show paramdef.SpinType
  .Float : <Autodesk.Max.EditSpinnerType>, read-only, static
  .Int : <Autodesk.Max.EditSpinnerType>, read-only, static
  .PosFloat : <Autodesk.Max.EditSpinnerType>, read-only, static
  .PosInt : <Autodesk.Max.EditSpinnerType>, read-only, static
  .PosUniverse : <Autodesk.Max.EditSpinnerType>, read-only, static
  .Time : <Autodesk.Max.EditSpinnerType>, read-only, static
  .Universe : <Autodesk.Max.EditSpinnerType>, read-only, static
  .value__ : <System.Int32>
NiK684's picture

Thx again :)

Thx again :)

NiK684's picture

Thanks a lot

Thanks a lot

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.