## XSIApplication.ExecuteCommand

### Introduced

v6.0

### Description

Executes a Softimage Command identified by its scripting name. This method can be used to execute any built-in or custom command. This method is similar to XSIApplication.ExecuteScriptCommand, but unlike ExecuteScriptCommand, the method doesn't pack output arguments in an ISIVTCollection object but rather in a standard Array.
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 applications written with C# to be able to call Softimage commands.

### C# Syntax

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

### Scripting Syntax

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

### Return Value

Returns a C# System.Object or a Variant in scripting, containing the value returned from the command. If the command has no return value explicitly defined, ExecuteCommand returns all output arguments in an Array object. However, if the command defines a return value, you cannot extract any output arguments from it. This is because the command is not returning an output argument array, but a specific value. You can check the Return Value section in the Softimage reference documentation to see whether it uses an explicit return value and what that value is.

### Parameters

Parameter | Type | Description
--- | --- | ---
Name | String | Command's script name
Arguments | Array of Variants in scripting or array of System.Objects in C#. | Array of all required command arguments, including output arguments.

### Examples

#### C# Example

    //
    // This example illustrates how to use Softimage commands from C#.
    //
    CXSIApplication xsi = new CXSIApplication();
    try
    {
            // Create a cube to add the new property
            Object[] args = new Object[4] { "Cube", "MeshSurface", null, null };
            xsi.ExecuteCommand("CreatePrim", args);
            // Add an Annotation property to the new cube
            args = new Object[5] { "Annotation", null, null, "Annotation", null };
            Array retVal = (Array)xsi.ExecuteCommand("SIAddProp", args);
            // Inspect the Annotation Property
            args = new Object[5];
            args[0] = retVal;
            xsi.ExecuteCommand("InspectObj", args);
    }
    catch (Exception e)
    {
            xsi.LogMessage("Exception raised: " + e.ToString(), siSeverity.siError);
    }

### See Also

XSIApplication.ExecuteScriptCommand Command