Você está na página 1de 19

Sizzle™ Scripting Language for

SynthEyes 2008 Build 1000


©2003-2007 Andersson Technologies LLC

Overview
Sizzle is a scripting language enabling SynthEyes users to modify the scene files
exported for different 3-D animation packages, create their own exporters for new software
packages, create or modify importers, and create or modify scene tools. It is derived from a loose
amalgam of C++, Javascript, Visual Basic, AWK, etc. User’s familiar with any of these scripting
languages, or scripting languages for 3-D packages such as 3ds max or MEL should recognize
enough to get started. A complete guide to programming can not be provided here. The features
described here are for the SynthEyes 2008 build in the title; features may be available in earlier or
later builds as well.
Warning: if you start changing things in the scene, you can potentially create an
unreadable scene.
If you use the VIM text editor (http://www.vim.org), you can obtain a syntax file that will
color-code the Sizzle scripts as you edit them by e-mailing support@ssontech.com.

A First Example
A simple Sizzle exporter script is listed below. The first line must contain “//SIZZLEX ”,
starting in the first column. After that follows a file extension, and a human-readable name for the
exporter. This information appears on SynthEyes File/Exports menu. SynthEyes picks up its list
of scripts from reading the SynthEyes program folder (and also a user-specific folder), looking
for files with a .szl extension and the proper header.

//SIZZLEX .tst Test Exporter


@[
DateTime("%a, %b %d, %Y %I:%M:%S %p") "\n"

"Number of objects " #Obj "\n"


for (ob in Obj)
"Object name " ob.nm "\n"

shot = ob.shot
f0 = shot.start
f1 = shot.stop
for (frame = f0; frame <= f1; frame++)
printf("Frame %d: %.3lf %.3lf %.3lf %.3lf %.3lf %.3lf\n",
frame, ob.x, ob.y, ob.z, ob.rx, ob.ry, ob.rz)
end

printf("%d trackers\n", #ob.trk)


for (tk in ob.trk)
printf("Name %s %.3lf %.3lf %.3lf err %lf\n", tk.nm,
tk.wx, tk.wy, tk.wz, tk.error);
end
end
Message("Hi, this is a test")

The @[ sequence on the second line switches Sizzle into script mode. The Sizzle script is
embedded in the file, the same as Javascript is embedded in an HTML web page.
At the beginning of a file, Sizzle reads the input, copying it to the output. When it
encounters a @[ sequence, that denotes the beginning of some Sizzle script, which continues until
the next ]@. Sizzle interprets everything between the ]@ and the @[ as if it was in “quotes” If
you want the file to include the value of ten plus eleven, you could just write @[10+11]@ and it
would appear as 21 in the output file. Of course, in a real Sizzle script, much more interesting
expressions can be used, accessing shot, object, and tracker information.
This makes a different style possible:
//SIZZLEX .tsx Another test
This stuff just goes right into the file.
There are @[#Trk]@ trackers in the scene,
And @[Shot[1].length]@ frames.
I’d like to emphasize the following remark,
@[for (I = 1; I <= 10; I++)]@by repeating it 10 times…
@[end]@. That should be enough.
This style of scripting can be easier to read, especially when an output file format
requires a lot of “boilerplate”. You can embed the Sizzle script into the file, or vice versa.

Types of Scripts
Sizzle supports three different script types: importers, tools, and exporters. The importers
read an input file, typically to add a new object or tracker path to the scene. An exporter examines
the scene, producing an output file that will later be read by a computer-graphics or compositing
package. Sizzle tools examine the scene and optionally make changes.
Since any script can read or write files, the distinction between types is somewhat
arbitrary, but SynthEyes provides specialized amenities for the varieties, such as sticky export file
names for exporters.
Import scripts appear on the File/Import menu, export scripts on the File/Export menu,
and tools on the Script menu.
The scripts are placed in the scripts folder, usually located in “C:\Program
Files\Andersson Technologies LLC\SynthEyes” or “/Library/Application Support/SynthEyes,” or
in a user-specific folder. You can quickly get to either folder with the two menu items at the top
of the Script menu.
SynthEyes mirrors the folder structure into the menus, so you can create subfolders of
related scripts and have them turn up inside a submenu. This can help reduce clutter and let you
keep straight different versions of scripts, or distinguish standard scripts from your custom ones.
To tell which type of script is which, the header lines are different:
//SIZZLEI .ext Human-readable importer name [An importer for .ext files]
//SIZZLET Human-readable tool name [A tool]
//SIZZLEX .ext Human-readable exporter name [An exporter for .ext files]
SynthEyes will prompt for the file name for importers and exporters. Any script can read
or write additional files if it needs to, by calling the appropriate I/O functions within Sizzle.
After running any script, you can undo its effect if desired.

Objects Lists, Objects, and Attributes


Sizzle uses objects and attributes to represent entities within SynthEyes, such as trackers
and cameras. A camera has attributes including its position and focal length, while a tracker
provides attributes about its position in the world and the image plane.
A script accesses the objects using Object Lists. There is an object list for each of the
major types of objects within SynthEyes, such as the Obj, Trk, and Shot lists.
Each object in a list can be grabbed using subscripting: Obj[1] is the first object(typically
a camera), Trk[5] is the 5th tracker. Often, a loop such as for (ob in Obj) … end will let you loop
over each object without subscripting.
The object attributes are accessed as ob.nm or ob.x, for example, or indirectly with
ob.$chan where chan is “x”, “y”, or “z”. Some attributes may themselves be lists, such as
Shot[1].obj[1].trk, the list of trackers on the first object of the first shot.
The Obj list, Mesh list, and Obj.trk lists permit subscripting by an object name, for
example, Obj[“Camera01”].trk[“Tracker1”] returns an object representing Tracker1 on
Camera01. Note that this style is rarely necessary―it is inefficient and object names should not
be burned into scripts―but lookups by name can be very helpful in import scripts.
You can create new objects using the new operator, which is applied only to lists, and
only to those lists indicated in the reference below. For example, new Lite creates a new light
and returns it for further manipulation. Objects are created with default attribute values
determined by SynthEyes.
You can delete trackers, meshes, lights, or extra points using the delete operator, for
example, delete tk to delete a tracker.
However, deletions are not actually performed until after the completion of the script—
objects to be deleted are tagged for deletion, but remain accessible and are still counted as a
member of their list. If you delete tracker1, it will still appear in Camera01.trk and be counted in
#Camera01.trk.
You can determine if a particular object has been tagged for deletion by using its
.willDelete attribute. Since you can change this attribute, you can use it as an alternate way to
delete an object. You can even use it to undelete an object.
As a convenience, deleted objects are not included if you use for (…in…) loops. If you
want to see deleted objects in a loop, use for(i=1; i <= #list; i++).

Expression Operator Precedence


Sizzle uses a simplified operator precedence, especially compared to C++. The
precedences have been adjusted to make embedding script in boilerplate easy. The operators are
listed from highest to lowest.

Terms (expr), [index], ob.attr, function calls, #ob, $indirection


Autoincrements ++x, --x, x++, x—
Powers x**2
Negations x, ~x
Multiplications x*y, x/y, x%y, x&y, x^y, x<<y, x>>y
Additions x+y, x-y, x|y
Selection (q ? x : y)
Relations x<y, x>y, x==y, x!=y, x<=y, x>=y
Boolean Negate !(x==3)
Boolean And x>y && y>z
Boolean Or x==5 || y>3
Assignments x=y, x+= y, x -= y, x *= y, x /= y, x &= y, x |= y, x ^=
y
Concatenation “a” x=”b” 2+3 x produces “a5b”

Note that the assignment operators do not produce output to the file, as in the
concatenation example above. The mini-script @[x=”Hi” “there”]@ writes “there” (without the
quotes) to the output file, assigning “Hi” to the variable x. This is because concatenation is lower
in the precedence table than assignment, so the assignment “=” binds only to “Hi”. If you wanted
x to be “Hi There”, you would write [@x=(“Hi” “There”)]@, which would output nothing.
Though this means you need parentheses for this example, the precedence above eliminates the
need to end each line with a semicolon or end of line.

Object Lists
Cam List of cameras
Curve List of 2-D Curve objects in the scene. New supported.
Extra List of “extra” points. New supported.
Flex List of 3-D Flex objects in the scene. New supported.
Lite List of lights. New supported.
Mesh List of mesh objects (boxes, waving man, imports).
New meshes added here.
Obj List of cameras and moving objects
Output Object containing output-specific attributes
Scene Object containing scene-specific attributes
Shot List of shots
Trk List of all trackers, solved or not. Use new object.trk

Objects and Attributes


Object
These are cameras or moving objects, from the Obj list, not “objects” as in “object-orient
programming.”
.cam Camera object for this object (Read only)
.ClearSelect() Unselect all trackers
.color 24bit color for the displayed object
.distortion Computed or hand-set distortion coefficient
.insideSplines(uvpos) Returns 1 if the uvpos point is inside the active spline
area (considering all splines, enables, object
assignments, etc) at the current frame, or 0 if not.
.isCamera 1 or 0: is it a camera? (Read only)
.fl Focal length for current frame (back plate width from
scene object)
.fov Horizontal field of view in degrees for current frame
.lensMode Lens mode: 0=known, 1=fixed, 2=zoom
.mode Solver mode as listed on solver panel: “Disabled”,
“Automatic”, “Refine”, “Tripod”, “Refine Tripod”,
“Indirectly”, “Individual mocap”, “From Seed Points”,
“From Path”
.nm Object’s name
.parent Parent camera of object (if object is a camera,
ob.parent == parent) (Read only)
.rmserr RMS error of overall solution for this object
.shot Shot to which object is attached (Read only)
.trk List of trackers attached to object (Read only, new
tracker supported)
.UpdateZWT() Recalculate the position of all zero-weight-trackers on
this object, or if it is a camera, on any attached object.
.valid Solved position available on this frame?
.vfov Vertical field of view in degrees for the current frame.
This is NOT the same as fov/aspect!

.weight Weight multiplier for the object’s trackers during


solving.
.worldSize world size setting
(transform attribs) See transform attribute listing. Gives world transform
of camera/object
Warning: writing the camera/object path or field of view can take some time because
splines and zero-weighted-trackers are recalculated after each write.
Tracker
.asp tracker aspect ratio, horizontal/vertical
.autokey automatically add a key after this many frames
.axisLock Combination of bits for axis locks on the tracker:
X/Y/Z = 1/2/4. If 8 is present, locks are to zero
coordinates, otherwise to the lockPos
.color Color in display, 24b RGB value. Is 0x818283 if the
color is the default determined by the preferences.
.dist Distance constraint value.
.direction Same as isBackward, but writing it causes the keys and
enable track to be adjusted to maintain existing
tracking data.
.error tracker’s root-mean-square tracking error.
.fom 0 to 1 figure of merit for tracking quality on this frame.
.isBackward tracker tracks backwards. Writing it affects only the
flag, not the keys or enable track. Use during setup
.isDone tracker has been marked “done” (locked)
.isEnabled tracker is enabled on the current frame
.isExported tracker should be exported
.wantFar Tracker should be solved as far (applies to seed
coordinates)
.gotFar Tracker was solved as far (ie even if a non-far solution
was desired). Use for all exports and solved positions
.isFar Far tracker status. When read, gotFar is solved,
otherwise wantFar. When written, sets both wantFar
and gotFar.
.inFront Predicted 3-D position in front of, not in back of, the
current camera.
.isGolden tracker is golden. Can only be written to 1, can not be
cleared.
.isKeyed Has a key on this frame. Set to add a key at the current
position, clear to 0 to remove a key
.isSeed tracker is a seed point
.isSel tracker is selected. When writing, the tracker selection
set is cleared only if the value is exactly 1.
.isShown tracker is shown in the viewports
.isSolved tracker’s position has been solved (0=no, 1=normal,
2=“individual”)
.key Key location u/v. Write to add a key at the given
location.
.kind 0/1/2/3: match, black spot, white spot, symmetric
.lockPos Vector, coordinates the target is locked to, or its seed
position. Always in Z-Up coordinates!
.MClear() Clears any motion-capture path for the tracker
.mlength Length of the tracker’s individual (motion-capture)
path, if any.
.mvalid Whether the tracker’s individual path, if any, is valid
on this frame. Can be read, or only be written to zero.
.mvec Tracker’s motion-capture path position (vector) on the
current frame.
.netcolor Net color: the default value is resolved to the net color
using the applicable preferences
.nm tracker’s name
.obj the object for this tracker. Do not change this within a
loop such as obj.trk, etc – it is effective immediately.
.outcome A numeric code reflecting the tracking results on this
frame, see below.
.ox,.oy,.oz,.ovec tracker’s position relative it’s host camera or object, a
constant. See vector attributes below. Only ovec is
writable.
.pegged If set, tracker will be pegged exactly at the specified
coordinates, subject to axisLock.
.polarity Combination of bits for desired prealignment axis
polarity: X/Y/Z positive = 1/2/4, X/Y/Z negative =
0x10/0x20/0x40.
.pu Predicted 3-D horizontal position, -1 to +1 (Read only)
.pv Predicted 3-D vertical position, -1 to +1 (Read only)
.puv Predicted 3-D position as seen from the active camera,
as a point (Read only)
.Run() Re-run the tracker at the current frame. Call after using
attributes below to make sure that the tracker is in a
consistent state.
.shot the shot for this tracker
.size tracker horizontal size, 0 to 1
.smooth smoothing region between earlier/later keys
.srch search-region size, as a point
.srchu horizontal search-region size, 0 to 1
.srchv vertical search-region size, 0 to 1
.target Target tracker that this tracker is locked to.
.u tracker’s horizontal position on this frame, -1 to +1
.uv tracker’s position as a point
.v tracker’s vertical position on this frame, -1 to +1
.valid a valid image position is available for this frame
.valid3d a valid 3-d position is available for this frame
.weight Weight given the tracker during solving. Set to less
than zero for a “zero-weighted-tracker”. Do not set
exactly to zero. Typically, set to -1, which is a zero-
weighted tracker that would be restored to a weight of
1 if the ZWT button on the tracker panel is clicked.
.willDelete 1 if the object will be deleted after the script completes.
Can be changed to control what will happen.
.wx,.wy,.wz,.wvec tracker’s current 3-D position, taking into account host
camera/object motion. Read only.
The tracker’s outcome code reflects what happened when a given frame was tracked. It is
a logical OR of several bits, as follows:
OUTCOME_RUN = 1
OUTCOME_ENABLE = 2 -- mirrors the enable track
OUTCOME_OK = 4 -- usable u/v present on this frame
OUTCOME_KEY = 8 -- there is a key here (OK will be on too)
OUTCOME_JUMPED = 16
OUTCOME_OUTASIGHT = 32
You can examine the outcome code on a particular frame as part of a 2-D export script, or
write to the outcome code as part of an importer. The outcome code reflects other portions of the
SynthEyes scene file, notably the tracker keying and enable tracks, and it is must be kept
synchronized with them to avoid an “inconsistent” scene that can produce errors.
Shot
If you need to determine whether the shot’s source is a single-file ‘movie’ of some kind,
or an image sequence, test whether or not imageName is null at the start of the shot. This is a sure
test even as new movie and image file extensions come into existence in the future.
.actualLength actual length of the shot, as currently available, in
frames (fields). Will be 10 if the shot is not readable.
.aspect shot’s (net) image aspect ratio (1.333, 1.777, 2.35 etc)
as output from image prep (Read only)
.aspectRef shot’s reference aspect ratio, normally the input of
image prep, or the output in Apply mode.
.aspectSrc shot’s source aspect ratio, into image prep (Read only)
.backPlateWidth camera’s back plate width setting (mm)
.biastime offset time of this shot’s first frame vs global, seconds
.cam Camera object for this shot (Read only)
.Flush() Clear the shot cache
.frameCount Number of complete frames in the shot, independent of
interlacing mode.
.handHeld tracker prediction mode: 0: predict, 1: sticky, 2: multi-
tracker predict, 3: current position (special use)
.height image height, pixels (Read only)
.imageName image file name for current frame (sequence), or empty
string if not an image sequence (Read only)
.insideSpline(name, uvpos) Returns 1 if the uvposition point is inside the named
spline at the current frame, or 0 if not.

.interlace interlace mode (a small integer)


.is16bit 16 bit enable flag. On read,shows if user has enabled
16 bit operation on 16 bit files. On write, enables 16 bit
operation for 16 bit source files. Note: you can’t force
16 bit operation on 8 bit files! Nor can you tell if the
source is 16 bit, if the user has turned OFF the 16 bit
checkbox.
.length shot length, frames (Read only)
.nm shot’s image file name (for a sequence, an ifl). If you
write this, call Flush() afterwards, and set the
frameCount correctly based on actualLength.
.obj List of objects using this shot (Read only, new
(moving) object supported)
.parity starting frame parity, if interlaced (Read only)
.pixasp shot’s pixel aspect ratio (0.88, 1.0, etc), determined
from image aspect and resolution. (Read only)
.rate frame rate, frames per second, does not have to be
integer
.skipFrame frame is skipped for autotracking and solving
.squeeze Animorphic squeeze factor
.start start frame number
.stop ending frame number
.width image width, pixels (Read only)
Mesh
.backFace Backface mode selected
.blue blue component of color, 0..1
.color 24-bit color value
.date Date mesh was imported, if any.
.face List of faces (new supported)
.file File name if mesh was imported (read/write)
.green green component of color, 0..1
.hasNormals Returns 1 if mesh has vertex normals, otherwise 0
.hasTexCos Returns 1 if mesh has texture coordinates, otherwise 0
.invertNormal Inverted normals
.kind Kind: Box, Sphere, Guy, etc, plus Custom
.nm Name of the mesh
.norm List of all vertex normals, if present
.obj Object that the mesh is attached to, or zero. Use typeof
to tell what has been returned.
.red red component of color, 0..1
.svec Object scale vector
.sx,.sy,.sz Object scale factor for each coordinate axis (Read
only)
.texco List of all vertex texture coordinates (u,v), if present.
Call msh.texco.Update() after making changes.
.trans Mesh position relative its parent.
.vtx List of all vertices in the mesh (new supported)
.wx,.wy,.wz etc Mesh position in world coordinates, taking parent
motion into account
.willDelete 1 if the object will be deleted after the script completes.
Can be changed to control what will happen.
.x,.y,.z, etc Mesh position relative its parent object, constant. See
Transform Attributes

Vertex and Face Lists


.ClearSelect() Clear the selections
.isSelected(vfno) Is vertex or face with the index given by vfno selected?
.Select(vfno) Select the given vertex/face
.Unselect(vfno) Unselect the given vertex/face
.Update() Call mesh.vtx.Update() after completing vertex
modifications, or mesh.texco.Update() after completing
texture coordinate modifications.
Mesh Faces
.showAB show a line from A to B in wireframe mode (also
.showBA)
.showAC show a line from A to C (same as .showCA)
.showBC show a line from B to C (same as .showCB)
.vA index to vertex A of the face (starts at 1, same as vertex
list)
.vB index to vertex B of the face
.vC index to vertex C of the face
Light
.kind Either “omni” or “directional”
.nm Name of the light
.x,.y,.z etc Light’s position/orientation transform on the current
frame (Read only)
.vec Light’s position (writeable)
.willDelete 1 if the object will be deleted after the script completes.
Can be changed to control what will happen.

Extra Points
.inFront Point is in front of, not behind, the active camera (read
only)
.inFront(cam) Point is in front of, not behind, the specific camera
(read only)
.nm Extra point name
.pu Predicted u position from active camera (read only)
.pv Predicted v position from active camera (read only)
.pu(cam) Predicted u position seen from specific camera (read
only)
.puv(cam) Predicted v position seen from specific camera (read
only)
.pv(cam) Predicted v position seen from specific camera (read
only)
.u Predicted u position from active camera (read only)
.u(cam) Predicted u position seen from specific camera (read
only)
.uv(cam) Predicted v position seen from specific camera (read
only)
.v Predicted v position from active camera (read only)
.v(cam) Predicted v position seen from specific camera (read
only)
.vec Position vector (writeable)
.willDelete 1 if the object will be deleted after the script completes.
Can be changed to control what will happen.
.x,.y,.z Extra point position on the current frame (read only)

Flex
.curve List of curves attached to this flex (read only)
.end 3-D position of the end point constraining the ending
end of the flex.
.endMode If 0, the flex ends perpendicular to the point, if 1, ends
exactly at the point.

.err RMS pixel error (read only)


.isVisible Flex is visible in the viewports
.nm Flex name
.obj Moving object it is attached to, if any
.seed List of seed control points (vectors) in the unsolved
flex. The list can not be written, but the elements can.
New is supported, and returns the new index number to
write.
.start Position of “start” point constraining the starting end of
the flex.
.startMode If 0, the flex starts perpendicular to the point, if 1, it
starts exactly at the point.
.way List of waypoints (vectors) in the solved flex. The list
can not be written, but the individual elements can.

Curve
.cp List of Curve Control Points (see below). New
supported.
.flex The flex to which the curve is attached, if any.
.isEnabled Animated control marking whether or not the curve is
valid on any frame.
.isVisible Show the curve in the viewports or hide it.
.nm Curve’s name
.obj The object (camera) to which the curve refers. (read
only)
.Pt(frac) Function returning the 2-D position along the curve at
the given frac (0..1) from start to end.
Curve Control Point
.curve The hosting curve for this control point (read only)
.isKeyed The control point is keyed on the current frame.
.pt The 2-D position of the control point on the current
frame.
Scene
These are read only except as noted.
.activeObj Object that is “active” within the scene.
.build SynthEyes build number, integer such as 1005
.clipboard Operating system’s clipboard, read/write
.exportFile Export file name
.exportType Export file type
.exportUnits Export units: “in”, “ft”, “yd”, “mi”, “mm”, “cm”, “m”,
“km”
.FolderPref(i) Returns the folder preference setting for the given
index: 1:BatchIn, 2:BatchOut, 3:Images, 4:Scene,
5:Imports, 6:Exports, 7:Previews
.info Access to the user’s Description of the scene file on the
File/File Info dialog, read/write.
.OSbits 32 on 32-bit operating systems, 64 on Windows XP-64
or Vista-64. Note that 64-bit operation requires a 64-bit
processor, a 64-bit Operating System, and a 64-bit
license and installation of SynthEyes.
.platform The machine, either “PC”, “MAC”, or “MACTEL”
.scriptFile The file name of the running script
.selected The (single) thing selected in the user interface. Use
typeof to determine what it is: SynMesh, SynObj,
SynTrk, SynLite, SynExtraPt
.Save(filename) Saves the .sni file to this name, intended for setting up
batch operations. Return value is 1 for success, 0
failure.
.SetFolderPref(i, foldername) Set the preference for the given index (see FolderPref)
to the given foldername.
.sourceFile Source .sni file name
.startFrame Starting frame number preference
.version SynthEyes version, something like 2005.1.1002
Output
.binary Set file to binary (value != 0) or text (value==0) Write
only.
.chars Number of characters written. Read only.
Transforms
The transform matrices are 4 rows by 3 columns, so that new vectors are multiplied in
from the left, as in OpenGL. Transforms are offered as attributes of various SynthEyes objects or
may be manipulated directly.
Transform(row1, row2, row3, row4) creates a transform object. Transform(diag_vector)
creates a transform with the specified vector constituting the diagonal. Transform(value) creates a
transform with the value repeated three times along the diagonal (good for zero and identity
transforms). RotX(angle), RotY(angle), and RotZ(angle) create transforms that rotate about the
specified axis by the given angle. Offset(vector) creates a transform with an identity rotation and
the given position offset. Mangle(axisMode) is a transform that mangles transforms from the
internal Zup to the given axis mode. Demangle(axisMode) is the inverse of Mangle.
A variety of different attributes may be accessed from a transform:
.x, .y, and .z are the positions.
.rx, .ry, and .rz are three rotation angles. The rotations are read-only. The rotation angles
are controlled by a rotation angle ordering value, the global rotOrder value, and a global
axisMode value. These are initialized to the SynthEyes Maya axis ordering and scene’s
coordinate axis mode settings: Z Up(0), Y Up(1), and Y Up Left(2).
.rowA, .ax, .ay, .az are the first row, and the three components of it.
.rowB, .bx, .by .bz are the second row, and the three components of it.
.rowC, .cx, .cy, .cz are the third row, and the three components of it.
.rowP, .px, .py, .pz are the fourth (position) row, and the three components of it (same as
.x, .y, and .z).
.angXYZ is a vector of the rotation angles, interpreted in the XYZ order, read-only.
.angZXY is the vector of rotation angles in ZXY order, read-only.
.angZYX is the vector of rotation angles in XYX order, read-only.
.inv is the inverse transform. (read-only)
.rot is a transform consisting only of the rotation portion. (read-only)
.trans returns an object that is the entire transform, when it is offered as an attribute. You
can pass it to a function, say, and then extract any of the attributes from it at that time.
If an object offers multiple transforms, each transform’s attribute names will have an
additional prefix, such as .wx or .wrz.
Operators: you can multiply transforms together, for example, posnew = oldpos *
wldtoobj * objtoref.

Vectors
A vector offers .x, .y, and .z attributes, or an offered vector can be taken whole with .vec.
Vectors can be created outright with Vector(x,y,z).
.length is the length of the vector (square root of the sum of x, y, and z, each squared).
(read-only).
.norm is the vector with the length normalized to one. (read-only)
.Dot(vector2) returns the dot product of this vector with vector2.
.Cross(vector2) returns the cross product of this vector with vector2.
When an object offers multiple vectors, each vector’s attribute names have a different
prefix, resulting in .wx, .wy, .wz or .ox, .oy, or .oz, for example.
Operators: +, -, *(scalar), *(transform), /(scalar)

Points
A vector offers .u, and .v attributes, or an offered vector can be taken whole with .pnt.
Points can be created outright with Point(u,v).
.length is the length of the vector (square root of the sum of u and v, each squared). (read-
only).
.norm is the vector with the length normalized to one. (read-only)
.Dot(vector2) returns the dot product of this vector with vector2.
When an object offers multiple vectors, each point’s attribute names have a different
prefix, resulting in .wu, .wv or .pu or .pv, for example.
Operators: +, -, *(scalar), /(scalar).

Generic Lists
You can create generic indexed lists of objects
Mylist = [1, 2, “buckle my shoe”]
and subsequently change or retrieve the components with Mylist[2], for example. You can tack
on additional items to the last slot, with Mylist[4] = 3, Mylist[5]=4, etc. It is an error to perform
Mylist[10] = “why?” because that would leave a hole.
You can create a new empty list to add items to
MyNewEmptyList = [ ]
You can also create associative lists with
Color[“apple”] = “red”
Color[“pear”] = “green”
You can access Color[2] as well, at this point.
#Color is the number of elements, 2 in this example
Color.keys is the list [“apple”, “pear”]. Note that there may be fewer keys than elements
in the list, if some elements have been added without keys, using numeric subscripts.
Color.index(“pear”) = 2, ie the index of a key in the list, or 0 if it cannot be found.

Function Calls
Sizzle has subroutine calls with parameters. Parameters are passed by value, meaning that
from within a subroutine, you can’t change any of the arguments of the caller. The order of
functions and calls within the file does not matter.
Simon(“right”)
function Simon(val)
“Simon says jump “ val “\n”
end

Simon(“up”)

Include Files
You can include libraries of code within SynthEyes scripts using the INCLUDE
operation, with the following syntax:
INCLUDE(“filename”)
There should be no whitespace between any of these elements. The INCLUDE does not
have to fall in column 1. Although it looks like a function call, it must be executed directly during
syntax parsing (like a C++ preprocessor), so the filename can not be an expression.
The filename can be absolute or relative. Absolute files names start with either kind of
slash, or with a drive specification such as C:. Relative file names can be plain filenames such as
mylib.szl, or may contain a relative path specification such as ../shared/mylib.szl or
./includes/mylib.szl. Any file extension can be used, though .szl is probably a good idea.
The included file does not have to include a standard Sizzle header such as //SIZZLET,
though it may. Any header line will be ignored, because it looks like a comment. Note that you
should not include //SIZZLEX export scripts, because they default as inline content, and will be
misinterpreted.
Includes can be nested as desired. There is an arbitrary maximum depth of 20 levels, to
catch runaway recursive includes.
Builtin Functions
printf(format, arguments….) Formatted Unix-style print to output or string. Supports
%c, %d, %x, %f, %g, %e, %s formats.
substr(string, start [, count]) If start is negative, measure from the end
index(look_in_here, for_this) Find first 2nd string in 1st, return zero if not found
rindex(look_in_here, for_this) Find last 2nd string in 1st, return zero if not found
length(string)
translate(string, from_chars, to_chars) Translate string, replacing each character in
from_chars to the corresponding character of to_chars
openout(filename) Start outputting to this file instead. WARNING: you
can clobber any file on your computer!
closeout() Close redirection, output to previous file instead
getline() Read a line from the current input file, returning a new-
line terminated string or an empty string on end-of-file.
scanf(format, arguments…) Read data from current input file. The arguments
should be variables or attributes that you might find on
the left hand side of an assignment (no & required).
Supports %s, %c, %d, %x, %f, %lf, %g, %lg, %[..] and
the ‘*’ assignment suppression. Returns the number of
variables assigned to.
sscanf(string, format, arguments…) Read data from a string, see scanf for details.
openinp(filename) Start reading this file (save read point in current file).
Returns 1/0 if OK/not.
closeinp() Stop reading current file, resume reading earlier file
DateTime(fmt) The current time and date in a user-selected format, see
the strftime function on the Microsoft site:
http://msdn.microsoft.com/library/default.asp?url=/libr
ary/en-
us/vccore98/HTML/_crt_strftime.2c_.wcsftime.asp For
example, "%a, %b %d, %Y %I:%M:%S %p" produces
“Tue, Feb 25, 2003 10:19:22 PM”
Message(msg) Pops up an informational dialog box
YesNoCancel(question) Asks the question, click buttons for “yes”, “no”or
“cancel”, which is returned from the function.
abs(x) or fabs(x) absolute value
sqrt(x) square root
sin(x) sine function
cos(x) cosine function
tan(x) tangent function
atan(x) arc-tangent function
atan(y, x) arc-tangent of y/x
log(x) logarithm function
exp(x) exponent function
pow(x,y) x to the y’th power
floor(x) largest integer less than x
ceil(x) smallest integer greater than x
round(x) nearest integer
typeof(x) A string giving x’s type: Double, String, etc
isNull(x) Returns 1 if x is a null (non-existant) object, 0 if it an
actual object
system(cmd [,dir]) Run the command cmd in a “DOS” command shell
using “cmd.exe /c”. If present, start in the directory dir,
which must include a drive name and full path if
present. Use double-backslashes as appropriate:
“C:\\temp”. WARNING: erroneous system
commands can damage or destroy any file in your
computer!

User Interfaces
You can use the Dialog object to display a user interface for your exporter, importer, or
tool. The user interface can consist of the usual checkboxes, buttons, data entry fields, etc. After
creating a dialog, you populate it with fields, show it, then access the data entered as attributes of
the dialog object. If the user cancels the displayed dialog, then entire script will be cancelled.
So that the user doesn’t have to keep on re-entering the same settings, each dialog’s final
entries are stored away and then restored when that dialog box is shown again. If the operation is
Export Again, the dialog box is not shown; the saved data is used instead. The script can cause
this data to be reset, potentially when the user hits a button, or always cause the dialog box to be
shown.
Most of the data-field-creating member function calls require an attribute name, which
can be used to access the value of the field after the dialog is shown, and a prompt string, which is
displayed in the user interface to explain what must be entered in the field. The attribute name
must be a valid SynthEyes identifier name, with no embedded spaces or special characters.
dlg = NewDialog(“uniqid”) Create a new dialog object. The uniqid must be unique
across ALL DIALOGS of ALL SCRIPTS on the user’s
system: it is used to identify the identify the settings of
this dialog for when it is re-opened later. It should be a
simple alphanumeric string related to the script name.
dlg.OpenFile(“attr”, “prompt”, “extn”) Create a data-entry field for a file name, presumably to
be read by the script (the file must exist). There will be
a browse button as well as a text field. The extn is the
default file-name extension to use. Note that it is up to
the script to actually read the file.
dlg.SaveFile(“attr”, “prompt”, “extn”) Create a data-entry field for a file name, presumably to
be written (the user must approve the over-write if the
file already exists).
dlg.Path(“attr”, “prompt”) Create a data-entry field for a path name.
dlg.String(“attr”, “prompt”, “defstr”) Create a text input field. The defstr value is its default
value when the dialog is first displayed, or after a reset
operation.
dlg.Info(“attr”, “prompt”, “info”) Create an unchangeable text input field. This can be
used to provide additional explanatory text to the user,
perhaps to show other information such as the number
of frames or image resolution.
dlg.Int(“attr”, “prompt”, minv, defv, maxv) Create an integer input field. The input will have
an initial value of defv, and must fall within the range
of minv to maxv.
dlg.Float(“attr”, “prompt”, minv, defv, maxv) Create a floating-point input field. The input will
have an initial value of defv, and must fall within the
range of minv to maxv.
dlg.Check(“attr”, “prompt”, defv) Create a checkbox. The defv controls its initial state,
and must be 0 or 1.
dlg.StartRadio(“overall_name”, “overall_prompt”) Start a group of radio buttons. The
overall_name attribute will be set to the name of the
attribute that is selected.
dlg.Radio(“attr”, “prompt”, defv) Create a radio button. Only one radio button must have
defv of 1, the rest should have defv of 0.
dlg.Button(“funcname”, “prompt”, “btn”) Create a push button. The button will be labeled
btn, and have a description of prompt. The funcname
will be called when the button is pushed.
dlg.Show() Display the assembled dialog and wait for user action.
If this is an Export Again, the dialog will not be
shown, but will have the saved settings. (See the
Always function.)
dlg.Reset() The dialog values are reset to the default values set by
the script, overriding previously-stored values. Can be
called during a pushbutton function evaluation.
dlg.Always() Causes the dialog to be shown even during Export
Again operations, when called before Show.
Here’s an example of a small settings panel.
dlg = NewDialog(“MyFavorite”)
dlg.String(“f1st”, “Start Frame”, 0, 0, shot.length)
dlg.Check(“abs”, “Use Absolute Coordinates”, 0)
dlg.StartRadio(“which”, “Trackers to Output”)
dlg.Radio(“all”, “All”, 1)
dlg.Radio(“sel”, “Only selected”, 0)
dlg.Button(“reset_dlg”, “Reset to defaults”, “Reset”)
dlg.Show()

only_sel = dlg.sel
bias = dlg.f1st

function reset_dlg()
dlg.Reset()
end
You can use several dialogs (and dialog objects) simultaneously within a single script, if
necessary.

Builtin Variables
frame // current frame number
rotOrder // rotation order, 1=xyz, 0=zxy
axisMode // Zup=0, Yup=1, Yupleft=2
Pi // 3.14159…
Sizzle Grammar Reference

prog → stmtlist
stmtlist → stmtlist stmt
stmtlist → stmt
stmt → for ( [expr] ; [expr] ; [expr] ) stmtlist end (expressions are optional)
stmt → while ( expr ) stmtlist end
stmt → for ( lhs in expr ) stmtlist end (each object in an object list)
stmt → break
stmt → continue
stmt → return
stmt → return expr
stmt → function ident ( idlist ) stmtlist end (function definition)
stmt → function ident ( ) stmtlist end
idlist → idlist , ident
idlist → ident
stmt → if ( expr ) stmtlist end
stmt → if ( expr ) stmtlist else stmtlist end
stmt → if ( expr ) stmtlist elseifs else stmtlist end
stmt → if ( expr ) stmtlist elseifs end
elseifs → elseifs elseif
elseifs → elseif
elseif → elsif ( expr ) stmtlist
elseif → elseif ( expr ) stmtlist
stmt → assop
stmt → boolor // Generating output...
stmt → ;
stmt → delete lhs
expr → expr assop
expr → expr boolor
expr → assop
expr → boolor
assop → lhs = boolor
assop → lhs += boolor
assop → lhs -= boolor
assop → lhs *= boolor
assop → lhs /= boolor
assop → lhs &= boolor
assop → lhs |= boolor
assop → lhs ^= boolor
boolor → boolor || booland
boolor → booland
booland → booland && boolnot
booland → boolnot
boolnot → ! relop
boolnot → relop
relop → addop < addop
relop → addop > addop
relop → addop == addop
relop → addop <= addop
relop → addop >= addop
relop → addop != addop
relop → addop
addop → addop + mulop (addition)
addop → addop - mulop (subtraction)
addop → addop | mulop (bitwise or)
addop → mulop
mulop → mulop * negop (multiplication)
mulop → mulop / negop (division)
mulop → mulop % negop (modulo)
mulop → mulop & negop (bitwise and)
mulop → mulop ^ negop (bitwise exclusive or)
mulop → mulop << negop (left binary shift)
mulop → mulop >> negop (right binary shift)
mulop → negop
negop → ~ powop (bitwise complement)
negop → - powop (negative)
negop → + powop (nothing, except strings converted to numbers)
negop → powop
powop → powop ** term (powerop to the auto power)
powop → term
auto → ++ lhs
auto → -- lhs
auto → lhs ++
auto → lhs --
term → ident ( arglist ) (function call)
term → ident ( ) (function call)
term → ( boolor ? expr : expr ) (select the 1st or 2nd expression, based on boolean)
term → string
term → number
term → lhs
lhs → ident (ident is an identifier, an alphanumeric starting with alpha)
lhs → lhs [ expr ] (select I’th element from an object list)
lhs → lhs . ident (select an attribute from an object)
lhs → lhs . $ ident
term → lhs . ident ( arglist ) (member function call)
term → lhs . ident ( ) (member function call)
term → ( expr )
term → [ arglist ] (create a list object from the expressions)
term → [ ] (create an empty list)
term → # term (number of objects in a list)
term → $ term (the object with the name given by term)
arglist → arglist , expr
arglist → expr

Você também pode gostar