AddWithHandler (ArgumentCollection)
Introduced
4.0
Description
Appends an argument with an ArgumentHandler.
Scripting Syntax
ArgumentCollection.AddWithHandler( ArgumentName, ArgumentHandler, [DefaultValue] )
C# Syntax
Argument ArgumentCollection.AddWithHandler( String in_ArgumentName, Object in_ArgHandler, String in_DefaultValue );Parameters
|
Parameter |
Type |
Description |
|
ArgumentName |
Name of the new argument to append |
|
|
ArgumentHandler |
Name of the argument handler to use. |
|
|
DefaultValue |
Normally Argument Handlers do not require a default value, but some adjust their behavior if a string is provided. For example if the string "*" is provided in conjunction with the "Collection" Argument Handler then all the objects in the scene are sent to the command rather than the current selection. This behavior is documented with the siArgumentHandler enum. |
Return Value
Examples
JScript Example
// JScript example: Add argument handler that gets the current selection // Remove existing command Application.RemoveCommand("MyCommand"); // Create a command named "MyCommand". You must create the file and paste // the "MyCommandFunc" function in the file to get the example to work var oCmd = Application.CreateCommand("MyCommand"); // Outputs all element that are currently selected function MyCommandFunc( in_CurrentSelection ) { Logmessage( "MyCommandFunc was called with the following arguments: " ) ; for (i = 0; i < in_CurrentSelection.Count; i++ ) { var currentItem = in_CurrentSelection(i); LogMessage( currentItem.Name ); } } // Set the handler code (this is an embedded command) oCmd.Code = MyCommandFunc.toString() ; oCmd.Language = "Jscript" ; // Function implementing the handling code (see MyCommandFunc for the actual function code) oCmd.Handler = "MyCommandFunc"; // Adds an argument handler that gets the currently selected objects // when the user does not specify the argument value when invoking the // command. var oCmdArguments = oCmd.Arguments var noValue; oCmdArguments.AddWithHandler ( "CurrentSelection", // name of the new argument "Collection", // name of the argument handler to use noValue // parameter to the argument handlers (stored in Argument.Value) ); // Register the new command Application.AddCommand(oCmd); SelectObj( "light" ) ; // Call the updated command. The "CurrentSelection" argument // will contain the current selection. oCmd.Execute(); // You can override the behavior by passing specific object oCmd.Arguments(0).Value = "Camera_Root" ; oCmd.Execute() ; // Remove the command Application.RemoveCommand("MyCommand"); // Expected results: //INFO : "MyCommandFunc was called with the following arguments: " //INFO : "light" //INFO : "MyCommandFunc was called with the following arguments: " //INFO : "Camera_Root"
See Also
Autodesk Softimage v7.5