Object Hierarchy | Related C++ Class: Argument







The Argument object represents an argument (or "parameter") of a Softimage Command. For example the DeleteObj command takes 1 argument ("InputObj"). You add arguments to custom commands using the ArgumentCollection.Add, ArgumentCollection.AddWithHandler or ArgumentCollection.AddObjectArgument method.

Argument objects are used in three circumstances in Softimage:

- For defining command arguments at creation time When a command is created, arguments are added to the Command object and the Argument.Value is set to define the default value for that argument. This default value is persisted and is used as the argument value in the case that no value is specified at invocation time.

- For specifying argument values when invoking a command. When a command is invoked, Argument.Value is used to specify the value of the argument that will be passed to the command. You may also define an ArgumentHandler to get a default value based on the selection or the scene content. You can create an argument with a handler using the ArgumentCollection.AddWithHandler method.

-In the third case it is possible to change the definition of a custom command after it has been installed. In this case Argument.Value is used to specify new default values for the command, and it is possible to add and remove arguments. Then Command.Update is called to commit the changes.

For a detailed description of the workflow for creating custom commands, see the Command object.


IsClassOf operator IsEqualTo operator    


Application Categories Flags FullName operator
Handler Help Name operator NestedObjects
Origin OriginPath Parent Type operator


1. JScript Example

/* ------------------------------------------------------------------------------
	This JScript example demonstrates how to create a command with
	arguments and then how to pass values to the command when executing it.
------------------------------------------------------------------------------ */
//  Start off with a clean slate
Application.RemoveCommand( "SillyPutty" );
//  Get the user path and use it to build the filename + path
sFileName = InstallationPath( siUserPath ) + "\\Data\\Scripts\\MySillyPutty.js";
//  Create the script on disk
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
var fHWFile = fso.CreateTextFile( sFileName );
fHWFile.WriteLine( "function OnSillyPutty( gooey, mute )" );
fHWFile.WriteLine( "{" );
fHWFile.WriteLine( "\tLogMessage( \"SillyPutty is working!\" );" );
fHWFile.WriteLine( "\tLogMessage( gooey );" );
fHWFile.WriteLine( "\tLogMessage( mute );" );
fHWFile.WriteLine( "}" );
//  Create the custom command
var oCmd = CreateCommand( "SillyPutty", siNoCategory );
oCmd.Description = "Stretches and bends until it reaches the breaking point.";
oCmd.ScriptingName = "SillyPutty";
oCmd.Handler = "OnSillyPutty";
oCmd.FileName = sFileName;
oCmd.Language = "JScript";
//  Add some arguments
var oArgs = oCmd.Arguments;
oArgs.Add( "Gooeyness", siArgumentInput, 24.0, siDouble );
oArgs.Add( "Mute", siArgumentInput, false, siBool );
//  Register the new command
AddCommand( oCmd );
//  Populate the arguments and run the command
var oRunCmd = Application.Commands( "SillyPutty" );
oRunCmd.Arguments(0).Value = 50.0;
oRunCmd.Arguments(1).Value = true;
/* ------------------------------------------------------------------------------
	Output of above command:
	INFO : "SillyPutty is working!"
	INFO : "50"
	INFO : "True"
	SillyPutty(50, true, null);
------------------------------------------------------------------------------ */

2. VBScript Example

'vbscript Custom Command Demo
'This script demontrates the Softimage support for creating a custom command and handling its
'This example uses an embedded command.
'When you run this script the following results will be logged in the script history:
'	INFO : "Installing example command found in c:/temp/CmdDemo.vbs"
'	INFO : "Default arguments for command are : DefaultString 2.2"
'	INFO : "ExampleCommand is now installed"
'	INFO : "ExampleCommand called - DefaultString 2.2"
'	INFO : "ExampleCommand called - Another string 1.1"
dim cmd
'Remove any existing earlier registrations of this command
if ( typename( Application.Commands( "ExampleCommand" ) ) = "Command" ) then
	Application.RemoveCommand "ExampleCommand"
end if
set cmd = Application.CreateCommand("ExampleCommand", siNoCategory)
cmd.Description = "Example custom command"
cmd.ScriptingName = "ExampleCommand"
cmd.Handler = "OnExampleCommand"
cmd.Code = _
	"function OnExampleCommand( StringArg, DblArg ) " & vbCrLf & _
	"     'Show the arguments we recieved" & vbCrLf & _
	"     LogMessage ""ExampleCommand called - "" & StringArg & "" "" & DblArg" & vtCrLf & _
	"     'Return this value" & vbCrLf & _
	"     OnExampleCommand = 55 " & vbCrLf & _
	"end function"
cmd.Language = "VBScript"
'Command is function, not a sub
cmd.ReturnValue = true									
cmd.Arguments.Add "StringArg", siArgumentInput, "DefaultString"
cmd.Arguments.Add "DblArg", siArgumentInput, 2.2
logmessage "Default arguments for command are : " & cmd.Arguments(0).Value & " " & cmd.Arguments(1).Value
Application.AddCommand cmd
logmessage "ExampleCommand is now installed"
'Now that the command is installed we can look it up and execute it
set cmdlookup = Application.Commands("ExampleCommand")
'This will execute it with default values
'Use these specific values
cmdlookup.arguments(0).Value = "Another string"
cmdlookup.arguments(1).Value = 1.1

3. VBScript Example

'VBScript example
set args = Application.Commands("Twist").Arguments
for each a in args
	LogString = a.Name & ":"
	if a.Flags = siArgumentInput or a.Flags = siArgumentInputOutput then
		LogString = LogString & CStr(a.Value)
	end if
	LogMessage LogString