Tuesday, August 10, 2010

Slim user commands















For adding a custom user commands to Slim menu, you need to modify your custom slim.ini and TOR.ini. Also you have to write custom Slim template with your cmdui definition.

Tip:
To customize RAT environment, it is a good practice to keep your custom slim.ini and TOR.ini files in the directory defined in system environment variable RAT_SCRIPT_PATHS. You can define space-separated list of directories in this variable for connecting templates and settings from different location inside studio. 
E.g.: SET RAT_SCRIPT_PATHS=d:/slim //server/studio/slim


1. Here is a fragment of code from my meCustomCmd.slim

#===============================================================
slim 1 extensions mesh {
  extensions mesh sl {
    cmdui meshFunctions {
        invocation {PaletteEditor/Functions/Read Slim file(s)} \
        {ReadSlimFile %c}
        TclTkSource {
          proc ReadSlimFile plt {
            ::RAT::PickFile -cmd "slim ReadSlimFile %v" 
            -filetypes Source           
            -mode openmulti
          }
        }
        invocation {PaletteEditor/Functions/Flatten Shader} \
        { ::mesh::FlatShader %c}
        invocation {PaletteEditor/Functions/App Params Manager} \
        { ::mesh::slimParamManager %c}
        invocation {PaletteEditor/Functions/Get App Info} \
        { ::mesh::GetAppInfo %c}
        invocation {PaletteEditor/Functions/Get Params Info} \
        { ::mesh::GetParamsInfo %c}
        invocation {PaletteEditor/Functions/Reload Slim extensions} \
        {    slim ReloadExtensions slim
            slim ReloadExtensions customcmd
            slim ReloadExtensions customui
            slim ReloadExtensions tcl
        }
    
    ... skipped ...

    }
  } 
} 
2. If meCustomCmd.slim is located in d:/slim/mesh, then somewhere in the begining of custom slim.ini add the following commands:

set userTempl [GetEnv RAT_SCRIPT_PATHS]
LoadExtension slim [file join $userTempl mesh//meCustomCmd.slim] customcmd 

3. If scripts with user commands are located in d:/slim/mesh/(cmd), then somewhere in custom TOR.ini add the following commands:

set userCmdDir [file join [GetEnv RAT_SCRIPT_PATHS] mesh//(cmd)] 
LoadExtension tcl [file join $userCmdDir meCommon.tcl]
LoadExtension tcl [file join $userCmdDir FlatShader.tcl]
LoadExtension tcl [file join $userCmdDir GetAppInfo.tcl]
LoadExtension tcl [file join $userCmdDir EnsTools.tcl]
LoadExtension tcl [file join $userCmdDir slimParamManager.tcl]
LoadExtension tcl [file join $userCmdDir slimPaletteManager.tcl]
LoadExtension tcl [file join $userCmdDir NodesTools.tcl]

No comments:

Post a Comment