v2.0
Converts a preset-based scripted operator into a
runtime-designed scripted operator. The difference between a
preset-based and runtime-designed operator are as follows:
Runtime-based scripted operators are saved as part of the scene.
Preset-based plug-in operators, either compiled or scripted, are
saved as references and have an associated preset file (.preset
file extension) and spdl file (.spdl file extension).
You cannot load a scene that has references to the preset-based
scripted operator if you do not have the plug-in operator installed
on your system. To determine which scripted operators are installed
you can use the 'xsi -l' command line option or view the list of
installed scripted operators in the add-on packaging dialog.
Note: The Self-Installed Custom Operator (SICO) is the preferred
way to implement custom operators in Softimage; however, this
command cannot convert SICOs to runtime operators.
oReturn = ConvertScriptedOp( [Source] ); |
Returns an Operator that contains a runtime-designed version of the preset-based scripted operator
Parameter | Type | Description |
---|---|---|
Source | Operator | The preset-based scripted operator
Default Value: Currently selected preset-based scripted operator |
/* This example demonstrates how to use the ConvertScriptedOp command to generate a legacy runtime operator from a preset-based operator definition. Since the preferred implementation for custom operators is now Self-Installing Custom Operator, this example first creates a legacy runtime operator, and then writes it to a spdl file and registers the new spdl file so that we have a preset-based legacy operator to use. Once a preset-based legacy operator has been saved to disk and registered in Softimage, this example creates a new scene and runs the ConvertScriptedOp command to create a new runtime version of the preset-based operator. */ // --------------------------------------------------- // SET UP A PRESET-BASED OPERATOR // // Create scene and apply operator NewScene( null, false ); GetPrim( "null" ); // Create and apply the operator to the null's posx var str = DemoSpdlFile_Update.toString(); var op = AddScriptedOp( "null.kine.local.posx", str, null, "DemoSpdlFile" ); // Create a preset from it spdlpath = XSIUtils.BuildPath( Application.InstallationPath(siUserPath), "Application", "spdl" ); var fso = XSIFactory.CreateActiveXObject( "Scripting.FileSystemObject" ); if ( !fso.FolderExists(spdlpath) ) { // Create the directory if it doesn't exist fso.CreateFolder(spdlpath); } spdlpath = XSIUtils.BuildPath( spdlpath, "DemoSpdlFile.spdl" ); CreateDemoSpdlFileOnDisk( spdlpath ); XSIUtils.RegisterSPDL( spdlpath, true ); // --------------------------------------------------- // RUN THE CONVERTSCRIPTEDOP COMMAND // // Now run the ConvertScriptedOp command in a new scene NewScene( null, false ); var myNull = GetPrim( "null" ); var myPresetBasedOp = ApplyOp( "DemoSpdlFile", myNull )(0); var myRuntimeDesignedOp = ConvertScriptedOp( myPresetBasedOp ); // --------------------------------------------------- // HELPER FUNCTION // // Update function function DemoSpdlFile_Update( ctx, out ) { Application.LogMessage( "DemoSpdlFile::Update()" ); out.Value = 2; } // Create SPDL file function CreateDemoSpdlFileOnDisk( in_path ) { // Set up text to write to spdl file var spdltext = "SPDL\nVersion = \"2.0.0.2\";\nReference = \"{CE89DBEF-EA05-4378-B507-4A6718" + "25641F}\";\nName = \"DemoSpdlFile\";\n\nPropertySet \"DemoSpdlFile_Params\"\n{\n" + "\tParameter \"DemoSpdlFile\"\n\t{\n\t\tName\t= \"DemoSpdlFile\";\n\t\tGuid\t= \"" + "{CE89DBEF-EA05-4378-B507-4A671825641F}\";\n\t\tCaps\t= Persistable;\n\t\tType\t=" + " VT_EMPTY;\n\t}\n\n}\n\n\nLayout \"Default\"\n{\n}\nPortSet \"DemoSpdlFile_Ports" + "\"\n{\n\tGroup \"Group_0\"\n\t{\n\t\tOrigin = Select;\n\t\tPickMessage = \"Group" + "_0\";\n\n\t\tOutput \"Outposx\"\n\t\t{\n\t\t\tMajor = {9E04FCEE-10F3-11D0-943A-0" + "0AA006D3165};\n\t\t\tMinor = {4125B131-86EF-11D1-B1AB-0800360BFF02};\n\t\t\tComp" + "onent = {06294283-B94B-11D2-B87F-00A0C92469BE};\n\t\t\tAttributes = 0x00009001;\n" + "\t\t}\n\t}\n}\n\nPlugin = Scripted\n{\n\tLanguage = \"JScript\";\n\n\tUpdate =\n" + "\tBeginScript\n\tDemoSpdlFile_Update(In_UpdateContext, Out);\n\n\tEndScript\n\n" + "\tHelpers =\n\tBeginScript\nfunction DemoSpdlFile_Update( ctx, out ) \n{ \n Ap" + "plication.LogMessage( \"DemoSpdlFile::Update()\" );\n out.Value = 2;\n}\n\tEnd" + "Script\n}"; // Create a spdl file on disk var fso = new ActiveXObject( "Scripting.FileSystemObject" ); var ts = fso.CreateTextFile( in_path ); ts.Write( spdltext ); ts.Close(); } |