PDA

View Full Version : how to get value back from maxscript function called in SDK?


nathan7
03-06-2008, 04:03 AM
how to get value back from maxscript function called in SDK?

in the following code, we can evaluate a string in SDK, and the line

vl.result->print();

will print the result in listener

how can i get the result in SDK? for example
script: m = 5
result: 5

how can i get the value 5? the Value class is very complexed and i have no idea how it's organized,

thanks for helping!


BOOL Co3dsMax::MAXScriptEvaluate(Interface* ip, char* command)
{
BOOL result=TRUE;
init_thread_locals();

four_typed_value_locals(Parser* parser,
Value* code,
Value* result,
StringStream* source);

vl.parser = new Parser (thread_local(current_stdout));
vl.source = new StringStream (command);
vl.source->log_to(thread_local(current_stdout));

save_current_frames();
try
{
ip->RedrawViews(ip->GetTime(),REDRAW_BEGIN);
vl.source->flush_whitespace();
vl.code = vl.parser->compile_all(vl.source);
vl.result = vl.code->eval();
vl.result->print();
//vl.result->prin1();// no use
CharStream * cs = thread_local(current_stdout);


vl.source->flush_whitespace();
vl.source->close();

ip->RedrawViews(ip->GetTime(),REDRAW_END);
}
catch (...)
{
restore_current_frames();
result=FALSE;
vl.source->close();
}

pop_value_locals();
return result;
}

xenry
03-07-2008, 06:32 AM
you can use

int myVar = vl.result->to_int();

CGTalk Moderation
03-07-2008, 06:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.