Description
For custom operators, this callback is fired when an instance of the operator is instantiated. Unlike Define, Init is called both for newly created operators and for operators loaded from a file.
User data can be stored in the operator context of the Init callback and then retrieved later in the Update and Term callbacks. Data can be stored as simple numerical or strings values as well as COM or C++ objects.
![]()
|
While you can also initialize cached operator data the first time update is called, it is strongly suggested to perform data initialization in Init. |
Applies To
Syntax
// C#
public class <operator_name>
{
public bool Init( Context in_ctxt )
{
...
}
}
// C++ CStatus <operator_name>_Init( CRef& in_context ) { ... } // JScript function <operator_name>_Init( in_context ) { ... } # Python def <operator_name>_Init( in_context ): ... ' VBScript Function <operator_name>_Init( in_context ) ... End Function # PerlScript sub <operator_name>_Init { my $in_context = shift; }
<operator_name> is the name specified in the call to PluginRegistrar.RegisterOperator, with any spaces removed.
Parameters
|
Parameter |
Language |
Type |
Description |
|
in_context |
Scripting and C# |
Context.Source returns the CustomOperator. |
|
|
C++ |
CRef & |
A reference to the Context object. Context::GetSource returns the CustomOperator . |
Examples
C++ Example (Basic)
// C++
XSIPLUGINCALLBACK CStatus CppOp_Init( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
CustomOperator op( ctxt.GetSource() );
CString strOpNameAsUserData = op.GetUniqueName();
ctxt.PutUserData( strOpNameAsUserData ) ;
return CStatus::OK ;
}C++ Example (Object User Data)
class CData
{
LONG data;
};
XSIPLUGINCALLBACK CStatus CppOp_Init( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
CData* p = new CData;
p->data = 123;
CValue val = (CValue::siPtrType) p;
ctxt.PutUserData( val ) ;
return CStatus::OK ;
}
// Time to release memory
XSIPLUGINCALLBACK CStatus CppOp_Term( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
CValue val = in_ctxt.GetUserData();
CData* p = (CData*)(CValue::siPtrType)val;
delete p;
return CStatus::OK ;
}See Also
• Define
• Update
Autodesk Softimage v7.5