Problem returning value from Maxscript command

 
 
 
Posted by:duke
Data created:23 May 2011

I'm trying to use "material.classes" and return that value as a string, but I can't work out how. I used the documentation to send the command off:

public static IValue MaxScriptExecute(IGlobal global, string str)
        {
            var result = false;
            
            return global.ExecuteScript(global.StringStream.Create(str), result);
        }

 

...but casting the returned value .ToString_ crashes max.

 

Can you catch your call into a try{} catch{} block? If it throws a SEH Exception you're probably trying to cast IValue to a string when it isn't a string. Make sure that material.classes isn't undefined before doing this. I usually would call

if( MaxScriptExecute( "material.classes != undefined" ).ToBool )
{
// ...
}

To make sure I'm getting the value I'm expecting

Marsel Khadiyev (Software Developer, EPHERE Inc.)