Next Previous Contents

6. The Tcl Scripting Interface

The scripting interface is mainly a bunch of Tcl procedures and Tcl commands that a big part of The Mops uses internally.

Using Tcl, you could directly modify the code The Mops consists of. This is, however, not recommended for good reasons. So watch out for already existing procedures and commands when implementing your own!

Using procedures and commands not listed in this documentation is dangerous too. Implementation and interfaces of that commands may change in future versions.

The scripting interface may be used directly from the console of The Mops. You can, of course, also write procedures in your own Tcl script files, that may be loaded at any time into The Mops using the console and the command "source".

Note, that most of the listed commands work in background, without changing anything to the Mops GUI and Mops view windows, for execution speed. If you want your changes to become visible you have to update the various parts of the GUI explicitly.

From scripts it may be necessary to check wether an error occured during the execution of a command. All commands return TCL_OK in any case so checking their return value avails to nothing, but they set the global Tcl variable mops_error to 1 if an error occured. You need to set it to zero before and check it after the operation in question to see whether the operation performed successfully.

6.1 Index of Procedures and Commands

Creating Objects

To create new objects the "crtOb" command can be used.

Manipulating the Selection

These functions are probably the most important ones, because a lot of the other commands operate on selected objects only.

setSelect:

selectNext:

Clipboard Operations

copOb - copy object:

cutOb - cut object:

pasOb - paste object:

delOb - delete object:

Hierarchy Operations

goDown:

goUp:

goTop:

swapOb:

reverseOrder:

Transformations

movOb - move objects:

rotOb - rotate objects:

scalOb - scale objects:

movSel - move selected points:

rotSel - rotate selected points:

scalSel - scale selected points:

delegateTran - delegate transformations:

Manipulating Shaders

delShader:

scanAllShaders:

Manipulating NURB Curves and Surfaces

clampNC:

elevateNC:

getNCPoint:

setNCPoint:

getNPPoint:

setNPPoint:

insKn - insert knot:

refineNC:

revertNC:

rpNC - reparam NURB curve:

splitNPatch:

buildNPatch:

Updating the GUI

redrawAllViews:

updateMopsSelect:

updateMopsPList:

Custom Objects

lc - load custom:

getCustomObjects:

Manipulating Properties

All properties need to be copied from the Tcl context (the GUI) to the C context (the scene storage) and vice versa while The Mops is running. There is a pair of two commands for each property that manages this. The commands are e.g. named "setSProp" (set shader property) and "getSProp" (get shader property), set denotes transport from Tcl to C and get denotes transport from C to Tcl.

They always need a selected object (C context), and a global arrray that holds the data of the property in the Tcl context. Each property uses it's own global array, an example for the aforementioned shader properties is e.g. surfaceShaderData.

Example:

You are welcome to apply a surface shader (try matte) to an object, keep object and SurfShader property selected, then type in the console:

"parray surfaceShaderData"

to see how this special array is organized.

See how the entry of Ka changes (in the property GUI!), while you type:

"set surfaceShaderData(Ka) 5"

To apply the changed Ka value back to the C context type:

"setSProp surface surfaceShaderData".

Check whether the property has really been updated by clicking on SurfShader in the properties listbox.

Always call the get property procedure before the set property procedure to initialize the array with correct values!

For more details (exact names of commands and arrays) please see the documentation of the properties in section Mops Objects and Properties.

Applying Commands to a Number of Objects

There are two commands that help to apply arbitrary commands to a number of objects, forAll and forAllT.

forAll:

forAllT:

Scene IO

newScene:

replaceScene:

insertScene:

saveScene:

Miscellaneous

getType:

getTmpFile:

hasChild:

setON:

saveUndo:

undo:

convOb:

forceNot:


Next Previous Contents