Script-Defined Attributes

< Previous | Contents | Manuals Home | Boris FX | Next >

object.trk


Script-Defined Attributes

Sizzle allows scripts to set up new attributes for shots, objects, trackers, phases, meshes, lights, notes, extra points, and splines. New attributes must be either a string or a number. For more complex attribute values, convert the value to a string (ie with printf/sscanf).

Each of the corresponding lists, ie Shot, Obj, Trk, Phase, Mesh, Lite, Note, Extra, and (a shot).spline, implements three additional functions:

.AddAttr(nm, default) Add a user-defined attribute with the given

name (nm) for objects of this type, with the default value specified, which will be returned any time this attribute is requested from an object where this attribute has not yet been set. The default value must be either a number or string.

.RemAttr(nm) Removes the given attribute from the list of permissible user attributes for this type of object. The attribute values will be removed from each object as well.

.DefAttr(nm) Returns the default value for this attribute.

Once you have added an attribute to a type of object, you can fetch or set the value of the attribute for any particular instance of this object type as if it was a built-in attribute. For example:

Obj.AddAttr("serial", "unknown") Mesh.AddAttr("version", "0")

...

cam = Scene.activeObj.cam cam.serial = "S/N 1305"

...

msh.version = msh.version + 1

Note that in this example, attributes must be added for Obj, not Cam, since the created attributes apply to both cameras and objects. The attributes will be carried around with the object even if its name is changed, the file is merged with another, etc.

Unlike a normal Sizzle variable, the added attributes are part of the SynthEyes scene file and persist from one script run to the next; they are saved in the sni file and available when it is loaded again (unlike global variables, which persist from script to script but only during a single run of the SynthEyes program). Also unlike global variables, attributes are subject to normal Undo- system operation. Both types are useful, but in different situations!

Scripts sharing attributes among several scripts should re-AddAttr their attributes at the beginning of each script, in case that script is the first run using those attributes.

The creation, usage, and interpretation of the added attributes is up to the script programmer. Attributes are not magically exported to any other package, for example. With the right scripts, one script may allow you to tag an object with special properties for use during a particular corresponding export!


©2023 Boris FX, Inc. — UNOFFICIAL — Converted from original PDF.