C# Scripting

This plug-in shows how to use C# as a scripting language from the Scripting Editor. You can use it when you need to test some simple C# code in Softimage without having to create a plug-in. To use C# scripting, just add a Script.Main method entry-point in the Scripting Editor, type C# code in the Main function and Run the code by right-clicking the C# Scripting | Run menu in the Scripting Editor window.

E.g.:
   class Script
   {
      public static void Main()
      {
         // Code goes here
      }
   }

The C# scripting menu contains the following entries:


Note: The assemblies required by your C# code are not referenced automatically by the C# compiler. If a reference is missing, the compiler will issue an error. Referenced assemblies can be added/removed through the References menu. For instance, if your script needs a reference to System.Web, you must add an entry to the reference list containing System.Web.dll.

Example Files

Location
Files
CSharpScripting.csproj
CSharpScripting.cs

Running the Example

To run the example

  • From the Scripting Editor, right-click in the editor window and select the C# Scripting | New menu.
  • Add some C# code in the Main method such as:
    public static void Main()
    {
       CXSIApplicationClass xsi = new CXSIApplicationClass();
       xsi.LogMessage( "Called From Main", siSeverity.siInfo );
    }
    
  • Right-click in the Scripting Editor window and select the C# Scripting | Run menu.

Building the C# Scripting Example

Softimage SDK includes a compiled version of C# Scripting. If you want to modify the code, you can rebuild the example by following these instructions.

To build the example on Windows

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

    Starting Visual Studio .NET from an 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 CSharpScripting project from the command line, type:

    devenv src\CSharpScripting.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#, RegisterCommand, RegisterMenu, View.