# C++ API Reference

The C++ Application Programmer's Interface (API) is a collection of C++ classes that exposes Autodesk® Softimage®'s functionality through methods and properties written in C++. The C++ API architecture does not replace the Softimage object model (OM) but is an alternative solution for C++ developers writing plug-ins for Softimage.

# Running the C++ API Reference Page Examples

The reference pages for the C++ API provide code samples to demonstrate how to use the classes and their members. If you want to test out these snippets for yourself, you can test them by following these instructions:

1. Generate the skeleton code for a command using the C++ Command Wizard (available in contextual menus of the Plug-in Tree in Softimage).

   The Command Wizard also generates a Visual Studio .NET 2003 project (.vcproj), a Visual C++ project (.dsp), and a GNUMakefile. Using project/makefile generated by the wizard ensures that your development environment is set up correctly.

2. To make sure the required environment variables, such as `XSISDK_ROOT`, are set, do one of the following:

   - On Windows, start Visual C++ from a Softimage Command Prompt (provided during installation) and open the project (.vcproj) generated by the wizard.

   - On Linux, run the following command in a shell (tcsh):

         source <Softimage install folder>/.xsi_[version]

3. Open the source code file generated by the wizard and find the TODO comment in the Execute callback:

       XSIPLUGINCALLBACK CStatus YourDummyCommand_Execute( CRef& in_ctxt )
       {
       	Context ctxt( in_ctxt );
       	CValueArray args = ctxt.GetAttribute(L"Arguments");

       	Application().LogMessage(L"YourDummyCommand_Execute called");
       	//
       	// TODO: Put your command implementation here.
       	//
       	// Return a value by setting this attribute:
       	ctxt.PutAttribute( L"ReturnValue", true );

       	// Return CStatus::Fail if you want to raise a script error
       	return CStatus::OK;
       }

4. Paste the code from the reference page example that you want to test into the TODO location.

5. Make sure you have included each header file corresponding to the classes the code uses. For example, the X3DObject class uses the xsi_x3dobject.h file, the SIObject class uses the xsi_siobject.h file, etc. For a list of header files available in the C++ API, see the File List reference page.

Note: Don't forget, if a function appears in the example, use it as a distinct function (eg., paste it at the end of your source file, not inside the Execute callback), and remember to add forward declarations, if necessary.

6. Compile the code. For Linux, you can run the gmake command from the shell.

7. Load the plug-in into Softimage, and in the script editor, type the name of the command and then click Run.