XSIApplication.ExecuteScriptCommand
 
 
 

XSIApplication.ExecuteScriptCommand

Description

Executes a Softimage Command. This method can be used to execute any built-in or custom command. The name of the method is misleading, because compiled custom commands can also be executed via this method. For this reason the equivalent method in the C++ API has been renamed to Application::ExecuteCommand.

Typically this method is not necessary from scripting because Softimage commands can be invoked directly. So the main purpose of this method is to enable C++ applications written with COM to be able to call Softimage commands. With the advent of the C++ API it is rarely necessary to use this method.

This method, in scripting, can only return arguments via the return value. In C++ the arguments are supplied to the command via a variant containing a SafeArray. Output arguments must be passed by reference; this is done by setting the variant's argument type to VT_VARIANT | VT_BYREF.

C# Syntax

Object XSIApplication.ExecuteScriptCommand( String in_bzScriptName, Object in_vsa );

Scripting Syntax

oVariant = XSIApplication.ExecuteScriptCommand( Name, [Arguments] );

Return Value

Variant (return value from script command)

Parameters

Parameter Type Description
Name String Command's script name
Arguments Array of Variants Array of all required script command arguments, including output arguments passed by reference. In C++ the argument is implemented as a variant containing a SafeArray of variants.

Examples

1. VBScript Example

'
'       This example illustrates how to create a image clip and inspect it using
'       a modal property page.
'
Dim clip, args
args = Array(Application.InstallationPath( siFactoryPath ) & "\Data\XSI_SAMPLES\Pictures\A_Green_Suit.JPG")
set clip = ExecuteScriptCommand( "CreateImageClip", args )
On Error Resume Next
ExecuteScriptCommand "InspectObj", Array( clip,,,siModal)
if Err.Number = siErrCancelled then
        Application.LogMessage "command cancelled"
end if
On Error Goto 0

2. VBScript Example

'
'       This example shows different ways to
'       call a Softimage command from vbscript
'
' Normal method.  This method will not work
' on Netview
GetPrim "Null"
' This method will not work on Netview
' (because there is no global Application object)
Application.GetPrim "Null"
' This is the method that works in a Netview
' script.  The oXsi object can be cached.
set oXsi = CreateObject( "XSI.Application" )
set oXsi = oXsi.Application
oXsi.GetPrim "Null"
' Because of the convenience of the previous methods,
' this mechanism is not recommended from vbscript.
' it is most useful for COM C++ plug-ins
Application.ExecuteScriptCommand "GetPrim", Array( "Null" )

3. Python Example

#
# Python Example
#
args = ["Cone","MeshSurface","",""]
retval = Application.ExecuteScriptCommand( "CreatePrim", args )
args = [retval,"","", 4]        # siModal=4
try:
        Application.ExecuteScriptCommand( "InspectObj", args )
except:
        Application.LogMessage("command cancelled")

4. JScript Example

/*
        JScript Example
*/
var obj,i=0;
var aArgs1 = new Array();
i=0;
aArgs1[i++] = "Cone";
aArgs1[i++] = "MeshSurface";
aArgs1[i++] = null;
aArgs1[i++] = null;
obj = ExecuteScriptCommand("CreatePrim", aArgs1 );
var aArgs2 = new Array();
i=0;
aArgs2[i++] = obj
aArgs2[i++] = null;
aArgs2[i++] = null;
aArgs2[i++] = siModal;
try {
        ExecuteScriptCommand("InspectObj", aArgs2 );
}
catch (e) {
        LogMessage("command cancelled");
}

See Also

Application.ExecuteScript Command