Notifications
Clear all

[Closed] how to get value back from maxscript function called in SDK?

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; 
}

  


1 Reply

you can use

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