Some Softimage functions return both output arguments and return values. If the function has a return value explicitly defined, you cannot extract any output arguments via the ISIVTCollection because the function is returning an a specific value instead.
You can check the Return Value section in the Commands and Scripting Reference to see whether it uses an explicit return value and what that value is.
In these cases, VBScript must pass output parameters in order to retrieve the information via output arguments but for JScript, and Python, other strategies must be considered.
In most cases, there are special versions of those functions that use output arguments and return values. These functions generally have the same name as the output argument versions, but with '2' appended to the name. For example, the NurbsSurface.GetTrim function allows output arguments (see VBScript Example: Getting Output Arguments from a Method), but the NurbsSurface.GetTrim2 function returns an array of output values (JScript Example: Using the Method Ô2' Workaround).
If there is no alternate (compliant) version of the function, your only option for a workaround is to create a VBScript custom command to call the non-compliant command and return an array containing both the output arguments and return value.
Note that this snippet contains the Execute callback for the custom command. See Example: Custom Command Workaround for Both Output Arguments and Return Values for the full implementation of this plug-in.
' Execute callback for the custom command function MyGetSkeleton_Execute( InputObj ) ' Call the GetSkeleton command and pack the output ' argument and the return value in an array set oSkel = GetSkeleton( InputObj, lIndex ) aReturn = Array( lIndex, oSkel ) ' Return the array MyGetSkeleton_Execute = aReturn end function
' Execute callback for the custom command function MyGetSkeleton_Execute( InputObj ) ' Call the GetSkeleton command and pack the output ' argument and the return value in an array set oSkel = GetSkeleton( InputObj, lIndex ) aReturn = Array( lIndex, oSkel ) ' Return the array MyGetSkeleton_Execute = aReturn end function
NewScene( null, false ); Create2DSkeleton( -3.004, 2.152, 0.000, -1.531, -1.163, 0.000, 0.000, 0.000, 1.000, 1 ); AppendBone( "eff", 0.853, 1.396, 0.000 ); AppendBone( "eff", 2.578, -1.532, 0.000 ); // Returns a VBArray, which must be converted to a JS Array var RtnArray = MyGetSkeleton( "bone1" ).toArray(); // The output argument is the first item (a Long) var MyObjIndex = RtnArray[0]; LogMessage( "Index of objects in skeleton: " + MyObjIndex ); // The return value is the second item (XSICollection) var MySkeleton = RtnArray[1]; for ( i=0; i<MySkeleton.Count; i++ ) { LogMessage( "Item[" + i + "] = " + MySkeleton(i) ); } // So both are available now in JScript // INFO : Index of objects in skeleton: 2 // INFO : Item[0] = root // INFO : Item[1] = bone // INFO : Item[2] = bone1 // INFO : Item[3] = bone2 // INFO : Item[4] = eff
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License