Custom Command Examples

These examples demonstrate how to implement self-installing custom commands using various implementation languages.


Simple Command
This example implements a simple custom command that takes one argument and logs the argument value to the command history. The example includes JScript, Python, VBScript, C++ and C# versions of the command. You can run the command from the Script Editor or add the command to a toolbar. The C# version included is more elaborated as it takes a selected object as input and logs all its parameters.

Custom commands are one of the main building blocks for more sophisticated plug-in tools. The SimpleCommand example shows the basic code framework for a custom command. When you're ready to start writing your own custom commands, you could use it as a starting point. Or, even better, you can use the Command Wizard to generate a more complete code skeleton.

Simple Undoable Command
This example demonstrates how to implement an undoable custom command using the C++ API. This example creates a NetView view at 0,100 and the undoable command moves the window to 200,100. The positioning of the window can be undone and redone through the Undo and Redo built-in Softimage commands. The sample command can be accessed from the 'Undoable Custom Command' menu located in the main menu bar.

Example Files

Location
Files
simplejscommand.js
simplepycommand.py
simplevbscommand.vbs
simplecommand.cpp
GNUmakefile
simplecommand.vcproj
simplecscommand.cs
simplecscommand.csproj
simpleundoredocommand.cpp
simpleundoredocommand.vcproj
GNUmakefile

Running the Examples

To run the Simple Command example

To run the Simple Undoable Custom Command example

Building the C++ Examples

Follow the instructions below to build the examples.

To build the Simple Command example on Windows

  1. Open a Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from a Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the Simple Command project from the command line, type:

    devenv cppsrc\simplecommand.vcproj
    
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Win32/Win64 Release or Debug) and build the DLL.

To build the Simple Command example on Linux

  1. In a shell (tcsh) window, type:

    source $XSI_HOME/.xsi_<xsi_version>
    
  2. Change directories to

    cppsrc
    
  3. To remove all intermediate files before building the example, run this command:

    gmake clean
    
  4. To compile the example, run this command:

    gmake
    

To build the Simple Undoable Command example on Windows

  1. Open a Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from a Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the Simple Undoable Command project from the command line, type:

    devenv UndoRedo\simpleundoredocommand.vcproj
    
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Win32/Win64 Release or Debug) and build the DLL.

To build the Simple Undoable Command example on Linux

  1. In a shell (tcsh) window, type:

    source $XSI_HOME/.xsi_<xsi_version>
    
  2. Change directories to

    UndoRedo
    
  3. To remove all intermediate files before building the example, run this command:

    gmake clean
    
  4. To compile the example, run this command:

    gmake
    

Building the C# Simple Custom Example

Follow these instructions to build the C# plug-in.

Note: You can either use Visual Stusio .NET 2005 or Visual C# 2005 Express Edition to build the example. Visual C# Express can be dowloaded freely at http://msdn.microsoft.com/vstudio/express/visualcsharp/.

To build the example on Windows

  1. Open a Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET or Visual C# Express from a Softimage command prompt ensures that environment variables such as XSI_USERHOME are set (otherwise you'll get build and link errors).

    Tip To load the SimpleCommand project from the command line, type:

    devenv cssrc\SimpleCSCommand.csproj
    
  2. In Visual Studio .NET, open the project file .csproj.
  3. Select a configuration (Release or Debug) and build the DLL.

Keywords

This example uses the following keywords:

C++, JScript, Python, VBScript, C++ example, JScript example, Python example, VBScript example, C# example, RegisterCommand, Init, Execute, ArgumentArray, GetArguments, PutUserData, Undo, Redo, CValue::siPtrType, Command, Context, GetSource,