RMS
Scripting Slim Palettes


return to main index


Introduction

Pixar's RenderMan Studio (RMS) enables most of the functionality "normally" accessed via their GUI's ie. mouse and keyboard input, to be controlled directly via MEL scripts.

These notes (currently in development Oct 2007) closely follows those that deal with the Mtor "equivalent" way of scripting Slim. Refer to Scripting a Mtor/Slim Palette.


Accessing Slim Commands

Invoking a slim command from MEL takes the general form of,

rman slim "COMMAND -flag1  -flag2...";
// for example
rman slim "[slim CreatePalette -new -edit]";
 
    or
 
rman slim "$reference COMMAND -flag  data]";
// for example
rman slim "set plastic [$p CreateInstance -file \"$RMANTREE/lib/shaders/plastic.slo\"]";
rman slim "set cs [$plastic GetProperties -name \"Cs\"]";
 
    or
 
slimcmd $reference COMMAND info;
// for example
rman slim "[$p SetLabel \"my palette\"]";

By $reference I mean a string that indentifies a slim object - Pixar's documentation calls them "handles".


Creating a Palette

Because the MEL script we are writing will most probably be run several times we need to check for the existance of a previously created palette.


code snippet 1


rman slim "set p [slim FindPalette \"my palette\"]";
rman slim "if { $p == \"\" } { set p [slim CreatePalette -new -edit] }";
rman slim "[$p SetLabel \"TemplateTest\"]";
rman slim "[$p UpdateEditor]";
rman slim "[slim WindowCmd Show $p]";
rman slim "set entries [$p GetAppearances -name \"*\"]";
rman slim "if { [llength $entries] > 0 } { [$p DeleteEntries $entries -remove] }";

Adding a Shader

The macro $RMANTREE will expand to the full path of the Pixar directory.


code snippet 2


rman slim "set shader [$p CreateInstance -file \"$RMANTREE/lib/shaders/plastic.slo\"]";
rman slim "[$shader PreviewRender]";
rman slim "[$p UpdateEditor]";
rman slim "[slim WindowCmd Show $p]";
rman slim "[$shader Edit]";

Setting Shader Values

Notice the use of quoted curly braces to enclose multiple values. Internally
slim uses the TCL scripting language - lists are enclosed in parenthesises.


code snippet 3


rman slim "set cs [$plastic GetProperties -name \"Cs\"]";
rman slim "[$cs SetValue \"1 1 0\"]";
rman slim "[$shader PreviewRender]";
rman slim "[$p UpdateEditor]";

Adding a Template

This mel snippet assumes a slim template file is located at

    /home/user_name/cutrTest.slim

The slim template represents a constant "shader" ie.

slim 1 extensions cutter {
extensions fundza cutr {
    template shadingmodel Test {
        collection shadingmodel shadingmodel {
            access output
            display hidden
            parameter color CI {
                access output
                }
            parameter color OI {
                access output
                }
            }
        RSLFunction {
        void
        cutrTest (
                output color CI;
                output color OI;
                )
        {
        OI = Os;
        CI = OI * Cs;
        }

code snippet 4


rman slim "set p [slim FindPalette \"TemplateTest\"]";
rman slim "if { $p == \"\" } { set p [slim CreatePalette -new -edit] }";
rman slim "[$p SetLabel \"TemplateTest\"]";
rman slim "[$p UpdateEditor]";
rman slim "[slim WindowCmd Show $p]";
rman slim "set entries [$p GetAppearances -name \"cutrTest*\"]";
rman slim "if { [llength $entries] > 0 } { [$p DeleteEntries $entries -remove] }";
  
rman slim "[slim ReadSlimFile \"/home/user_name/cutrTest.slim\"]";
rman slim "set appearance [$p CreateInstance -template \"fundza,Test\"]";
rman slim "[$p UpdateEditor]";
rman slim "[slim WindowCmd Show $p]";
rman slim "[$appearance Edit]";





© 2002- Malcolm Kesson. All rights reserved.