The Ayam scripting interface consists of a number of Tcl procedures
and Tcl commands that are also used internally by the application.
For instance, the main menu entry "File/New"
calls the
scripting interface command "newScene"
(among other commands).
Using the Ayam scripting interface means to call these procedures
or commands, possibly in a mix with standard Tcl script code.
Furthermore, using Tcl and its introspection capabilities, the code Ayam consists of could easily be modified at runtime. This is, however, not recommended for good reasons (unless intimate knowledge about the Ayam source code is obtained first). 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 those procedures and commands may change in future versions of Ayam without notice.
In Tcl, all variables, procedures, and commands are case sensitive,
it really is "sL"
and not "sl"
and not
"SL"
.
The scripting interface may be used directly from the console
of Ayam. One can, of course, also put scripts in Tcl script files,
that may be loaded at any time into Ayam using
the console and the Tcl command "source"
.
Script files can also be made to run on every application startup
automatically using the preference setting
"Main/Scripts"
.
Moreover, on the X11 and Aqua window systems, Ayam is able to execute
script code sent via the Tk "send"
command or the AppleScript
"tell"
command from external applications.
In contrast to other modelling environments, in Ayam there is yet another way to run scripts. In Ayam, scripts may also be attached to Script objects and run when the notification mechanism updates the scene. See also section Script object. Even normal objects can trigger scripts upon notification using BNS or ANS tags. See also sections Before Notify Script and After Notify Script.
Note that most of the scripting interface commands listed in this
documentation work in the background, without changing anything to
the Ayam GUI and Ayam view windows, for the sake of execution speed.
To make any changes to the scene visible, the various parts of the GUI
(property GUIs, view windows) need to be updated explicitly
(see also section
Updating the GUI).
However, since Ayam 1.13 it is also possible to automatically run GUI
updating commands in the console with every issued command by
using <Shift+Return>
instead of <Return>
.
Also note that even though no updates of the GUI take place when using
the scripting interface, all notification processes are carried out
immediately regardless. The scene will be consistent and up to date
when the scripting interface command returns.
Scene changes from the scripting interface can also be recorded in the undo buffer, but this must be arranged manually too (see the documentation of the undo command: Undo).
From scripts it may be necessary to check whether an error occurred
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 "ay_error"
to a value higher than 1 if an error occurred. This variable needs to
be set to zero before and checked after the operation in question
to see whether the operation performed successfully, see the following
example:
proc myProc { } { set ::ay_error 0 copOb if { $::ay_error > 1 } { ayError 2 "myProc" "Error copying object!" } }
Several global variables and arrays exist in the Ayam Tcl context, that may be useful for scripts.
The global variable "ay_error"
holds the current error state.
See also section
Reporting Errors.
The global variable "i"
is used by all "forAll"
command variants. See also section
Applying Commands to a Number of Objects.
The global variables "u"
and "v"
are set by the
find u/uv actions. See also sections
Finding Points on Curves and
Finding Points on Surfaces.
The global array "ay"
holds application state variables.
Furthermore, the paths to important widgets can be found
(e.g. the tree widget for the object hierarchy or the currently
active view) in this array.
Use "parray ay"
in the console to see what is there.
More documentation to come.
The global array "ayprefs"
holds preferences data.
The complete array is saved in the ayamrc file upon exit,
so be careful when adding new elements to this array.
See also section
Ayamrc File.
Use "parray ayprefs"
in the console to see what is there.
More documentation to come.
Note that changes to this array on the Tcl side do not immediately
take effect as the data needs first to be transferred to the C context
using the "setPrefs"
command.
See also section
Managing Preferences.
The global array "aymark"
holds a copy of the current mark position.[∗]
It is updated whenever the mark is set using e.g. the
set mark action (see section
Setting the Mark).
Manual changes to this array have no effect on the mark.
For every object type, a corresponding global variable exists,
that contains the property names of this object type as a list.
The variable name is just the object type name followed
by _props
(for properties).
For example for the NCurve object type, this variable is named
"NCurve_props"
and the list it contains looks like this:
{ Transformations Attributes Tags NCurveAttr }
This list is consulted each time a single object is selected in the tree
view or object list widget and its content is used to populate the properties
listbox widget. See also section
Properties.
Note that the list can be further manipulated
by "NP"
and "RP"
tags of the selected object.
For every property, a corresponding global array exists, where the property is managed. For the Transformations property, this array looks like this:
Transformations { arr transfPropData sproc setTrafo gproc getTrafo w fTrafoAttr }
"arr"
, designates the name of the global property
data array (thus, transformation data is stored in an array called
"transfPropData"
).
This array only holds useful data when it has been filled explicitly
by the so called get-property callback.
The entries "sproc"
and "gproc"
designate the set-property and
get-property callbacks (procedures or commands).
Those are called, when the "Apply"
button is used or the
property is selected in the properties listbox respectively.
If sproc or gproc are empty strings (""
), standard callbacks
named "setProp"
or "getProp"
will/should be used to get
or set the property values.
But for the Transformations property, the "setTrafo"
and
"getTrafo"
commands should be used.
The flexibility gained by individual sproc/gproc procedures is used to
sanitize user input, run additional GUI update code or realize dynamic
property GUIs.
The last entry, "w"
, is the name of the main property GUI window.
To get the full, usable, widget path of this window, the current value of the
array entry "ay(pca)"
needs to be prepended:
$ay(pca).$Transformations(w)
.
Note that for many object types the property variable and the
object type specific property management arrays only exist after an
object type specific initialization procedure, derived from the
type name, is called, e.g. "init_Box"
.
Those types are:
ACurve, Bevel, Birail1, Birail2, Box, BPatch, Cap, ConcatNC, ConcatNP,
Cone, Cylinder, Disk, ExtrNC, ExtrNP, Hyperboloid, ICurve, IPatch,
NCircle, OffsetNC, OffsetNP, PatchMesh, Paraboloid, Revolve, RiInc,
RiProc, Script, SDMesh, Select, Sphere, Sweep, Swing, Torus, and Trim.
Since Ayam 1.16, the global property management array may be created
easily using the new scripting interface command "addPropertyGUI"
.
See also section
Property GUI Management.
The following global arrays and callbacks to get or set the data exist:
property | array | get-property callback | set-property callback |
Transformations | transfPropData | getTrafo | setTrafo |
Attributes | attrPropData | getAttr | setAttrp |
Material | matPropData | getMat | setMat |
Tags | tagsPropData | getTagsp | setTagsp |
MaterialAttr | MaterialAttrData | "" | setMaterialAttrp |
Surface | ay_shader | shader_getSurf | shader_setSurf |
Displacement | ay_shader | shader_getDisp | shader_setDisp |
Interior | ay_shader | shader_getInt | shader_setInt |
Exterior | ay_shader | shader_getExt | shader_setExt |
Light | ay_shader | light_getShader | light_setShader |
LightAttr | LightAttrData | light_getAttr | "" |
ViewAttrib | ViewAttribData | "" | setViewAttr |
Camera | CameraData | "" | setCameraAttr |
NCurveAttr | NCurveAttrData | "" | "" |
NPatchAttr | NPatchAttrData | "" | "" |
ICurveAttr | ICurveAttrData | "" | "" |
NCircleAttr | NCircleAttrData | "" | "" |
Note that this list is pretty much incomplete, however the information
can always be inferred easily using the "parray"
command in the Ayam
console:
» parray NCurveAttr
See also section
Manipulating Properties
for more information on how to edit property values from the
scripting interface.
This section provides documentation on the most important scripting interface procedures and commands of Ayam sorted by category.
Note that the "help"
command in the Ayam console can be used
to directly jump to the appropriate sub-section of this part of
the documentation.
All procedures and commands are documented in the following scheme:
"command param1 param2 [optionalparam1]"
(syntax of the command and its parameters),"command 1 2"
(example application of the command
with explanation of expected results).Since Ayam 1.8.2 a scripting interface command named "help"
is available,
that displays the help of scripting interface commands using a web
browser (similar to the "Help on Object"
feature):
"help command"
"help help"
displays the help of the help procedure.
To create new objects the "crtOb"
command can be used.
"crtOb type [args]"
"crtOb"
,
"type"
may be derived from the object type names, as displayed in the
tree view.
The new object will be created and linked to the scene as last object
in the current level, no part of the GUI (object selection widget, property
GUI, views) will be updated. Furthermore, the new object will not
be selected.
Depending on the type, further arguments may (or have to) be given; some object types expect other objects to be selected upon creation.
All arguments consist of a option name part and a value part (i.e. it is
"-center 1"
and not "-center"
and also not
"-center=1"
).
The option names can be abbreviated. Useful default and fallback
values exist (see below). The arguments can be mixed freely (their
order is not important) and repeated. If arguments are repeated, only the
last set value is used, even if this leads to errors and application of
fallback values later on.
Here is a comprehensive list of available arguments sorted by object type:
"NCurve"
: NURBS curves accept the following
arguments:
"-length"
: length of the new curve, the length defaults to 4."-order"
: order of the new curve, the order defaults to 4.
If a value greater than the length is specified, the order will be made
identical to the length value."-kt"
: the knot type of the new curve, must be one of
0 – Bezier, 1 – BSpline, 2 – NURB, 3 – Custom,
4 – Chordal, 5 – Centripetal.
A knot vector of specified type will automatically be created.
The knot type defaults to 2 – NURB.
If a custom knot vector is specified using the "-kv"
option below,
the knot type will always be set to 3 – Custom.
"-kv"
: the knot vector of the new curve. The value of this
option is a list of floating point numbers of length curve length plus
curve order, e.g. for a curve with 2 control points and order 2, specify
4 knots: "-kv {0.0 0.0 1.0 1.0}"
. The knot vector defaults to
an automatically created knot vector of the type specified by the
"-kt"
option above.
"-kn"
: the knot vector of the new curve. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-kv"
option
above.
"-cv"
: the control vector of the new curve. The value of this
option is a list of floating point numbers that describe the 4D euclidean
rational (weight not multiplied in) coordinates of the control
points."-cv {0.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 2.0 0.0 0.0 1.0}"
.
"-cn"
: the control vector of the new curve. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-dx"
: the value of this option specifies the distance
of automatically created control points in the x dimension, default is 0.25.
"-dy"
: the value of this option specifies the distance
of automatically created control points in the y dimension, default is 0.0.
"-dz"
: the value of this option specifies the distance
of automatically created control points in the z dimension, default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new curve will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"-createmp"
: The "-createmp"
option toggles creation
of multiple points. The default value is 0."crtOb NCurve"
"crtOb NCurve -center 1"
"crtOb NCurve -length 5 -center 1 -dx 0.5"
In versions of Ayam prior to 1.17, NURBS curves only accepted the
"-length"
argument.
See also section NCurve Object.
"ICurve"
: Interpolating curves accept the following
arguments:
"-type"
: the type of the new curve, must be one of
0 – Open, 1 – Closed; default is 0.
"-length"
: length (number of data points to interpolate)
of the new curve; the length defaults to 4.
"-order"
: order of the new curve, the order defaults to 4.
If a value greater than the length is specified, the order will be made
identical to the length value.
"-pt"
: the parameter type of the new curve, must be one of
0 – Chordal, 1 – Centripetal, 2 – Uniform; default is 0.
"-cv"
: the control vector of the new curve. The value of this
option is a list of floating point numbers that describe the 3D
(non rational) coordinates of the control points. This list may also
only specify one point, which is then taken as starting point and
DX/DY/DZ (see below)
are used to create the missing control points automatically.
To specify a complete
control vector, this list should have curve length × 3
elements, e.g. for a curve of length 3, specify 9 values:
"-cv {0.0 0.0 0.0 1.0 0.0 0.0 2.0 0.0 0.0}"
.
"-cn"
: the control vector of the new curve. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-dx"
: the value of this option specifies the distance
of automatically created control points in the x dimension, default is 0.25.
"-dy"
: the value of this option specifies the distance
of automatically created control points in the y dimension, default is 0.0.
"-dz"
: the value of this option specifies the distance
of automatically created control points in the z dimension, default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new curve will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"-derivs"
: the value of this option controls whether
user defined end derivatives should be used: 0 – no, 1 – yes,
default is 0.
"-sdlen"
: the value of this option specifies the
relative length (in relation to the distance of the first and second
control point) of the start derivative, default is 0.125.
"-sderiv"
: is the start derivative, specified as
a list of three float values. The derivative is specified relative to the
first control point. The start derivative defaults to an automatically created
derivative of a direction taken from the first two control points
and length specified by the "-sdlen"
option.
"-edlen"
: the value of this option specifies the
relative length (in relation to the distance of the second to last and last
control point) of the end derivative, default is 0.125.
"-ederiv"
: is the end derivative, specified as
a list of three float values. The derivative is specified relative to the
last control point. The end derivative defaults to an automatically created
derivative of a direction taken from the last two control points
and length specified by the "-edlen"
option.
"crtOb ICurve"
"crtOb ICurve -l 5 -sderiv {0.0 -0.5 0.0} -ederiv {0.0 -0.5 0.0} -derivs 1 -center 1"
In versions of Ayam prior to 1.17, interpolating curves only accepted the
"-length"
argument.
See also section ICurve Object.
"ACurve"
: Approximating curves accept the following
arguments:
"-type"
: the type of the new curve, must be one of
0 – Open, 1 – Closed; default is 0.
"-length"
: length (number of data points to approximate)
of the new curve, the length defaults to 4.
"-alength"
: number of NURBS control points to use for the
approximating curve, must be smaller than the length above;
this parameter defaults to length-1.
"-order"
: order of the new curve, the order defaults to 3.
If a value greater than the output length is specified, the order will be made
identical to the output length value. Currently, only values larger than
2 are supported.
"-symmetric"
: toggles creation of symmetric curves,
must be one of 0 – Asymmetric, 1 – Symmetric; default is 0.
"-cv"
: the control vector of the new curve. The value of this
option is a list of floating point numbers that describe the 3D
(non rational) coordinates of the control points. This list may also
only specify one point, which is then taken as starting point and
DX/DY/DZ (see below)
are used to create the missing control points automatically.
To specify a complete
control vector, this list should have curve length × 3
elements, e.g. for a curve of length 3, specify 9 values:
"-cv {0.0 0.0 0.0 1.0 0.0 0.0 2.0 0.0 0.0}"
.
"-cn"
: the control vector of the new curve. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-dx"
: the value of this option specifies the distance
of automatically created control points in the x dimension, default is 0.25.
"-dy"
: the value of this option specifies the distance
of automatically created control points in the y dimension, default is 0.0.
"-dz"
: the value of this option specifies the distance
of automatically created control points in the z dimension, default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new curve will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"crtOb ACurve -length 6"
"crtOb ACurve -l 5 -center 1"
In versions of Ayam prior to 1.17, approximating curves only accepted the
"-length"
argument.
See also section ACurve Object.
"NPatch"
: NURBS patches accept the following
arguments:
"-width"
: width of the new patch, the width defaults to 4."-height"
: height of the new patch, the height defaults to 4."-uorder"
: order of the new patch in U parametric dimension,
the order defaults to 4. If a value greater than the width is specified,
the order will be made identical to the width value."-ukt"
: the U knot type of the new patch, must be one of
0 – Bezier, 1 – BSpline, 2 – NURB, 3 – Custom,
4 – Chordal, 5 – Centripetal.
A knot vector of specified type will automatically be created.
The knot type defaults to 2 – NURB.
If a custom knot vector is specified using the "-ukv"
option below,
the knot type will always be set to 3 – Custom."-ukv"
: the U knot vector of the new patch. The value of this
option is a list of floating point numbers of length width plus
patch U order, e.g. for a patch with width 2 and U order 2, specify
4 knots: "-ukv {0.0 0.0 1.0 1.0}"
. The knot vector defaults to
an automatically created knot vector of the type specified by the
"-ukt"
option above.
"-un"
: the U knot vector of the new patch. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-ukv"
option
above.
"-vorder"
: order of the new patch in V parametric dimension,
the order defaults to 4. If a value greater than the height is specified,
the order will be made identical to the height value."-vkt"
: the V knot type of the new patch, must be one of
0 – Bezier, 1 – BSpline, 2 – NURB, 3 – Custom,
4 – Chordal, 5 – Centripetal.
A knot vector of specified type will automatically be created.
The knot type defaults to 2 – NURB.
If a custom knot vector is specified using the "-vkv"
option below,
the knot type will always be set to 3 – Custom."-vkv"
: the V knot vector of the new patch. The value of this
option is a list of floating point numbers of length height plus
patch V order, e.g. for a patch with height 2 and V order 2, specify
4 knots: "-vkv {0.0 0.0 1.0 1.0}"
. The knot vector defaults to
an automatically created knot vector of the type specified by the
"-vkt"
option above.
"-vn"
: the V knot vector of the new patch. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-vkv"
option
above.
"-cv"
: the control vector of the new patch. The value of this
option is a list of floating point numbers that describe the 4D euclidean
rational (weight not multiplied in) coordinates of the control
points.
This list may also only specify one point, which is then taken as starting
point and UDX/UDY/UDZ and VDX/VDY/VDZ (see below) are used to create the
missing control points automatically.
To specify a complete control vector, this list should have
width × height × 4 elements,
e.g. for a patch of width 2 and height 2, specify 16 values:
"-cv {0.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 2.0 0.0 0.0 1.0 2.0 1.0 0.0 1.0}"
.
"-cn"
: the control vector of the new patch. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-udx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a row (U parametric dimension, along width), default is 0.25.
"-udy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-udz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-vdx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-vdy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a column (V parametric dimension, along height), default is 0.25.
"-vdz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new patch will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"-createmp"
: The "-createmp"
option toggles creation
of multiple points. The default value is 0."crtOb NPatch"
"crtOb NPatch -vdy 0 -vdz 0.25"
"crtOb NPatch -udy 0.25"
"crtOb NPatch -udy 0.25 -vdz 0.25"
"crtOb NPatch -width 2 -height 2 -center 1 -udx 2 -vdy 2"
"crtOb NPatch -width 3 -height 2 -uorder 2 -cv {-1 0 1 1 1 0 1 1 -1 0 0 1 1 0 0 1 -1 1 0 1 1 1 0 1}"
-uorder 2
to get
a smooth shape).In versions of Ayam prior to 1.17, NURBS patches only accepted the
"-width"
and "-height"
argument.
See also section NPatch Object.
"IPatch"
: Interpolating patches accept the following
arguments:
"-width"
: width of the new patch, the width defaults to 4."-height"
: height of the new patch, the height defaults to 4."-uorder"
: order of the new patch in U parametric dimension,
the order defaults to 4. If a value greater than the width is specified,
the order will be made identical to the width value.
A value of 0 switches off interpolation along U."-ukt"
: the U parameterisation type, must be one of
0 – Chordal (default), 1 – Centripetal, 2 – Uniform."-vorder"
: order of the new patch in V parametric dimension,
the order defaults to 4. If a value greater than the height is specified,
the order will be made identical to the height value.
A value of 0 switches off interpolation along V."-vkt"
: the V parameterisation type, must be one of
0 – Chordal (default), 1 – Centripetal, 2 – Uniform.
"-deriv_u"
: the end derivative mode for U, must be one of
0 – None (default), 1 – Automatic, or 2 – Manual.
In manual mode full derivative vectors must be provided via
"-ederiv_u"
and "-sderiv_u"
."-edlen_u"
: the length of automatically calculated end
derivatives at end of patch in U (default 0.125)."-sdlen_u"
: the length of automatically calculated end
derivatives at start of patch in U (default 0.125)."-ederiv_u"
: end derivatives for U at end of patch.
The value of this option is a list of 3 × height
floating point numbers.
There is no default value."-sderiv_u"
: end derivatives for U at start of patch.
The value of this option is a list of 3 × height
floating point numbers.
There is no default value.
"-deriv_v"
: the end derivative mode for V, must be one of
0 – None (default), 1 – Automatic, or 2 – Manual.
In manual mode full derivative vectors must be provided via
"-ederiv_v"
and "-sderiv_v"
."-edlen_v"
: the length of automatically calculated end
derivatives at end of patch in V (default 0.125)."-sdlen_v"
: the length of automatically calculated end
derivatives at start of patch in V (default 0.125)."-ederiv_v"
: end derivatives for V at end of patch.
The value of this option is a list of 3 × width
floating point numbers.
There is no default value."-sderiv_v"
: end derivatives for V at start of patch.
The value of this option is a list of 3 × width
floating point numbers.
There is no default value.
"-cv"
: the control vector of the new patch. The value of this
option is a list of floating point numbers that describe the 3D
non rational coordinates of the data points to be interpolated."-cv {0.0 0.0 0.0 1.0 0.0 0.0 2.0 0.0 0.0 2.0 1.0 0.0}"
.
"-cn"
: the control vector of the new patch. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-udx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a row (U parametric dimension, along width), default is 0.25.
"-udy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-udz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-vdx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-vdy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a column (V parametric dimension, along height), default is 0.25.
"-vdz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new patch will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"crtOb IPatch"
"crtOb IPatch -vdy 0 -vdz 0.25"
"crtOb IPatch -udy 0.25"
"crtOb IPatch -udy 0.25 -vdz 0.25"
"crtOb IPatch -width 3 -height 3 -center 1 -udx 2 -vdy 2"
See also section IPatch Object.
"APatch"
: Approximating patches accept the following
arguments:
"-mode"
: the value of this option specifies the approximation
mode, it must be one of 0 - UV, 1 - VU, 2 - U, or 3 - V."-width"
: number of data points in U direction, the width defaults to 4."-height"
: number of data points in V direction, the height defaults to 4."-awidth"
: desired width of the NURBS patch approximating
the data points, defaults to 3.
This value must be <= the width."-aheight"
: desired height of the NURBS patch approximating
the data points, defaults to 3.
This value must be <= the height."-uorder"
: order of the new patch in U parametric dimension,
the order defaults to 3. If a value greater than awidth is specified,
the order will be made identical to the awidth value."-ukt"
: the U parameterisation type, must be one of
0 – Chordal (default), 1 – Centripetal."-vorder"
: order of the new patch in V parametric dimension,
the order defaults to 3. If a value greater than aheight is specified,
the order will be made identical to the aheight value."-vkt"
: the V parameterisation type, must be one of
0 – Chordal (default), 1 – Centripetal.
"-cv"
: the control vector of the new patch. The value of this
option is a list of floating point numbers that describe the 3D
non rational coordinates of the data points to be approximated."-cn"
: the control vector of the new patch. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-udx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a row (U parametric dimension, along width), default is 0.25.
"-udy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-udz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-vdx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-vdy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a column (V parametric dimension, along height), default is 0.25.
"-vdz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new patch will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"crtOb APatch"
"crtOb APatch -vdy 0 -vdz 0.25"
"crtOb APatch -udy 0.25"
"crtOb APatch -udy 0.25 -vdz 0.25"
"crtOb APatch -width 3 -height 3 -center 1 -udx 2 -vdy 2"
See also section APatch Object.
"PatchMesh"
: patch meshes accept the following
arguments:
"-type"
: type of the new patch mesh, must be one of
0 – bilinear or 1 – bicubic, defaults to 1.
"-width"
: width of the new patch, the width defaults to 4.
Valid values for bicubic patch meshes depend on closedness and step size
in the U direction. See also the discussion in
section
PatchMeshAttr Property."-height"
: height of the new patch, the height defaults to 4.
Valid values for bicubic patch meshes depend on closedness and step size
in the V direction. See also the discussion in
section
PatchMeshAttr Property.
"-closeu"
: determines, whether the patch mesh is closed in
U direction; must be either 0 – open (default) or 1 – closed."-closev"
: determines, whether the patch mesh is closed in
V direction; must be either 0 – open (default) or 1 – closed.
"-ubt"
: the U basis type, must be one of
0 – Bezier (default), 1 – B-Spline, 2 – Catmull-Rom,
3 – Hermite, 4 – Power, 5 – Custom."-vbt"
: the V basis type, must be one of
0 – Bezier (default), 1 – B-Spline, 2 – Catmull-Rom,
3 – Hermite, 4 – Power, 5 – Custom.
"-ubasis"
: the U basis; must be 16 float values in
column major order. If set, the U basis type will automatically set
to Custom and the step size should be specified (if different from 3).
"-ubn"
: the U basis. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-ubasis"
option
above.
"-vbasis"
: the V basis; must be 16 float values in
column major order. If set, the V basis type will automatically set
to Custom and the step size should be specified (if different from 3).
"-vbn"
: the V basis. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-vbasis"
option
above.
"-ustep"
: the U basis step size; must be 1, 2, 3, or 4.
Can be omitted for all non custom basis types."-vstep"
: the V basis step size; must be 1, 2, 3, or 4.
Can be omitted for all non custom basis types.
"-cv"
: the control vector of the new patch mesh. The value of this
option is a list of floating point numbers that describe the 3D
rational coordinates of the control points."-cv {0.0 0.0 0.0 1.0 1.0 0.0 0.0 1.0 2.0 0.0 0.0 1.0 2.0 1.0 0.0 1.0}"
.
"-cn"
: the control vector of the new patch mesh. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-udx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a row (U parametric dimension, along width), default is 0.25.
"-udy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-udz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a row (U parametric dimension, along width), default is 0.0.
"-vdx"
: the value of this option specifies the distance
of automatically created control points in the x dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-vdy"
: the value of this option specifies the distance
of automatically created control points in the y dimension between points
in a column (V parametric dimension, along height), default is 0.25.
"-vdz"
: the value of this option specifies the distance
of automatically created control points in the z dimension between points
in a column (V parametric dimension, along height), default is 0.0.
"-center"
: If the value of the "-center"
option is 1,
the new patch will be centered. The default value is 0, no centering.
This option is only in effect if no "-cv"
option is specified.
"crtOb PatchMesh"
"crtOb PatchMesh -vdy 0 -vdz 0.25"
"crtOb PatchMesh -udy 0.25"
"crtOb PatchMesh -udy 0.25 -vdz 0.25"
"crtOb PatchMesh -type 0 -width 3 -height 3 -center 1 -udx 2 -vdy 2"
See also section PatchMesh Object.
"PolyMesh"
: Polygonal meshes accept the following
arguments:
"-polys"
: the value of this option specifies the number of
polygons/faces in the mesh. The number of polygons defaults to 0.
"-loops"
: the value of this option specifies the number of
loops per polygon. It is therefore a list of positive integer values of a
length equal to the value of the "-polys"
option. The default value
of this option is a list of proper length with all elements set to 1
(only normal polygons, without holes, are specified).
"-nverts"
: the value of this option specifies the number of
vertices per loop. It is therefore a list of positive integer
values of a length equal to the sum of all elements of the "-loops"
option.
The default value of this option is a list of proper length with all
elements set to 3 (only triangles are in the mesh).
"-iverts"
: the value of this option specifies all the (zero
based) indices of the vertices of all loops. It is therefore a list of
integer values of a length equal to the sum of all elements of the
"-nverts"
option.
The default value of this option is a list of proper length with the
elements set to a sequence of integers so that the control points are
used in the same order as specified via the "-cv"
option
(0, 1, 2, 3, ...).
"-cv"
: the control points of the new mesh. The value of this
option is a list of floating point numbers that describe the 3D
(non rational) coordinates of the control
points. The indices specified via the "-iverts"
option point to
this list. If the "-vnormals"
option is 1, also vertex normals are
specified in this list (directly following the coordinate values of each
control point) and stride is 6, otherwise stride is 3.
This list must have a length of stride by the highest value in
the list provided via the "-iverts"
option.
The default value of this option is an empty list, this implies that this
option must be specified to create a non-empty PolyMesh object.
"-cn"
: the control points of the new mesh. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-vnormals"
: determines whether vertex normals are present.
The default value is 0 – no vertex normals are present.
"crtOb PolyMesh -p 1 -cv {0 0 0 1 0 0 0 1 0}"
"crtOb PolyMesh -p 2 -cv {0 0 0 1 0 0 1 1 0 0 1 0} -iv {0 1 2 0 2 3}"
"crtOb PolyMesh -p 3 -cv {0 0 0 1 0 0 1 1 0 0 1 0 1.5 0 0 1.5 1 0} -iv {0 1 2 0 2 3 1 4 5 2} -nv {3 3 4}"
"crtOb PolyMesh -p 1 -loops {2} -cv {0 0 0 1 0 0 0 1 0 .25 .25 0 .5 .25 0 .25 .5 0}"
"SDMesh"
: Subdivision meshes accept the following
arguments:
"-scheme"
: the value of this option specifies the subdivision
scheme, it may be set to 0 – Catmull-Clark or 1 – Loop only.
Default is 0.
"-faces"
: the value of this option specifies the number of
faces in the mesh. The number of faces defaults to 0.
"-nverts"
: the value of this option specifies the number of
vertices per face. It is therefore a list of positive integer
values of a length equal to the number of faces.
The default value of this option is a list of proper length with all
elements set to 3 (only triangles are in the mesh).
"-verts"
: the value of this option specifies all the (zero
based) indices of the vertices of all faces. It is therefore a list of
integer values of a length equal to the sum of all elements of the
"-nverts"
option.
The default value of this option is a list of proper length with the
elements set to a sequence of integers so that the control points are
used in the same order as specified via the "-cv"
option
(0, 1, 2, 3, ...).
"-cv"
: The value of this option is a list of floating point
numbers that describe the 3D (non rational) coordinates of the control
points. The indices specified via the "-verts"
option point to
this list.
This list must have a length of 3 multiplied by the highest value in
the list provided via the "-verts"
option.
The default value of this option is an empty list, this implies that this
option must be specified to create a non-empty SDMesh object.
"-cn"
: the control points of the new mesh. The value of
this option is a variable name (with optional array and namespace specifier).
The value of this variable must be compatible to the "-cv"
option
above.
"-tags"
: the value of this option specifies a number of tags.
It is therefore a list of positive integer values of arbitrary length.
The only allowed values are 0 – hole, 1 – corner,
2 – crease, and 3 – interpolateboundary.
The default value of this option is an empty list: no tags.
"-args"
: the value of this option specifies the number of
integer and floating point arguments per tag.
It is therefore a list of positive integer values of length:
double number of tags. The even entries specify the number of integer and
the odd entries the number of floating point arguments per tag.
The content of this list is partially dictated by the "-tags"
option, e.g. a crease entry has at least two integer arguments and one
floating point argument.
The default value of this option is list of proper length, with all
elements set to zero (no tags have any arguments).
"-intargs"
: the value of this option specifies the
integer arguments of all tags.
It is therefore a list of integer values of length
sum of all even elements given by the "-args"
option.
"-doubleargs"
: the value of this option specifies the
floating point arguments of all tags.
It is therefore a list of double values of length
sum of all odd elements given by the "-args"
option.
"crtOb SDMesh -f 4 -v {0 1 3 1 2 3 0 3 2 0 2 1} -cv {0 0 0 1 0 0 0 0 -1 0.5 1 -0.5}"
"crtOb SDMesh -f 4 -v {0 1 3 1 2 3 0 3 2 0 2 1} -cv {0 0 0 1 0 0 0 0 -1 0.5 1 -0.5} -tags {1} -args {1 1} -intargs {0} -doubleargs {3.0}"
"crtOb SDMesh -f 4 -v {0 1 3 1 2 3 0 3 2 0 2 1} -cv {0 0 0 1 0 0 0 0 -1 0.5 1 -0.5} -tags {1} -args {2 1} -intargs {0 1} -doubleargs {10.0}"
"Script"
: Script objects accept the following
arguments:[∗]
"-type"
: the value of this option specifies the script
type, it may be set to "run"
, "modify"
, or
"create"
(without quotes) only.
"-active"
: the value of this option specifies whether
to activate the script immediately or not. It may be set to
"yes"
, "no"
, 0, or 1.
"-script"
: the value of this option is the script code
itself.
"-file"
: the value of this option is the full path and
file name of a script to load into the new Script object.
"Level"
: these objects can be given an
additional type argument, this argument
may be one of:
"0"
(level – default), "1"
(union), "2"
(intersection),
"3"
(difference), or "4"
(primitive).
Examples:
"crtOb Level"
"crtOb Level 3"
See also section Level Object.
"Material"
: Materials must be given an additional
argument giving the name of the new material.
If a material with the chosen name already exists, no object will be created.
Example:
"crtOb Material Wood"
See also section Material Object.
"Instance"
: creates an instance of the selected object.
Example:
"crtOb Sphere; selOb -1; crtOb Instance"
See also section Instance Object.
"crtOb Sphere; uS; rV"
.
The following helper commands, create certain often used
curves:
crtNCircle – create NURBS circle:
"crtNCircle [-r radius] [-a arc]"
-r
option and arc as
defined via the -a
option. The curve always starts on the
positive X-axis. The radius defaults to 1.0 and
the arc to 360.0. The arc option supports negative values.
See also section NURB Circle Tool.
crtNParabola – create a parabola:
"crtNParabola [-ymin ymin] [-ymax ymax] [-rmax r]"
crtNHyperbola – create a hyperbola:
"crtNHyperbola [-ymin ymin] [-ymax ymax] [-a a] [-b b]"
crtNConicArc – create a conic arc:
"crtNConicArc -p0 p0 -t0 t0 -p2 p2 -t2 t2 -p1 p1 [-k]"
-k
, for
keep_zero_weights, is present. However, these infinite control points are
not supported by the majority of NURBS processing algorithms in Ayam and
curves/surfaces employing them do not display correctly using any of the
GLU NURBS display modes."crtNConicArc -p0 {-1 0 0} -t0 {0 1 0} -p2 {1 0 0} -t2 {0 -1 0} -p1 {0 1 0}"
.
crtClosedBS – create closed (circular) B-Spline:
"crtClosedBS [-s sections] [-o order] [-a arc] [-r radius]"
See also section Circular B-Spline Tool.
crtNRect – create a rectangular NURBS curve:
"crtNRect [-w width] [-h height]"
crtTrimRect – create a rectangular bounding trim curve:
"crtTrimRect"
"CreateAt"
and "CreateIn"
options are ignored.
See also section TrimRect Tool.
The following helper commands create certain often used surfaces:
"crtNSphere [-radius r]"
crtNCylinder – create a cylinder:
"crtNCylinder [-height h] [-radius r]"
"crtNCone [-height h] [-radius r]"
"crtNDisk [-radius r]"
"crtNTorus [-minorradius minr] [-majorradius majr]"
crtNParaboloid – create a paraboloid:
"crtNParaboloid [-ymin ymin] [-ymax ymax] [-rmax rmax]"
crtNHyperboloid – create a hyperboloid:
"crtNHyperboloid [-ymin ymin] [-ymax ymax] [-a a] [-b b]"
"delOb"
These commands help to inquire objects about various aspects.
"getType [varname]"
varname
argument.
The types are the well known strings that are displayed in the hierarchy
list box if the objects are not named (NPatch, NCurve, Sphere, etc.).
If no variable name is specified the command returns the respective result(s).[∗]
If multiple objects are selected, a list is returned."getName [-s] [varname]"
varname
argument. If the object has no name, a warning message will be
emitted (unless the option "-s"
is given).
If no variable name is specified the command returns the respective result(s).[∗]
If multiple objects are selected, a list is returned."hasChild"
1
if the selected object
has child objects, otherwise 0
is returned. If multiple objects are
selected, a list is returned."hasMat"
1
if the selected object
has a material assigned, otherwise 0
is returned. If multiple objects are
selected, a list is returned."hasRefs"
1
if the selected object
has references (e.g. it is a master), otherwise 0
is returned.
If multiple objects are selected, a list is returned."candelOb"
1
if the selected object(s)
can be deleted without errors and without moving objects to the end of
the current level, otherwise 0
is returned.
hasTrafo – has transformations:
"hasTrafo [-r
|
-s
|
-t]"
1
if the selected object
has non-default transformation attributes, otherwise 0
is returned.
If multiple objects are selected, a list is returned."-r"
flag is provided, the command only checks the rotation
attributes."-s"
flag is provided, the command only checks the scale
attributes."-t"
flag is provided, the command only checks the translation
attributes."isCurve"
1
if the selected object
is (or provides / converts to) a parametric curve, otherwise
0
is returned.
If multiple objects are selected, a list is returned."isSurface"
1
if the selected object
is (or provides / converts to) a parametric surface, otherwise
0
is returned.
If multiple objects are selected, a list is returned."getBB"
getPlaneNormal – get the plane normal of an object:
"getPlaneNormal [-t]"
"-t"
is given, the normal will be transformed
by the objects transformation attributes.
If the object is not planar, a mean normal will be computed. If the normal can not be computed because e.g. the selected curve is a straight line or degenerate the returned vector will be 0.0, 0.0, 0.0.
This command supports arbitrary object types that just need to provide their points.
"isClosed [-u
|
-v]"
1
if the selected object
is a closed parametric curve or surface,
otherwise 0
is returned.[∗]
The optional parameter "-u"
/"-v"
determines which dimension
of a surface to check.
If multiple objects are selected, a list is returned.
This command supports arbitrary object types that just need to provide NURBS curves or surfaces.
"crtOb NCurve; selOb -1; isClosed"
"0"
,"crtOb NCircle; selOb -1; isClosed"
"1"
.
isPlanar – check for planarity:
"isPlanar"
1
if the selected object
is a planar parametric curve or surface,
otherwise 0
is returned.[∗]
If multiple objects are selected, a list is returned.
This command supports arbitrary object types that just need to provide NURBS curves or surfaces.
isDegen – check for degeneracy:
"isDegen"
1
if the selected object
is a degenerated parametric curve (point shape) or surface (point or line
shape), otherwise 0
is returned.[∗]
If multiple objects are selected, a list is returned.
This command supports arbitrary object types that just need to provide NURBS curves or surfaces.
"crtOb NCurve; selOb -1; isDegen"
"0"
,"crtOb NCurve -dx 0; selOb -1; isDegen"
"1"
."isParent"
1
if the selected object
is a potential parent, otherwise 0
is
returned.[∗]
If multiple objects are selected, a list is returned."crtOb NCurve; selOb -1; isParent"
"0"
,"crtOb NPatch; selOb -1; isParent"
"1"
."isTrimmed"
1
if the selected object
is a non trivially trimmed parametric surface, otherwise
0
is returned.[∗]
If multiple objects are selected, a list is returned.
This command supports arbitrary object types that just need to provide a NURBS surface.
"isHidden"
1
if the selected object
is hidden, otherwise
0
is returned.[∗]
If multiple objects are selected, a list is returned.These commands are probably the most important ones, because many other scripting interface commands operate on selected objects only:
"selOb ([-get
|
-end
|
-clear] | [index] | [first-last])"
index
may be a single (zero based) index, an ordered list of
indices or a range."-get"
option is specified, the current
selection will be returned just as the "getSel"
command does."-clear"
option is specified, the current
selection will be cleared."-end"
option is specified, the last
object in the current level will be selected."selOb"
"selOb 0"
"selOb 0 1"
"selOb 1 0"
"selOb 0 3-8"
"selOb 1-end"
"selOb -1"
"sL [count]"
# create object crtOb NCurve # update tree uCR # select new object sL
"uCR"
command, as access to the GUI is blocked anyway in this
context:
# create object crtOb NCurve # select new object sL
sL
is a procedure that operates
on information in the Tcl context alone.
Calling sL
on outdated hierarchy data (e.g. by leaving out uS
or
uCR
after object creation) will possibly lead to the wrong objects
being selected.
hSL – hidden select last object:
"hSL [count]"
"sL"
instead.
sP – hidden select parent object:
"sP [-]"
"-"
is given,
the original selection is restored (from the previous call to this command
without this argument).This command manipulates the point selection.
selPnts – manage the point selection:
"selPnts [(-count
|
-get) [vname] | -has | -all | -none | index1 index2 ...]"
"-count"
, this command puts the number
of all currently selected points into the variable specified by the
"vname"
argument. If no variable name is provided, the number is
returned.[∗]"-get"
, this command puts the indices
of all currently selected points into the variable specified by the
"vname"
argument. If no variable name is provided, the indices are
returned.[∗]"-has"
, this command returns "1"
if at least one of the selected objects has selected points. Otherwise "0"
is returned.[∗]"-all"
, this command selects all points."-none"
, this command de-selects all points."selPnts -all"
"selPnts 0 2"
This command manipulates the face selection.
selFace – manage face selection:[∗]
"selFace [-count | -get | -has | -set | -clear | -toggle | ind1 ind2 ...]"
"-count"
, this command returns the total number
of all currently selected faces."-get"
, this command returns the indices
of all currently selected faces."-has"
, this command returns "1"
if at least one of the selected objects has selected faces. Otherwise "0"
is returned."-set"
, this command selects all or the
faces designated by the index arguments."-clear"
, this command de-selects all or the
faces designated by the index arguments."-toggle"
, this command reverts the
selection state of all or the faces designated by the index arguments."selFace -clear"
"selFace 0 2"
These procedures allow easy access to object properties from the scripting interface:[∗]
getProperty – get single property value
"getProperty (propname(elemname) | elemname) [varname] [-s
|
-i]"
elemname
from the property named propname
of the currently
selected object and writes the result into the variable named varname
.
Multiple selected objects are supported and lead to a list of values
produced in the output variable.[∗]
If the "varname"
is omitted, the procedure will return the fetched
value(s), otherwise the returned value will be "1"
for successful
operations and "0"
else.[∗]
If just the elemname is provided, the corresponding property element from the type specific attribute property will be retrieved.[∗]
If the "-s"
option is specified, no errors will be
reported.[∗]
If the "-i"
option is specified, "RP"
tags will be
ignored.[∗]
"NP"
/"RP"
tags are also handled transparently."r"
easily using the command
getProperty SphereAttr(Radius) r
In contrast to using "getProperty"
, here is an equivalent example for the
direct (fast) access of property values:
getProp
set r $::SphereAttrData(Radius)
See also section
Global Property Management and Data Arrays.
setProperty – set single property value
"setProperty (propname(elemname) | elemname) value"
elemname
of the property named propname
for the currently
selected object to the new value given in value
.
Multiple selected objects are supported.[∗]
If just the elemname is provided, the corresponding property element
from the type specific attribute property will be
set.[∗]"3.0"
easily using the command
setProperty SphereAttr(Radius) 3.0
or, using the simple syntax available since Ayam 1.35:
setProperty Radius 3.0
In contrast to using "setProperty"
, here is an equivalent example for the
direct (fast) access of property values:
getProp
set SphereAttrData(Radius) 3.0
setProp
See also section
Global Property Management and Data Arrays.These commands operate the object clipboard:
"copOb [-append]"
"-append"
is used, the clipboard will not be cleared
before this operation.
"cutOb [-append]"
"-append"
is used, the clipboard will not be cleared
before this operation."pasOb [-move]"
"-move"
is given,
the objects are moved and not copied, i.e. after a "pasOb -move"
,
the clipboard is empty and no reference counters will be changed.
repOb – replace clipboard content with selected object(s):
"repOb"
clearClip – clear object clipboard:
"clearClip"
The following procedures operate the property clipboard,
which is totally independent from the object clipboard.
copyProp – copy a property to the property clipboard
"copyProp [mode]"
mode
is 0 (default), all marked entries will be omitted.
If mode
is 1 only the marked entries will be copied.
Property entries are usually marked by double clicks
on the respective entry labels but they can also be marked programmatically
by adding the respective property element names to the global array
"pclip_omit"
."pasteProp"
These commands manipulate the current level of Ayam:
"goDown index"
index
. If
index
is 0 and the current level is inside some object
the parent level will be entered instead. If index
is -1, the last
object of the current level will be entered."crtOb Level; goDown -1; crtOb Sphere"
creates a simple Level, enters it, and creates a Sphere as child of
this level."goUp"
"goTop"
The following commands move objects around in the hierarchy:
upOb – shuffle object(s) backward in the current level:
"upOb"
The moved objects stay selected, i.e. this command can be used multiple times in a row.
downOb – shuffle object(s) forward in the current level:
"downOb"
The moved objects stay selected, i.e. this command can be used multiple times in a row.
These commands transform objects or selected points of objects:
"movOb dx dy dz"
dx
in direction of the
objects X-axis, by dy
in direction of the objects Y-axis, and by
dz
in direction of the objects Z-axis."rotOb (dx dy dz | -a ax ay az a)"
dx
degrees around the
objects X-axis, then by dy
degrees around objects Y-axis, and finally by
dz
degrees around the objects Z-axis. Note the order of the
rotations.-a
, they denote an rotation
axis followed by the angle in degrees.[∗]"rotOb 0 0 45"
"rotOb -a 1 1 0 45"
"1 1 0"
."scalOb dx dy dz"
dx
in
direction of the objects X-axis, by a factor of dy
in
direction of the objects Y-axis, and by a factor of dz
in
direction of the objects Z-axis.
movPnts – move selected points:
"movPnts dx dy dz"
dx
in direction of the
objects X-axis, by dy
in direction of the objects Y-axis, and by
dz
in direction of the objects Z-axis.
rotPnts – rotate selected points:
"rotPnts (dx dy dz | -a ax ay az a)"
dx
degrees around the
objects X-axis, then by dy
degrees around objects Y-axis, and finally
by dz
degrees around the objects Z-axis. Note the order of the
rotations.-a
, they denote an rotation
axis followed by the angle in degrees.[∗]"rotPnts 0 0 45"
"rotPnts -a 1 1 0 45"
"1 1 0"
.
scalPnts – scale selected points:
"scalPnts dx dy dz"
dx
in
direction of the objects X-axis, by a factor of dy
in
direction of the objects Y-axis, and by a factor of dz
in
direction of the objects Z-axis.
delegTrafo – delegate transformations:
"delegTrafo"
This operation fails for complex setups (i.e. if the combination of parent and child transformation is a shear transformation).
applyTrafo – apply transformations:
"applyTrafo [-sel]"
"-sel"
is given) are modified.
It is no error, if an object has no points at all or if the points
are readonly.
Additionally, if any points of an object are modified, the transformations
of this object will be reset to the default values.
normTrafos – normalize transformation values:
"normTrafos"
"NormalizeDigits"
(by default 6)."normPnts"
"NormalizeDigits"
(by default 6).
normVar – normalize variable(s):
"normVar varname"
"NormalizeDigits"
(by default 6).
Lists are also supported.[∗]
normVal – normalize double value(s):
"normVar value"
"NormalizeDigits"
(by default 6).These commands operate the shader properties:
"shaderSet shadertype [varname]"
shadertype
for the selected
object. Type may be one of "surface"
, "displacement"
,
"light"
, "imager"
, "atmosphere"
, "exterior"
or "interior"
. If varname
is not given, the shader in question
is deleted from the object instead.
Otherwise, varname
points to an associative array that contains
the data (arguments) of the shader. Example content may be created
with the "shaderGet"
command below. The data is not checked
against the internal shader database for correctness or completeness.
This command fails, if the selected object does not support a shader
of given type."shaderGet shadertype varname"
shadertype
for the selected
object. Type may be one of "surface"
, "displacement"
,
"light"
, "imager"
, "atmosphere"
, "exterior"
or "interior"
. The shader data will be written to an associative
array pointed to by varname
.These commands may be used to modify the tags of an object (see also section Tags).
When processing tags of unknown or unregistered type, a corresponding
warning message may be emitted. This warning can be inhibited using
the hidden preference
setting "WarnUnknownTag"
or by registering the tag type using
the "registerTag"
command (see below).
"setTag type value"
type
and value-string
value
to the currently selected object(s).""
as value parameter. This is
e.g. needed for the "NoExport"
tag type."setTag NoExport """
"NoExport"
tag to the selected objects."setTag RP Transformations"
"RP"
(remove property) tag to the selected objects
that hides the Transformations property GUI."addTag type value"
type
and value-string
value
to the currently selected objects.""
as value parameter. This is
e.g. needed for the "NoExport"
tag type."addTag NoExport """
"NoExport"
tag to the selected objects."addTag RP Transformations"
"RP"
(remove property) tag to the selected objects
that hides the Transformations property GUI."hasTag type [value]"
"1"
if the selected
object has at least one tag of the designated type. Otherwise "0"
is returned. If multiple objects are selected, a list of values
is returned.[∗]
If a value is provided, this string is matched against the potential
tag value, it may also contain any of *?[]
for more complex
forms of matching.
"delTags [type]"
"all"
, all tags are
deleted from the currently selected objects."delTags"
"delTags RP"
"RP"
tags from the selected objects."getTags tvname vvname"
tvname
for the tag types and vvname
for the tag
values."setTags tagslist"
tagslist
. The tag types are
taken from the list elements with even index numbers and the tag
value-strings from the list elements with odd index numbers."setTags {RP Transformations RP Attributes}"
"RP"
tags."getTag type [vname]"
""
.
If no variable name is provided, the value of the tag is returned."registerTag type"
These commands operate on parametric curves:
"openC"
See also section Open Tool.
"closeC"
See also section Close Tool.
"refineC"
See also section Refine Tool.
"coarsenC"
"coarsenNC"
,
the old name is still available for compatibility but its
use is deprecated.
See also section Coarsen Tool.
"revertC"
See also section Revert Tool.
shiftC – shift control points of a (closed) curve:
"shiftC i"
i
(which may be negative to revert the direction of the
shifting). For a simple closed curve, shifting with i=1
, the first
control point will get the coordinates of the former last control point.
This means, positive shifts occur in the direction of the curve.
Note that for closed and periodic NURBS curves, the multiple points will
be managed correctly.
See also section Shift Closed Curve Tool.
toXYC – rotate curve to XY-plane
"toXYC"
See also section To XY Tool.
"concatC [-c closed | -k knottype | -f fillets | -fl len]"
The option "-c"
allows to create a closed curve
(0 – open, 1 – closed; default 0).
The option "-k"
allows to set a knot type (0 – NURB,
1 – Custom; default 0 – NURB).
The option "-f"
determines whether or not fillets should be created
(0 – no, 1 – yes; default 0).
The option "-fl"
allows to set the length of the fillets.
See also section ConcatNCAttr Property for more information on these options.
These commands operate on parametric surfaces:
"revertuS"
See also section Revert U Tool.
"revertvS"
See also section Revert V Tool.
swapuvS – swap dimensions of surfaces:
"swapuvS"
See also section Swap UV Tool.
concatS – concatenate surfaces:
"concatS [-o order | -t type | -k knottype | -u uvselect]"
The option "-o"
determines the desired order
of the surface in U direction.
The option "-t"
allows to set a surface type
(0 – open, 1 – closed, 3 – periodic; default 0).
The option "-k"
allows to set a knot type (default 1 – NURB).
Finally, the "-u"
option allows to specify the uv-select-string.
See also section ConcatNPAttr Property for more information on these options.
"capS [-mp mp] side"
The option "-mp"
allows to specify the point to extend to.
The side parameter must be an integer between 0
and 3
,
where 0
and 1
extend the surface at U0 and Un respectively, and
2
and 3
extend the surface at V0 and Vn respectively.
These are more specialized commands to change NURBS curve properties:
"clampNC [-s
|
-e]"
"Custom"
and
the knots will have o equal values at the desired side(s), where o
is the order of the curve.
If the side parameter is omitted, both sides are clamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is clamped.
In Ayam versions prior to 1.18 it was an error if the curve was already clamped at either side, this is no longer the case. Furthermore, curves with multiple knots in the end region(s) could not be clamped, this works ok now.
See also section Clamp Tool.
unclampNC – unclamp NURBS curve:
"unclampNC [-s
|
-e]"
"Custom"
.
If the side parameter is omitted, both sides are unclamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is unclamped.
See also section Unclamp Tool.
extendNC – extend NURBS curve:
"extendNC (x y z [w] | -vn varname | -m)"
See also section Extend Tool.
elevateNC – increase order of NURBS curve:
"elevateNC [n]"
n
.
If the parameter n
is omitted, a default value of 1 is used.
The knot type of the elevated curves will be changed to "Custom"
.
See also section Elevate Tool.
reduceNC – decrease order of NURBS curve:
"reduceNC [tol]"
tol
in any point.
If the parameter tol
is omitted, a default value of 0.0 is used,
i.e. the order is only reduced if the curve does not change.
The knot type of the reduced curves will be changed to "Custom"
.
See also section Reduce Tool.
insknNC – insert knot into NURBS curve:
"insknNC u r"
u
r
times. The valid range for u
is determined by
the current knot vector U as follows: U[p] <= u <= U[n]
, where
p
is the degree (order-1) of the curve and n
is the length of
the curve.
The knot type of the curves will always be changed to custom but
the shape of the curves will not change.
See also section Insert Knot Tool.
remknNC – remove knot from NURBS curve:
"remknNC (u | -i ind) r [tol]"
u
(u must be in the valid range of the knot vector
of the selected curve) r
times from the curve. Since Ayam 1.20
the knot to remove may also be specified using its (zero based)
index in the knot vector (i.e. use "remknNC -i 3 1"
instead of
"remknNC 0.5 1"
for the knot vector "0 0 0 0.5 1 1 1"
).
Note that the shape of the curve may be changed by this tool unless
the parameter tol
is specified.
If tol
is specified the new curve does not deviate
from the original curve more than tol
in any point on the curve.
If the knot can not be removed r
times due to the tolerance, an
error is reported and the original curve is left unchanged.
This operation also fails, if the knot removal would lead to a curve of lower order.
See also section Remove Knot Tool.
remsuknNC – remove superfluous knots from NURBS curve:
"remsuknNC [tol]"
tol
parameter. The default value
of this parameter is 0.0.
It is no error if no knots can be removed.
See also section Remove Superfluous Knots Tool.
refineknNC – refine knots of NURBS curve:
"refineknNC [{u1 u2 un}]"
{u1 u2 un}
.
If no list of new knots is given, a new knot is inserted into each interval
in the old knot vector.
See also section Refine Knots Tool.
tweenNC – interpolate (tween) curves:
"tweenNC [r]"
r
defines the
ratio of influence of the first and the second curve (the latter
using 1-r
). This parameter defaults to 0.5.r
is ignored and this
third curve defines the ratio of influence with its y coordinates.
See also section Tween Curve Tool.
rescaleknNC – rescale knots of NURBS curves:
"rescaleknNC [-r rmin rmax | -d mindist]"
rmin
, rmax
] if the "-r"
argument is
given or to the minimum distance mindist
if the "-d"
argument is used.
Scaling to a minimum distance ensures that all knots (except for multiple
knots) have a distance bigger than mindist
afterwards.
Since Ayam 1.20 the knot type of the curve does
not have to be "Custom"
anymore. Furthermore, rescaling the knots
does not change the knot type.
This operation does not change the shape of the curve.
See also section Rescale Knots to Range Tool.
"splitNC [-a
|
-r] u"
u
into two curves, creating one new curve and
modifying the original selected curve.
If the option "-r"
is present, the parametric value is interpreted
in a relative way and should therefore be in the range
[0, 1].[∗]
If the option "-a"
is present, the new curve(s) will be appended
to the current level. Otherwise the new curve(s) will be inserted
into the level right after the respective curve(s) to split.[∗]
See also section Split Tool.
"extrNC [-relative] umin umax"
umin
and umax
which have to be in the respective valid knot range.
If the optional argument "-relative"
is specified, the parametric
values are interpreted in a relative
way and must consequently be in the range [0,1].
"trimNC [-relative] umin umax"
If the optional argument "-relative"
is specified, the parametric
values are interpreted in a relative way and must consequently be in
the range [0, 1].
See also section Curve Trim Tool.
estlenNC – estimate length of NURBS curve:
"estlenNC [-trafo | -refine n] [varname]"
"-trafo"
is given, the transformation
attributes of the curve will be applied to the control points for the
length estimation."-refine"
is given, the curve will be
refined n
times prior to the length estimation which increases
the accuracy of the estimation.[∗]
reparamNC – reparameterise a NURBS curve:
"reparamNC type"
0
), or centripetal knots (type: 1
).
The knot type of the curve will be changed to "Custom"
.
See also section
Reparameterisation Tool."isCompNC [-l level]"
1
if the selected NURBS curves
are compatible (i.e. defined on the same knot vector), otherwise it
returns 0
.
If "level"
is 0
, only the orders of the curves
are compared.
If "level"
is 1
, only the orders and lengths of the curves
are compared.
makeCompNC – make NURBS curves compatible
"makeCompNC [-f | -l level]"
If the option "-f"
is present, there will be no prior compatibility check.
If "level"
is 0
, only the orders will be adapted.
If "level"
is 1
, only the orders and lengths will be adapted.
See also section Make Compatible Tool.
interpNC – interpolate NURBS curve:
"interpNC [-order order | -ptype type | -closed (0|1) | -sdlen length | -edlen length]"
"-closed"
parameter but this will also increase
the length of the resulting NURBS curve. The default is to
create an open curve for open input curves and a closed curve for
closed or periodic input curves.
Using the options "-sdlen"
and "-edlen"
(which both default
to 0.0) the length of automatically created start/end derivatives
can be adjusted. If any of these are not 0.0, a different interpolation
algorithm will be used, which increases the length of the resulting NURBS
curve.
The curve will interpolate all current control points after the interpolation and the position of certain control points will be changed in this process so that, after interpolation, the new control points will not be interpolated by the curve. The curve will rather interpolate the old control point positions.
The knot type of the interpolated curves will be changed to "Custom"
.
See also section Interpolate Tool.
approxNC – approximate NURBS curve:
"approxNC [-order o | -length l | -closed (0|1) | -tesselate t | -ptype (0|1|2)]"
The "-order"
parameter defaults to the order of the respective
NURBS curve and must be at least 2. If a smaller value is supplied the
command will silently fall back to the default. The order must also
be smaller or equal to the length of the new curve.
The "-length"
parameter defaults to the length of the respective
NURBS curve and must be higher than 2. If a smaller value is supplied
the command will silently fall back to the default. The length must
not be higher than the number of data points to approximate.
If the "-closed"
parameter is set to "1"
a closed periodic curve
will be created. By default, whether or not a closed curve shall be created
will be derived from the type of the curve to be approximated.
The "-tesselate"
parameter allows to control the tesselation of the
curve to be approximated. If this parameter is not present or zero,
no tesselation will be carried out and the control points of the curve
will be approximated.
The tesselation parameter directly controls the number of intermediate
points to generate for every distinct knot interval in the originating
curves knot vector. The total number of data points generated by the
tesselation is nd+(nd-1)×t, where nd is the total number of
distinct knots in the valid range of the knot vector.
The "-ptype"
parameter allows to choose a parameterization type:
"0"
centripetal, "1"
chordal, or "2"
uniform.
The knot type of the processed curves will be changed to "Custom"
.
See also section Approximate Tool.
"crtOb NCurve; selOb -1; approxNC -l 3 -o 3"
"crtOb NCurve; selOb -1; approxNC -l 5 -o 3 -t 3"
"curvatNC [-r] -u u"
u
.If the option "-r"
is present, the parametric value is interpreted
in a relative way and should therefore be in the range
[0, 1].
If multiple objects are selected, a list of curvature values is returned.
See also section Plot Curvature Tool.
"torsionNC [-r] -u u"
u
.[∗]If the option "-r"
is present, the parametric value is interpreted
in a relative way and should therefore be in the range
[0, 1].
If multiple objects are selected, a list of torsion values is returned.
distNC – compute distance between two NURBS curves:[∗]
"distNC [mode]"
This command supports arbitrary object types that just need to provide NURBS curves.[∗]
"fairNC [tol]"
If a tolerance value is present the processed control points do not move more than the given value.
If points are selected, only these will be processed.
See also section Fair Tool.
These are more specialized commands to change NURBS surface properties:
clampuNP – clamp NURBS patch in U direction:
"clampuNP [-s
|
-e]"
"Custom"
and the knots will have o
equal values at start and end (where o is the order of the patch in
U direction).
If the side parameter is omitted, both sides are clamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is clamped.
In Ayam versions prior to 1.18 it was an error if the patch was already clamped at either side, this is no longer the case. Furthermore, patches with multiple knots in the end region(s) could not be clamped, this works ok now.
See also section Clamp Surface Tool.
clampvNP – clamp NURBS patch in V direction:
"clampvNP [-s
|
-e]"
"Custom"
and the knots will have o
equal values at start and end (where o is the order of the patch in
V direction).
If the side parameter is omitted, both sides are clamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is clamped.
In Ayam versions prior to 1.18 it was an error if the patch was already clamped at either side, this is no longer the case. Furthermore, patches with multiple knots in the end region(s) could not be clamped, this works ok now.
See also section Clamp Surface Tool.
unclampuNP – unclamp NURBS patch in U direction:
"unclampuNP [-s
|
-e]"
"Custom"
.
If the side parameter is omitted, both sides are unclamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is unclamped.
See also section Unclamp Surface Tool.
unclampvNP – unclamp NURBS patch in V direction:
"unclampvNP [-s
|
-e]"
"Custom"
.
If the side parameter is omitted, both sides are unclamped.
If the side parameter is "-s"
only the start, and if it is "-e"
only the end is unclamped.
See also section Unclamp Surface Tool.
rescaleknNP – rescale knots of NURBS patches:
"rescaleknNP [-r[u|v] rmin rmax | -d[u|v] mindist]"
rmin
, rmax
] if the "-r"
argument is
given or to the minimum distance mindist
if the "-d"
argument is
used.
Scaling to a minimum distance ensures that all knots (except for multiple
knots) have a distance bigger than mindist
afterwards.
The "-ru"
, "-rv"
, "-du"
, and "-dv"
variants scale only
the designated dimension.
Trim curves, if present, will also be scaled to match the new range.
Since Ayam 1.20 the knot type of the curve does
not have to be "Custom"
anymore. Furthermore, rescaling the knots
does not change the knot type.
This operation does not change the shape of the patch.
See also sections Rescale Knots to Range Surface Tool and Rescale Knots to Mindist Surface Tool.
"rescaleknNP -ru 0.2 0.3"
scales the u knot vector
of the selected NURBS patch objects to the new range
[0.2, 0.3].
insknuNP – insert knot into NURBS patch:
"insknuNP u r"
u
, r
times. u
must be in the valid range of
the corresponding
knot vector of the selected patches. The valid range is determined by
the current knot vector U as follows: U[p] <= u <= U[n]
, where
p
is the degree (order-1) of the patch in U direction and n
is the
width of the patch.
The u knot type of the patches will always be changed to "Custom"
but
the shape of the patches will not change.
See also section Insert Knot Surface Tool.
insknvNP – insert knot into NURBS patch:
"insknvNP v r"
v
, r
times. v
must be in the valid range of
the corresponding
knot vector of the selected patches. The valid range is determined by
the current knot vector V as follows: V[p] <= v <= V[n]
, where
p
is the degree (order-1) of the patch in V direction and n
is the
height of the patch.
The v knot type of the patches will always be changed to "Custom"
but
the shape of the patches will not change.
See also section Insert Knot Surface Tool.
remknuNP – remove u knot from NURBS surface:
"remknuNP (u | -i ind) r [tol]"
u
(u
must be in the valid range of the knot vector
of the selected surface) r
times from the surface. Since Ayam 1.20
the knot to remove may also be specified using its (zero based)
index in the knot vector (i.e. use "remknuNP -i 3 1"
instead of
"remknuNP 0.5 1"
for the knot vector "0 0 0 0.5 1 1 1"
).
Note that the shape of the surface may be changed by this tool unless the
parameter tol is specified. If tol
is specified, the new surface does
not deviate from the original surface more than tol in any point.
If the knot can not be removed r times due to the tolerance, an
error is reported and the original surface is left unchanged.
This operation also fails, if the knot removal would lead to a surface of lower order.
See also section Remove Knot Surface Tool.
remknvNP – remove v knot from NURBS surface:
"remknvNP (v | -i ind) r [tol]"
v
(v
must be in the valid range of the knot vector
of the selected surface) r
times from the surface. Since Ayam 1.20
the knot to remove may also be specified using its (zero based)
index in the knot vector (i.e. use "remknvNP -i 3 1"
instead of
"remknvNP 0.5 1"
for the knot vector "0 0 0 0.5 1 1 1"
).
Note that the shape of the surface may be changed by this tool unless
the parameter tol is specified. If tol
is specified, the new surface does
not deviate from the original surface more than tol in any point.
If the knot can not be removed r times due to the tolerance, an
error is reported and the original surface is left unchanged.
This operation also fails, if the knot removal would lead to a surface of lower order.
See also section Remove Knot Surface Tool.
remsuknuNP – remove superfluous knots from NURBS surface:
"remsuknuNP [tol]"
tol
parameter. The default value
of this parameter is 0.0.
It is no error if no knots can be removed.
See also section Remove Superfluous Knots Surface Tools.
remsuknvNP – remove superfluous knots from NURBS surface:
"remsuknvNP [tol]"
tol
parameter. The default value
of this parameter is 0.0.
It is no error if no knots can be removed.
See also section Remove Superfluous Knots Surface Tools.
refineuNP – refine NURBS surface in U direction:
"refineuNP [{u1 u2 un}]"
{u1 u2 un}
without changing their shape.
If no list of new knots is given, a new knot is inserted into each interval
in the old knot vector.
The u knot type of the refined surfaces may be changed to "Custom"
.
See also section Refine Knots Surface Tool.
refinevNP – refine NURBS surface in V direction:
"refinevNP [{v1 v2 vn}]"
{v1 v2 vn}
without changing their shape.
If no list of new knots is given, a new knot is inserted into each interval
in the old knot vector.
The v knot type of the refined surfaces may be changed to "Custom"
.
See also section Refine Knots Surface Tool.
elevateuNP – elevate NURBS surface in U direction:
"elevateuNP [n]"
n
.
If the parameter n
is omitted, a default value of 1 is used.
The u knot type of the elevated surfaces will be changed to "Custom"
.
See also section Elevate Surface Tool.
elevatevNP – elevate NURBS surface in V direction:
"elevatevNP [n]"
n
.
If the parameter n
is omitted, a default value of 1 is used.
The v knot type of the elevated surfaces will be changed to "Custom"
.
See also section Elevate Surface Tool.
reduceuNP – decrease order of NURBS surface:
"reduceuNP [tol]"
tol
in any point.
If the parameter tol
is omitted, a default value of 0.0 is used,
i.e. the order is only reduced if the surface does not change.
The knot type of the reduced surfaces will be changed to "Custom"
.
See also section Reduce Surface Tools.
reducevNP – decrease order of NURBS surface:
"reducevNP [tol]"
tol
in any point.
If the parameter tol
is omitted, a default value of 0.0 is used,
i.e. the order is only reduced if the surface does not change.
The knot type of the reduced surfaces will be changed to "Custom"
.
See also section Reduce Surface Tools.
"splituNP [-a
|
-r] u"
u
, creating one new NPatch object and
modifying the original selected NPatch object.
If the option "-r"
is present, the parametric value is interpreted
in a relative way and should therefore be in the range
[0, 1].
If the option "-a"
is present, the new NPatch object(s) will be appended
to the current level. Otherwise the new NPatch object(s) will be inserted
into the level right after the respective NPatch object(s) to split.
This is the new default.[∗]
See also section Split Surface Tools.
"splitvNP [-a
|
-r] v"
v
, creating one new NPatch object and
modifying the original selected NPatch object.If the option "-r"
is present, the parametric value is interpreted
in a relative way and should therefore be in the range
[0, 1].
If the option "-a"
is present, the new NPatch object(s) will be appended
to the current level. Otherwise the new NPatch object(s) will be inserted
into the level right after the respective NPatch object(s) to split.
This is the new default.[∗]
See also section Split Surface Tools.
"extrNP [-relative] umin umax vmin vmax"
umin
, umax
, vmin
, and vmax
which have to be in the
respective valid knot range.
If the optional argument "-relative"
is specified, the parametric
values are interpreted in a relative
way and must consequently be in the range [0,1].
See also section Extract Patch Tool.
tweenNP – interpolate (tween) surfaces:
"tweenNP [r]"
r
defines the
ratio of influence of the first and the second patch (the latter
using 1-r
). This parameter defaults to 0.5.r
is ignored and this
third surface defines the ratio of influence with its y coordinates.
See also section Tween Surfaces Tool.
interpuNP – interpolate NURBS surface in U direction:
"interpuNP [-order order | -ktype type | -closed (0|1) | -sdlen length | -edlen length]"
"-closed"
parameter but this will also increase
the width of the resulting NURBS surface. The default is to
create an open surface for open input surfaces and a closed surface
for closed or periodic input surfaces.
Using the options "-sdlen"
and "-edlen"
(which both default
to 0.0) the length of automatically created start/end derivatives
can be adjusted. If any of these are not 0.0, a different interpolation
algorithm will be used, which increases the width of the resulting NURBS
surface.
The surface will interpolate all current control points after the interpolation and the position of certain control points will be changed in this process so that, after interpolation, the new control points will not be interpolated by the surface. The surface will rather interpolate the old control point positions.
The u knot type of the interpolated surfaces will be changed to "Custom"
.
If the "-closed"
option is not present, the interpolated surface
will be closed for closed and periodic surfaces.
See also section Interpolate Surface Tool.
interpvNP – interpolate NURBS surface in V direction:
"interpvNP [-order order | -ktype type | -closed (0|1) | -sdlen length | -edlen length]"
"-closed"
parameter but this will also increase
the height of the resulting NURBS surface. The default is to
create an open surface for open input surfaces and a closed surface
for closed or periodic input surfaces.
Using the options "-sdlen"
and "-edlen"
(which both default
to 0.0) the length of automatically created start/end derivatives
can be adjusted. If any of these are not 0.0, a different interpolation
algorithm will be used, which increases the height of the resulting NURBS
surface.
The surface will interpolate all current control points after the interpolation and the position of certain control points will be changed in this process so that, after interpolation, the new control points will not be interpolated by the surface. The surface will rather interpolate the old control point positions.
The v knot type of the interpolated surfaces will be changed to "Custom"
.
See also section Interpolate Surface Tool.
approxNP – approximate NURBS surface:[∗]
"approxNP [-m mode | -aw awidth | -ah aheight | -ou uorder | -ov vorder | -kt(u|v) ptu|ptv | -c(u|v) 0|1 | -tp(u|v) tu|tv]"
The mode parameter determines whether to just approximate along U (0), V (1), U and then V (2), or V and then U (3). If just approximating in one direction, the approximation parameters of the other direction will be ignored and the values from the original surface will be used instead.
The order parameters default to 4 and must be higher than 2. They must also not be higher than the respective dimension of the approximating surface.
The awidth and aheight parameters must not be higher than the number of data points in the respective dimension to approximate.
The parameterisation type must be one of 0 – Chordal,
1 – Centripetal, or 2 – Uniform; default is Chordal.
For one dimensional approximations, the knot type of
the other dimension may not be uniform and will be overridden
to be of type "BSpline"
if a closed/periodic surface is created.
The approximation can create a closed surface if requested by the
"-cu"
/ "-cv"
parameter(s).
The "-tpu"
/ "-tpv"
parameters allows to control
the tesselation of the surface to be approximated. If these parameters
are not present or zero, no tesselation will be carried out and the
control points of the surface will be approximated.
The tesselation parameters directly control the number of intermediate
points to generate for every distinct knot interval in the originating
surfaces knot vectors. The number of data points per dimension generated
by the tesselation is nd+(nd-1)×t, where nd is the
total number of distinct knots in the valid range of the respective
knot vector and t the respective tesselation parameter.
The knot type of the approximated surfaces will be changed to "Custom"
.
See also section Approximate Surface Tools.
"crtOb NPatch; selOb -1; approxNP -aw 3 -ou 3"
"crtOb NPatch; selOb -1; approxNP -aw 5 -ou 3 -tpu 3"
breakNP – break NURBS patch into curves:
"breakNP [-r | -a | (-u | -v)]"
"-u"
or "-v"
is specified, default is U).
If the option "-a"
is specified, the transformations of the NPatch
objects will be applied to the control points and the NCurve objects
will be created with default transformation attributes, otherwise the
control points will be copied verbatim and the NCurve objects will get
the transformation attributes of the respective NPatch.
If the option "-r"
is specified, the new curve objects will
replace each NPatch object instead of being appended to the current
level. They will also be selected immediately.[∗]
See also section Break into Curves Tool.
buildNP – build NURBS patch from curves:
"buildNP [-r|-a (0|1) | -o order | -t type | -k knottype]"
The option "-a"
controls, whether the transformation attributes
of the NURBS curves shall be applied to the respective control points
before building the patch (default 1 – yes).
The option "-o"
determines the desired order of the surface in U
direction (default min(4,width)).
The option "-t"
allows to set a surface type
(0 – open, 1 – closed, 3 – periodic; default 0).
The option "-k"
allows to set a knot type (0 – Bezier,
1 – B-Spline, 2 – NURB, 4 – Chordal,
5 – Centripetal, default 2 – NURB). Custom knots
are not supported.
If the option "-r"
is present, the new NPatch objects will
replace the first selected NCurve object instead of being appended to
the current level, the other NCurve objects will be removed.
See also section Build from Curves Tool.
"isCompNP [(-u
|
-v) | -l level]"
1
if the selected NURBS surfaces
are compatible (i.e. defined on the same knot vector), otherwise it
returns 0
.
If the option "-u"
is given, only the U dimension will be checked.
If the option "-v"
is given, only the V dimension will be checked.
If "level"
is 0
, only the orders of the surfaces
are compared.
If "level"
is 1
, width/height and orders of the surfaces are
compared.
makeCompNP – make NURBS surfaces compatible
"makeCompNP [-f | (-u
|
-v) | -l level]"
If the option "-f"
is present, there will be no prior compatibility check.
If the option "-u"
is given, only the U dimension will be adapted.
If the option "-v"
is given, only the V dimension will be adapted.
If "level"
is 0
, only the orders will be adapted.
If "level"
is 1
, only the orders and lengths will be adapted.
See also section Make Compatible Tool.
curvatNP – compute Gaussian curvature:
"curvatNP [-r] -u u -v v"
u
and v
.If the option "-r"
is present, the parametric values are interpreted
in a relative way and should therefore be in the range
[0, 1].
If multiple objects are selected, a list of curvature values is returned.
fairNP – improve surface shape:
"fairNP [-m mode | -w | -t tol]"
The value of the option "-m"
(mode) controls how the surface
shall be faired: 0 – U direction only,
1 – along V direction only,
2 – first along U direction, then along V direction, and
3 – first along V direction, then along U direction.
The mode defaults to 0 – U direction only.
If the option "-w"
(worst) is present, only the point that would
move the farthest distance in a row/column will be changed.
If a tolerance value is present the processed control points do not move more than the given value.
If points are selected, only these will be processed.
tobasisPM – convert PatchMesh to a different
basis:
"tobasisPM [-t type | -s step | -b basis]"
The option "-t"
controls the new basis type
(0 – "Bezier"
, 1 – "B-Spline"
,
2 – "Catmull-Rom"
, 3 – "Hermite"
,
4 – "Power"
, 5 – "Custom"
),
default is 1 (conversion to "B-Spline"
).
The option "-s"
determines the new step size (1 to 4), it defaults
to the natural step size of the target basis type and thus can be
omitted safely, unless the target type is "Custom"
, in which case the step
size must be specified.
The option "-b"
allows to convert to a custom basis and thus
is a list of 16 floating point values specifying a 4 by 4 basis matrix
in column major order. If "-b"
is given, the target type defaults
to "Custom"
and the option "-t"
can be omitted.
"tobasisPM -t 0"
tobasisBC – convert BCurve objects to a different
basis:
"tobasisBC [-t type | -s step | -b basis]"
The option "-t"
controls the new basis type
(0 – "Bezier"
, 1 – "B-Spline"
,
2 – "Catmull-Rom"
, 3 – "Hermite"
,
4 – "Power"
, 5 – "Custom"
),
default is 1 (conversion to "B-Spline"
).
The option "-s"
determines the new step size (1 to 4), it defaults
to the natural step size of the target basis type and thus can be
omitted safely, unless the target type is "Custom"
, in which case the step
size must be specified.
The option "-b"
allows to convert to a custom basis and thus
is a list of 16 floating point values specifying a 4 by 4 basis matrix
in column major order. If "-b"
is given, the target type defaults
to "Custom"
and the option "-t"
can be omitted.
"tobasisBC -t 0"
These are more specialized commands to change PolyMesh properties:
genfnPo – generate face normals:
"genfnPo"
The generated normals will be stored in a PV tag.
gensnPo – generate smooth normals:
"gensnPo"
Already existing vertex normals will be destroyed.
If face normals already exist, they will be used, otherwise, new face
normals will be generated using the same algorithm as implemented in the
"genfnPo"
command above.
remsnPo – remove smooth normals:
"remsnPo"
flipPo – flip normals or loops:
"flipPo [0|1|2]"
Use these commands to read or manipulate the control points or normals of objects that support point editing.
"getPnt [-trafo | -world | -eval | -relative] (index | indexu indexv | u | u v) [(varx vary varz [varw] | -vn varname | -all [varname] | -sel [varname])]"
varx
, vary
,
varz
, and (if the object supports rational coordinates) varw
.
The index arguments needed depend on the type of the selected
object, e.g. reading the points of a NURBS curve requires just one
index parameter (index
), whereas reading the points of a NURBS
patch requires two index parameters (indexu
and indexv
) to be
specified.
If the optional argument "-trafo"
is given, the coordinates
will additionally be transformed by the values given in the objects
Transformation property.
If the optional argument "-world"
is used, the coordinates
will additionally be transformed to world space.
If the optional argument "-eval"
is specified, the "indexu"
and "indexv"
values are interpreted as parametric values of a
NURBS curve or surface and the corresponding point on the curve or
surface is delivered in varx
, vary
, and varz
.
If the optional argument "-relative"
is specified, the parametric
value for NURBS curve or surface evaluation is interpreted in a relative
way and must consequently be in the range [0,1].
If the alternative argument "-vn"
is given, the coordinate values
will be appended to the list variable specified by "varname"
.
If the alternative argument "-all"
is used, all coordinate values
of the selected objects will be appended to the list variable
specified by "varname"
.
If the alternative argument "-sel"
is used, the coordinate values
of the currently selected points of the selected objects will be appended
to the list variable specified by
"varname"
.[∗]
If any of the variable name arguments are omitted, the command returns the respective results.[∗]
"getPnt 1 x y z w"
"x"
, "y"
, "z"
,
and "w"
."getPnt -eval 0.5 x y z"
"0.5"
and writes the
coordinate values to the variables "x"
, "y"
, and "z"
."setPnt [-world] (index | indexu indexv) (x y z [w] | -vn varname) | (-all|-sel) varname)"
The index arguments needed depend on the type of the selected object, e.g. manipulating the points of a NURBS curve requires just one index parameter (index), whereas manipulating the points of a NURBS patch requires two index parameters (indexu and indexv) to be specified.
If the optional parameter "-world"
is given, the coordinate values are
expressed in world space and will be transformed to appropriate
object space coordinates before setting.
If the optional parameter "w"
is omitted,
but the selected object has rational points, a default value of 1.0 will
be used for the weight.
If the alternative parameter "-vn"
is used, the coordinate
values will be read from the variable specified by "varname"
which must be a list of double values.
If the alternative parameter "-all"
is provided, all control
points of the selected objects will be set and the coordinate
values will be read from the variable specified by "varname"
which must be a list of double values.
If the alternative argument "-sel"
is used, all selected control
points of the selected objects will be set and the coordinate
values will be read from the variable specified by "varname"
which must be a list of double values.[∗]
When reading data from list variables, no precision will be lost as there are no double-string-double conversions involved.
"setPnt 1 0.0 0.2 0.3 1.0"
"0.0 0.2 0.3 1.0"
."setPnt -world 0 0 0 0"
"setPnt 2 1 0.0 0.2 0.3"
"0.0 0.2 0.3 1.0"
."getNormal [-cv | -relative | -trafo | -world | -norm] (index | u v) [(varx vary varz | -vn varname)]"
varx
, vary
, and varz
.[∗]
This operation fails for PolyMesh objects, if there are no vertex normals.
The index arguments needed depend on the type of the selected
object, e.g. reading the normal of a PolyMesh requires just one
index parameter (index
), whereas evaluating the normal of a NURBS
patch requires two parameters (u
and v
) to be
specified.
If the optional argument "-cv"
is specified, the "u"
and "v"
values are interpreted as index parameters and the surface
is not evaluated but the normal is computed from the surrounding control
points.
If the optional argument "-relative"
is specified, the parametric
values for NURBS surface evaluation are interpreted in a relative
way and must consequently be in the range [0,1].
If the alternative argument "-vn"
is given, the coordinate values
will be appended to the list variable specified by "varname"
.
If the optional argument "-trafo"
is specified, the returned
normal will, additionally, be transformed by the object orientation
attributes.
If the optional argument "-world"
is specified, the returned
normal will, additionally, be transformed by the object and all
parent level orientation attributes.
If the optional argument "-norm"
is specified, the returned
vector will be scaled to a length of 1.
"getNormal 1 x y z"
"x"
, "y"
, "z"
.
"getNormal 0.5 0.5"
"0.5"
"0.5"
and returns the result as list."setNormal index (x y z | -vn varname)"
This operation fails if there are currently no vertex normals.
If the alternative parameter "-vn"
is used, the normal
values will be read from the variable specified by "varname"
which must be a list of double values.
When reading data from list variables, no precision will be lost as there are no double-string-double conversions involved.
"setNormal 1 0.0 0.2 0.3"
"0.0 0.2 0.3"
.
"setNormal 0 -vn normal"
"normal"
.
getTangent – get first
derivative(s)/tangent(s):
[∗]
"getTangent [-relative | -trafo | -world | -norm] (u | u v) (varx vary varz [varu varv varw] | -vn varname)"
varx
, vary
, and varz
; for parametric surface
objects both tangents (in u and v direction) will be computed
and, consequently, also varu
, varv
, and varw
will be
written to.
If the optional argument "-relative"
is specified, the parametric
values are interpreted in a relative
way and must consequently be in the range [0,1].
If the alternative argument "-vn"
is given, the resulting values
will be appended to the list variable specified by "varname"
.
If the optional argument "-trafo"
is specified, the returned
tangent will, additionally, be transformed by the object orientation
attributes.
If the optional argument "-world"
is specified, the returned
tangent will, additionally, be transformed by the object and all
parent level orientation attributes.
If the optional argument "-norm"
is specified, the returned
vector will be scaled to a length of 1.
"getTangent 0.5 x y z"
"x"
, "y"
, "z"
.
"getTangent 0.5 0.5"
"0.5"
"0.5"
and returns the result as list.These procedures implement simple vector algebra for vectors stored as lists.
l3add – add two three element vectors:
"l3add l1 l2"
l1
and l2
) as another three element list.l3sub – subtract two three element vectors:
"l3sub l1 l2"
l1
and l2
) as another three element list.l3mul – multiply two three element vectors:
"l3mul l1 l2"
l1
and l2
) as another three element list.l3scal – multiply a three element vector with a scalar:
"l3scal l c"
l
) with a scalar (c
).l3dot – compute the dot product of two three element vectors:
"l3dot l1 l2"
l1
and l2
).l3cross – compute the cross product of two three element vectors:
"l3cross l1 l2"
l1
and l2
) as three element list.l3to4 – convert 3D coordinates to rational style:
"l3to4 l3 (w)"
w
).
The weight defaults to 1.0.crtOb ICurve; selOb -1; crtOb NCurve -length [getProperty Length] -cv [l3to4 [getPnt -all]]
l4to3 – convert rational coordinates to 3D:
"l4to3 l4"
crtNCircle; selOb -1; crtOb ICurve -length [getProperty Length] -cv [l4to3 [getPnt -all]]
These procedures update various parts of the Ayam user interface:
"rV"
"uS [update_prop maintain_selection]"
If update_prop is 0 no update of the property GUIs will take place.
If maintain_selection is 1 the old selection will be established again.
If both arguments are omitted update_prop defaults to 1 and maintain_selection to 0.
"ay(ul)"
(UpdateLevel) may be set
to the current level before calling "uS"
. This will not remove
and update the complete scene but just the part below "ay(ul)"
.
Example:
global ay; set ay(ul) $ay(CurrentLevel); uS;
"uCR"
may be used instead of "uS"
."uCL cl"
may be used instead of "uS"
."uCL mode [args]"
"uS"
above.
The parameter "mode"
may be "cl" or "cs", where "cl" is the normal
operation mode, and "cs" just clears the selection.
uCR – update current level after create:
"uCR"
"uS"
above.
plb_update – property listbox update:
"plb_update"
Since Ayam 1.13 it is also possible to automatically run GUI updating
commands in the console by using <Shift+Return>
instead
of <Return>
. The commands from the hidden preference setting
"AUCommands"
will be executed after the commands from the command
line, if the <Shift>
key is held down. <Shift+Return>
may also be used without commands on the command line.
By default, the "AUCommands"
are "uS; rV;"
, leading to
updated object tree, property GUI, and views.
These commands manage preferences data:
getPrefs – get preferences data:
"getPrefs"
setPrefs – set preferences data:
"setPrefs"
"ayprefs"
to let all changes take effect.See also section Preferences
This command manages custom objects (plugins):
loadPlugin – load custom object / plugin:
"loadPlugin name"
name
is a complete
filename and the designated file exists, it will be loaded directly.
Otherwise, the file to load will be searched for in the list of configured
plugin directories (see "Plugins"
preference setting).
Note that it is currently not possible to unload a custom object or plugin from Ayam.
These procedures and commands help to apply arbitrary commands to a number of selected objects.
"forAll [(-recursive|-r) r | (-type|-t) t] command"
If r
is 1 (this is the default) then forAll will recurse into
every object (if it has child objects) before the execution of command.
If r
is 2, the recursion will happen after the execution of command.
If r
is 0, only objects from the current level will be processed.
If the "-type"
option is given, only objects of the specified type
t
will be processed.
Prior to Ayam 1.22, potential errors from the command(s) were suppressed and
processing continued regardless. But this made interactive usage and
debugging unnecessarily difficult.
From 1.22 on, errors are reported to the user and processing immediately
stops. Errors may still be suppressed using the "catch"
command
like this:
"forAll { catch { commands } }"
As the command will potentially be called multiple times, result
values of any kind can not be delivered using the "return"
command but should rather be collected in global variables.
In fact, returning any value that is not -1
will be interpreted
as error and the processing will stop immediately.
Returning -1
in a recursive forAll will stop the processing
without raising an error.
The global variable "ay(CurrentLevel)"
will be maintained while
a recursive forAll browses the scene. In addition, the global variable
"i"
will be set to the index of the current object.
Note that forAll will run slowly if a property GUI is displayed. If the current property is de-selected first (using e.g. the property context menu), it will run much faster.
Furthermore, the current selection is correctly maintained.[∗]
"-type"
option can be used."forAll { uplevel #0 { commands } }"
"forAll { global arrayname; commands }"
withOb – execute a command on certain selected object(s):
"withOb index [do] command"
"withOb 2 {movOb 0 1 0}"
These commands help to load scenes from and save them to Ayam scene files:
"replaceScene filename"
"filename"
parameter."insertScene filename"
"filename"
parameter."saveScene filename [selected]"
"filename"
parameter. If the optional parameter "selected"
is 1,
only the selected objects will be saved."newScene"
This command allows to export the current scene to a RenderMan Interface Bytestream (RIB):
"wrib filename [-image imagename] [-smonly | -selonly | -objonly]"
"filename"
.
If the argument "-image"
is given, the RIB file
will create an image file named "imagename"
upon rendering.
The export will use the camera transformation from the currently selected Camera object, unless one of the following options is specified.
If the argument "-smonly"
is provided, a RIB to render shadow maps
will be created and the argument of "-image"
will be ignored.
See also section
Using ShadowMaps.
If the argument "-selonly"
is used, only the selected (geometric)
objects will be exported, which will result in a RIB file not
suitable for rendering (no setup, camera transformation, or lights
are in it) but for inclusion into other scenes via RiArchive.
See also section
RiInc Object.
Likewise "-objonly"
leads to a RIB file containing all objects in the
scene but not suitable for rendering.
The "wrib"
command always needs a selected camera object
(unless the "-selonly"
or "-objonly"
options are given); if
there is none or if the camera transformations of the camera associated
with a view window shall be used, the corresponding Togl callback for
the view might be used like this instead:
.view1.f3D.togl wrib -file filename.rib
"wrib"
command.
"-filename "
, this is no longer the case.This command is for error reporting from scripts:
"ayError code place detail"
ayError
should be preferred to puts
because the error
reporting mechanism of Ayam features consistently formatted output,
compression of repeated messages, and logging.
The code parameter should be one of: 1 – warning, 2 – error,
3 – flush messages, 4 – unspecified output.
There are more codes defined (see ayam.h, look for Return/Error Codes)
but they are generally not needed in the Tcl script context.
The place parameter should describe the procedure where the error occurred.
The detail parameter is the string to be output."ErrorLevel"
see section
Miscellaneous Preferences.These procedures help to manage property GUIs. See also section Property Management and Data Arrays.
"addPropertyGUI name"
The array will be set up in a way that the data array of the property
will be named as the property with the string Data
appended,
i.e. for MyProperty
it will be MyPropertyData
.
The get/set procedure entries will be left empty.
After the creation of property GUI elements, "NP"
tags must
be used to make the new property visible to the user.
See also section
NP (New Property) Tag.
A complete example is available in section Script Object Examples.
"set w [addPropertyGUI MyProperty]"
The following procedures add user interface elements to the
property GUIs created by "addPropertyGUI"
.
addParam:
"addParam window arrayname paramname [defaults]"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The "defaults"
parameter is a list
of default values. Those values will be presented to the user as an
additional drop down menu on the right side of the interface element.
"addParam $w MyPropertyData MyFloat {0.1 0.5 1.5}"
addString:
"addString window arrayname paramname [defaults]"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The "defaults"
parameter is a list
of default values. Those values will be presented to the user as an
additional drop down menu on the right side of the interface element.
If the list contains an entry "..."
, selecting this entry will
clear the string entry field and move the input focus to the field.
"addString $w MyPropertyData MyString {"a" "b" "abc"}"
addCheck:
"addCheck window arrayname paramname [onoffvalues]"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The optional "onoffvalues"
parameter is a list of two values that will
be used when setting the corresponding variable when the check-button is
enabled or disabled. The default values are 0 and 1.
"addCheck $w MyPropertyData MyBool"
addColor:
"addColor window arrayname paramname [defaults]"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The "defaults"
parameter is a list
of default values. Those values will be presented to the user as an
additional drop down menu on the right side of the interface element.
"addColor $w MyPropertyData MyColor"
addMatrix:
"addMatrix window arrayname paramname"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The individual matrix value variable names will be formed by appending a
"_0"
to "_15"
to the "paramname"
.
"addMatrix $w MyPropertyData MyMatrix"
addMenu:
"addMenu window arrayname paramname choices"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The "choices"
parameter is a list
of strings that will be presented in the menu.
In contrast to the other user interface element generating procedures, the corresponding entry in the property data array must exist before this procedure is called.
"addMenu $w MyPropertyData MyMenu {Choice1 Choice2}"
addFile:
"addFile window arrayname paramname [defaults]"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter.
The "defaults"
parameter is a list
of default values. Those values will be presented to the user as an
additional drop down menu on the right side of the interface element.
"addSFile"
"addFile $w MyPropertyData MyFile {"/tmp/file1" "/tmp/file2"}"
addCommand:
"addCommand window name text command"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "name"
parameter is the name of the corresponding
button widget. The names must be unique in each property GUI.
The "text"
parameter is the string to be put on the button.
The "command"
parameter is the command to be executed when the
button is pushed.
"addCommand $w b1 PushMe {puts pushed}"
addText:
"addText window name text"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "name"
parameter is the name of the corresponding
label widget. The names must be unique in each property GUI.
The "text"
parameter is the string to be displayed.
"addText $w t1 "Angular Parameters:""
addInfo:
"addInfo window arrayname paramname"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter whose
value is to be displayed. Whenever the value of this variable changes,
the corresponding label will be updated automatically.
If a second variable named like "paramname"
but with an additional
trailing "Ball"
exists, its value will be displayed as balloon help
text, when the mouse pointer hovers over the label. This way longer or
more complex information can be presented.
"addInfo $w MyPropertyData NumGeneratedElems"
addProgress:
"addProgress window arrayname paramname"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the corresponding
data array of the property.
The "paramname"
parameter is the name of the parameter where
the progress is stored in percent.
"addProgress $w MyPropertyData Progress"
addVSpace:
"addVSpace window name height"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "name"
parameter is the name of the corresponding
widget. The names must be unique in each property GUI.
The "height"
parameter is the desired height in pixels.
"addVSpace $w v1 20"
addOptionToggle:
"addOptionToggle window arrayname paramname text cmd"
The "window"
parameter should contain the window name as returned by
"addPropertyGUI"
above.
The "arrayname"
parameter is the name of the property management
array of the property.
The "paramname"
parameter is the name of a variable that contains the
current visibility state.
The "text"
parameter is the text to display on the toggle widget,
this is usually a string like "Advanced Options"
.
The "cmd"
parameter is the name of a procedure that, based on the
current visibility state, creates or destroys the other property GUI
elements.
proc toggleAdvanced { } { global MyProp set w $MyProp(w) if { $MyProp(ShowAdvanced) } { addCheck $w MyPropData AdvancedOption } else { catch {destroy $w.fAdvancedOption} } } set w [addPropGUI MyProp] set MyProp(w) $w addCheck $w MyPropData CommonOption addOptionToggle $w MyProp ShowAdvanced "Advanced Options" \ toggleAdvanced
addScriptProperty:
"addScriptProperty propname propargs"
The "propname"
parameter is the base name of the property.
The "propargs"
parameter is a list of parameter specifications
of the property.
This procedure
Even though the name of this procedure suggests otherwise, it can and should be invoked on every run of the script objects code (unlike code that manages data arrays and GUI manually).
Each parameter specification is a list of three values:
"{ Name Defaultvalue ScriptContextVariableName }"
where:
"Name"
is the string to be used in the property GUI as parameter
name,"Defaultvalue"
is the initial value to be used for this parameter,
the type of the default value determines the type of property GUI
element to be created:
true
or false
lead to check boxes (addCheck), but the
values in the script variable will still be 1
or 0
(and not
true
or false
),"ScriptContextVariableName"
is a short variable name where the value
from the property GUI element will be stored for use in the script.addScriptProperty MyProp { { FloatParam 0.1 fp } { BoolParam false bp } { MenuParam { "Mode1" "Mode2" } mp } { StringParam "texture.tif" tp } }
fp
, bp
, mp
, and tp
respectively.Miscellaneous commands:
"convOb [-inplace [type] | -check type]"
If the option "-inplace"
is
used, the new object(s) will replace the old object(s).
If, additionally, a target type is specified, the conversion
will be repeated until the object is of the requested
type (and no conversion is attempted if the object is already
of the requested type).[∗]
If the option "-check"
is given, the convOb command does not
convert but checks, whether a conversion to a given object type would be
successful, the result of the check will be returned as 0 – no,
or 1 – yes. Note, that only immediate, one step, conversions are
checked, not multi step conversions as carried out by in-place conversions
with target type.
"undo [redo | save opname [0|1] | clear | rewind]"
"redo"
, this command performs the redo
operation."save"
, the currently selected objects
are saved to the undo buffer for future undo operations. The name
of the now following modelling operation has to be provided in
a second argument ("opname"
).
This name will be displayed in the default console prompt, to inform the
user about which operation would be undone/redone, if undo/redo would be
used (e.g. "[Undo:MoveObj/Redo:none].../bin>"
).
Since Ayam 1.13, a third argument may be given, that controls whether
all the children of the selected objects should also be saved. This may
be needed if the modelling action that follows the undo save is about to
change the selected objects and also their children.
Note: undo save does not fail if no objects are selected."clear"
, all currently saved states
will be cleared from the undo buffer."rewind"
is available since Ayam 1.14. With
this command you can undo the last undo save operation. This may be
necessary, if a modelling operation failed. Care should be taken,
however, to not rewind the undo state, when a modelling
operation only failed for some (not for all) of the selected objects.undo save "MovOb" set ay_error "" movOb 0 1 0 if { $ay_error > 1 } { undo rewind }
"runTool vars labels commands title [doc]"
vars
and labels
,
and if the dialog is closed via the "Ok"
-button, runs the specified
commands substituting the values provided by the user into the script.
"vars"
is a list of variable names, array names are allowed. If the
specified variables already exist, their current values will be used
to infer a parameter type for presenting a type specific GUI component
to the user. The type detection uses the string is
facility of Tcl.
If the current value is of type integer and there is a second variable
(named like the original variable with the appendix _l
), a menu
component will be used and the menu choices will be taken from the
second variable.
"labels"
is a list of label strings for the parameters.
"commands"
is the code that calls the tool and runs additional
GUI updating. If the code contains strings like %0
, those will
be replaced by the corresponding parameter value requested before
the code runs.
"title"
is the title string of the dialog window. It can be used
to convey the tool name or description to the user.
"doc"
is an optional argument that contains a documentation URL
for the tool. This URL will be opened when the <F1>
-key is
pressed in the dialog.
runTool {x} {"X:"} {moveOb %0 0 0;plb_update;rV} "MoveX"
runTool {x y} {"X:" "Y:"} {moveOb %0 %1 0;plb_update;rV} "MoveXY"
set l 0 set l_l {"Start" "End" "Both"} runTool {l} {"Side:"} { switch %0 { 0 {clampNC -s} 1 {clampNC -e} 2 {clampNC} } plb_update;rV } "Clamp"
"notifyOb [-all | -modified | -parent]"
If the "-modified"
parameter is used, only modified objects
will be notified.
If the "-all"
parameter is used, all objects
will be notified regardless of the selection.
If the "-parent"
parameter is used, only the current
parent object of the current level will be notified.
Prior to Ayam 1.20 this command was named "forceNot"
,
the old name is still available for compatibility but its
use is deprecated.
∗: Since 1.21 this command is also available in the safe interpreter with limited functionality: only the notification callbacks of the selected objects will be executed. No BNS or ANS tags will be considered, notification of parents will not be done, and the complete notification will also be omitted. Hence, in the safe interpreter, this command ignores all parameters.
See also section The Modelling Concept Tool-Objects.
"nameOb name"
"setMark [x y z | l]"
If no arguments are provided, the global mark is cleared.
This procedure only works, if there is at least one view.
See also section Setting the Mark.
"setMark 0 0 0"
"getMark"
This procedure only returns meaningful data, if there is at least one view.
See also section Setting the Mark.
"clearMark"
This procedure only works, if there is at least one view.
See also section Setting the Mark.
"tmpGet tmpdir varname [ext]"
varname
."whatis this"
"this"
in the Tcl scripting context to the console.
This procedure can be used to inquire about the existence of variables,
widgets, or whether or not something is a command or a procedure."whatis ."
leads to the output:
. is a command.
. is a widget.
"addToProc procedure addition"
addition
to
the Tcl procedure procedure
."return;"
statement.Various entries of dialogs for object creation and modelling tools support Tcl variables and expressions.
It is e.g. possible to enter
$::u
u
(that
may have been set before using the find u modelling action) and
insert a knot at the picked point.
It is also possible to enter complex mathematical expressions:
[expr sin(45)]
or call into own procedures (that have to return appropriately typed values):
[myproc]
"myproc"
is defined elsewhere (e.g. in a Tcl script file
loaded via the "Scripts"
preference setting) as follows:
proc myproc { } { return [expr sin(45)]; }
Repeated calling of the tool without opening the dialog (using
the keyboard shortcut <Ctrl+T>
), will execute the
provided expression again.
This means, a number of curves with increasing length can be created
by entering into the Ayam console
set ::myvar 1
[incr ::myvar]
<Ctrl+T>
multiple times.
Here are some complete example scripts for the Ayam Tcl scripting interface.
All examples may be copied from the documentation and pasted directly into the console of Ayam.
The following example script shows how to move a selected object to a specified position in space.
proc placeOb { x y z } { global transfPropData # copy Transformations-property data to # global array "transfPropData" getTrafo # set array values according to procedure parameters set transfPropData(Translate_X) $x set transfPropData(Translate_Y) $y set transfPropData(Translate_Z) $z # copy Transformations-property data from # global array "transfPropData" to selected object setTrafo } # placeOb
forAll -recursive 0 {placeOb 1 1 1}
"placeOb"
procedure (defined above) with them:
global ay $ay(cm) add command -label "Place Object(s)" -command { runTool {x y z} {"X:" "Y:" "Z:"} {forAll -recursive 0 {placeOb %0 %1 %2}; plb_update; rV } "Place Object(s)" }
"plb_update; rV"
command ensures that the GUI is updated
properly and all views display the new position of the moved objects.
The following example script snippet shows how to move control points of a NURBS curve.
# first, we create a new NURBS curve with 30 control points set len 30 crtOb NCurve -length $len # update selection uS # select last object (the newly created curve) sL # prepare moving set i 0 set r 3.0 set angle 0 set angled [expr 3.14159265/2.0] while { $i < $len } { set x [expr $r*cos($angle)] set y [expr $r*sin($angle)] set z [expr $i/3.0] # move control point to new position setPnt $i $x $y $z 1.0 set angle [expr $angle + $angled] incr i } # redraw all views rV
The following example script shows how to easily create a sweep from a selected path curve (avoiding the manual and lengthy creation and parameterisation of a suitable cross section).
proc easySweep { } { # first, we create a sweep object crtOb Sweep # now, we need to move the selected curve (path) to # the sweep and create a cross-section curve there too # for that, we move the currently selected curve to the clipboard cutOb # enter the Sweep (the last object in the current level) goDown -1 # now, we create a new curve (a closed B-Spline suitable as cross section) crtClosedBS -s 8 # select the new object selOb 0 # now, we rotate and scale the curve rotOb 0 90 0 scalOb 0.25 0.25 1.0 # move trajectory back (we use "-move", because we # really want to move (and not copy) the curve object pasOb -move # go up to where we came from goUp # finally, update the GUI... uS sL # ...and redraw all views rV } # easySweep
Run this procedure by selecting a NURBS curve object, then type into the console:
» easySweep
This command may be added to the main menu as well:
global ay $ay(cm) add command -label "Easy Sweep" -command { easySweep }
"Custom/Easy Sweep"
that calls the easySweep
procedure.
Here is another example script that shows how buttons may be added to the toolbox. myImage should be an image created e.g. from a GIF file of the size 25 by 25 pixels.
global ay ayprefs # create an image from a GIF file: image create photo myImage -format gif -file /home/user/giffile set b $ay(tbw).mybutton # if the button does not already exist: if { ![winfo exists $b] } { # create it: button $b -padx 0 -pady 0 -image myImage -command myCommand # tell Ayam about the new button: # you can use "linsert", to insert the button in a specific # place or just append to the end of the list using "lappend" lappend ay(toolbuttons) mybutton # display the button: toolbox_layout # from now on, the button will be under the # automatic toolbox layout management }
This example shows that
"ay(tbw)"
(this is ".tbw.f"
for multi-window GUI configurations or
".fv.fTools.f"
for single-window GUI configurations),"ay(toolbuttons)"
, the order in that list is the order
in which the buttons appear in the toolbox,"toolbox_layout"
.Adding buttons with just text is a little bit more involved,
as the sizes of those buttons often do not fit well in the
icon button scheme with its constant button size. However,
the procedure "toolbox_add"
can be of
considerable help.[∗]
See also the script "scripts/topoly.tcl"
for an example.
The following example script adds two buttons to the bottom of the toolbox spanning the whole window (this works best with the standard toolbox layout of 4 by 12 buttons used in the multi-window GUI configuration):
global ay # create a frame: set f [frame $ay(tbw).fcollex] # calculate the row number below the last row: set row [expr [lindex [grid size $ay(tbw)] 1] + 1] # now display the frame at calculated row, spanning the whole window: grid $f -row $row -column 0 -columnspan [lindex [grid size $ay(tbw)] 0]\ -sticky we # create two buttons inside the frame: button $f.b1 -width 5 -text "Coll." -command { collMP; rV; } button $f.b2 -width 5 -text "Expl." -command { explMP; rV; } pack $f.b1 $f.b2 -side left -fill x -expand yes
This sections contains the documentation of some helper scripts that are distributed with Ayam.
The helper scripts may be run via the context menu of the console, the
Tcl "source"
command in the console, or the "Scripts"
preference setting of Ayam on each start (the latter except for
the so called external scripts
"repairAyam.tcl"
, "bgconvert.tcl"
, and "aytest.tcl"
).
All other, internal scripts may be combined arbitrarily except for
"kdialog.tcl"
, "zdialog.tcl"
, and "intfd.tcl"
,
which are mutually exclusive.
The external Tcl script "repairAyam.tcl"
may be used to repair the application state of Ayam,
should it be stuck e.g. in an endless loop of Tcl error
messages.[∗]
On Unix systems "repairAyam"
may be started from any
shell simply by typing
» ./repairAyam.tcl
or
» wish repairAyam.tcl
on the command prompt; if the script detects that it is running on Unix
and not in Ayam it will send itself to the Tcl interpreter Ayam is
running in using the Tk send command. On Mac OS X Aqua (not X11!)
AppleScript events will be used instead of the Tk send command.
If this does not work as expected "repairAyam.tcl"
may still
be run via the Ayam console (as on Win32).
On Win32 "repairAyam.tcl"
has to be started from the Ayam console
using the command:
» source scripts/repairAyam.tcl
or via the consoles context menu: "Console/Load File"
.
The script "repairAyam.tcl"
should be considered a
last resort to help saving the current state of
modified objects.
The script will close all views, clean up the application state variables, reset the mouse cursor and the console prompt, and try to update important main window widgets.
Furthermore, the script will also clear the console and try to break potential endless loops running e.g. in the console or in Script objects.[∗]
After running "repairAyam.tcl"
the scene (or the most
important objects currently worked on) should be immediately
saved to a new scene file, not the file currently loaded,
using "File/Save As"
or
"Special/Save Selected"
) and Ayam should be restarted
afterwards.
Simply saving the scene using "File/Save"
or <Ctrl+s>
should be avoided because views were possibly deleted.
The external script "aytest.tcl"
allows to test the
Ayam implementation by creating objects with various combinations
of parameters and executing standard operations and modelling actions
on them.
The external Tcl script "bgconvert.tcl"
converts scene files from one 3D file format to another,
with the help of Ayam which is running in the
background.[∗]
In the most simple form, bgconvert may be used from a Unix command line (or shell script) like this:
» bgconvert.tcl infile.x3d outfile.dxf
The above command would load the X3D file "infile.x3d"
into Ayam and export the scene as DXF file to "outfile.dxf"
.
For a successful conversion Ayam has to run and the plugins required
for the import and export processes need to be available and properly
configured (check the "Plugins"
preference setting).
The plugins necessary for the conversion will be loaded automatically.
Import and export options may also be given like this:
» bgconvert.tcl "infile.rib -p 1" outfile.dxf
In the example above the "-p 1"
option switches on reading
of partial RIB files.
Available options and their syntax may be inquired from the
import and export plugin Tcl scripts (e.g. "plugins/rrib.tcl"
).
The Tcl script "slxml.tcl"
switches the shader parsing
machinery of Ayam to recognize XML based meta information embedded in
shading language comments.[∗]
This way, the shader database for the Material
objects can be built up from shading language source files, instead of
compiled shaders.
The XML tags will not be parsed by a real XML parser, so that well
formedness is not an issue. However, the attributes must be ordered
in a certain way. To specify a shader, use:
<shader type="stype" name="sname">
where stype
is one of surface
, displacement
, volume
, light
, imager
, or transformation
and sname
is the shader name
that must also match the file name of the shader source file sans extensions.
To specify a shader parameter, use a line like:
<argument name="argname" type="argtype" value="argval">
where argname
is the name of the parameter, argtype
is one of
float
, string
, matrix
, color
, point
, normal
,
or vector
and argval
is the default value.
See also the following example shader source:
/* myshader.sl: * Author: Randolf Schultz * <shader type="surface" name="myshader"> * <argument name="Ka" type="float" value="0.5"> * <argument name="Kd" type="float" value="0.9"> * <argument name="ic" type="color" value="0 1 0"> */ surface myshader(float Ka = 0.5, Kd = 0.9; color ic = color (0, 1, 0);) { color mycolor; ... Ci = Cs*mycolor*(Ka*ambient()+Kd*diffuse(faceforward(normalize(N),I))); }
The following restrictions/caveats (in contrast to the normal shader parsing) apply:
The script "topoly.tcl"
recursively browses through the scene and converts everything
to a polygonal representation.[∗]
After running the script, there is a new button in the toolbox
named "ToPolyMesh"
. Additionally, there is a corresponding
entry in the "Custom"
main menu.
Pressing the button or using the menu entry immediately starts the
conversion process.
Since the changes of the conversion can not be undone, the conversion will not run if the scene contains unsaved changes.
The conversion will use the current parameters from the preference settings
"SMethod"
, "SParamU"
, and "SParamV"
; "TP"
tags (if present) will override these parameters.
TP tags may be created easily using the tesselation tool, see also
section
Tesselation Tool.
The script "tonpatch.tcl"
recursively browses through the scene and converts everything
to a NURBS patch representation effectively flattening the tool object
hierarchy.[∗]
After running the script, there is a new button in the toolbox
named "ToNPatch"
. Additionally, there is a corresponding
entry in the "Custom"
main menu.
Pressing the button or using the menu entry immediately starts the
conversion process.
Since the changes of the conversion can not be undone, the conversion will not run if the scene contains unsaved changes.
The script "2lcons.tcl"
(for two line console) may be
used to restrict the screen space occupied by the console.
Normally, the Ayam console is resized with the main window and occupies a varying amount of screen space. After running the script, the console will always resize to exactly two lines of text. Different values may be chosen easily by adapting the script.
The script "colfocus.tcl"
(for colored focus) may be
used to paint the focus ring in a more visible color.
After running the script, the focus ring will be painted in blue (instead of black): focused sub-windows (views, console, object tree) will be more easily recognizable. Other colors may be used by editing the script.
The script "link.tcl"
places a small button into the
object hierarchy title area that controls the, otherwise permanent,
link between the hierarchy and the views.[∗]
If this button is disabled, selection actions and changes to the
hierarchy or to the objects themselves (via the property GUI)
do not result in redraw operations.
Toggling the state to "on"
will result in a single redraw.
This script may be used with all other scripts that place buttons in the designated area. The buttons will be placed from the right to the left in the order of the script execution.
The scripts "shufup.tcl"
and "shufdown.tcl"
place
small buttons into the object hierarchy title area that shuffle the
selected objects up or down in the current
level.[∗]
See also the image above.
See also the discussion about multiple hierarchy button scripts in section Decouple Hierarchy View Link.
The scripts "opent.tcl"
and "closet.tcl"
place
small buttons into the object hierarchy title area that allow to open
and close all tree levels.[∗]
See also the image above.
See also the discussion about multiple hierarchy button scripts in section Decouple Hierarchy View Link.
The script "aac.tcl"
(for automatic about center)
may be used to switch all modelling actions to their about variants with
the mark set to the center of the current selection automatically.
After running the script, invoking e.g. the scale 2D action using
the shortcut <s>
will:
<sac>
)<saC>
)The script modifies all rotate and scale actions (including their axis confined variants).
Note, that the mark is not reset to a new center, when the selection changes. After a selection change (e.g. by selecting points in a different view) simply restart the action to transform about the new center.
To rotate or scale about a different point than the center, the mark
may still be set manually using <a>
.
To temporarily disable the modified behavior, the global keyboard
shortcut <F11>
can be used.
Note that since the introduction of the "ScopeManagement"
preference
setting (see
Modelling Preferences) in Ayam 1.30
this script is obsolete and kept only for backwards compatibility.
Furthermore, to ensure complete compatibility this script will set the
scope management mode to "Explicit"
when loaded.
The script "apnt.tcl"
(for automatic point) may be
used to switch the modelling mode to point modelling automatically
after a point selection.
After running the script, selecting (tagging) a point using the
select point action (shortcut <t>
) will automatically
switch the view to point modelling so that the next modelling
actions (e.g. move, via shortcut <m>
) will always
transform the points and not modify the objects transformations.
Note that currently the switch to point modelling will also occur,
if no points are actually selected, it is just the mouse click that
counts.
Selecting all points via the keyboard shortcut <A>
will additionally switch to point modelling and de-selecting all points via
<N>
will additionally switch to object
modelling.[∗]
It is also still possible to switch back to object modelling anytime
via the keyboard shortcut <o>
.
To temporarily disable the modified behavior, the global keyboard
shortcut <F12>
can be used.
The script "ssp.tcl"
(for save selected points)
allows to save the point selection to tags of type
SP
.[∗]
After running the script, two new buttons appear in the toolbox that allow to save and restore the point selection respectively. See also the table below.
Operation | Icon |
Save | |
Restore |
There are also two corresponding entries in the custom menu.
Note that the tags can be saved to scene files and also copied to different objects.
The script "rc.tcl"
(for revert cursor) may be
used to get more useful cursor key behavior in primary modelling
views (parallel views).
After running the script, the keyboard shortcuts for rotating
and panning in parallel views are swapped, e.g. just pressing
<Left>
key will then pan the view, instead of rotating it.
The shortcuts will be swapped again, when the view changes
type to "Perspective"
.
The script "zap.tcl"
demonstrates, how arbitrary core
functionality that is just available through a main menu entry
or the scripting interface might be accessed easily via the
toolbox window.
After running the script "zap.tcl"
, there will be a new
toolbox button, labeled "Zap!"
, that simply runs the zap
command (which iconifies the complete application).
The script "kdialog.tcl"
switches all file dialogs of
Ayam to use the kdialog application of the KDE project instead
of the native Tk file dialog.
The script also adds a custom main menu entry to revert any
changes.
The script "zdialog.tcl"
switches all file dialogs of
Ayam to use the zenity application of the Gnome project instead
of the native Tk file dialog.
The script also adds a custom main menu entry to revert any
changes.
The script "intfd.tcl"
switches all file dialogs of
Ayam to use the Tcl/Tk internal version instead
of the native file dialogs provided by the operating system.
The script "useaqsisapp.tcl"
sets up Ayam to use Aqsis
from the application directory structure ("/Applications/Aqsis.app"
)
on Mac OS X. This is the default installation location of Aqsis on Mac OS X.
The script adapts the executable and shader search paths. Furthermore, environment variables vital for Aqsis to work will be set up properly.
Note that the script does not change the "RIB-Export/Renderer"
preferences, you still have to switch to Aqsis using the main menu
"Special/Select Renderer"
once.
The script "usepixie.tcl"
sets up Ayam to use Pixie
from the "/Library/pixie"
directory on Mac OS X.
This is the default installation location of Pixie on Mac OS X.
The script adapts the executable, shared library, and shader search paths. Furthermore, environment variables vital for Pixie to work will be set up properly.
Note that the script does not change the "RIB-Export/Renderer"
preferences, you still have to switch to Pixie using the main menu
"Special/Select Renderer"
once.
The script "myicons.tcl"
allows to replace icons of the Ayam
user interface, e.g. toolbox icons, with user defined ones.
The new icons must be GIF image files of size 25 by 25 and reside
in the "icons"
directory relative to the Ayam executable.
The names of the image files may be obtained from the script or by the following scripting interface command (in the Ayam console):
» image names
Action icon variants (e.g. for the scale about actions) can also be created
automatically by changing the "createVariants"
variable in
the script file.
The script "dtree.tcl"
(dynamic/fast tree) replaces some of
BWidgets tree code for faster interaction in scenes with many objects.
The original BWidget tree widget (and accompanying script code in Ayam) creates a canvas item for every object in the scene, even if it is not visible in the tree widget. Therefore, tree update operations that occur e.g. after loading of a scene or after drag-and-drop operations, can become very slow, when a scene has many objects.
If the dtree script is active, there are only as many canvas items as there are nodes visible in the current scroll region. Therefore, working with many objects in long lists becomes much faster for operations that require tree updates. However, operations like opening or closing sub trees or even just scrolling in the tree will become a bit slower, as canvas items need to be created constantly.
The script "cvview.tcl"
(control vertex view) allows to
view the control points of NURBS surface or curve objects as property,
see also the image above.
The script currently supports the following object types: APatch, IPatch, NPatch, PatchMesh, ACurve, ICurve, NCurve, BCurve, and SDCurve. In addition also objects that provide NPatch/NCurve objects and show a NPInfo/NCInfo entry in their parameter property are supported.[∗]
If the script is loaded, there is a new entry in the "Custom"
menu
("Add CVView to Object"
) that allows to add a new
property ("CVView"
) to an individual
surface or curve object.
The "CVView"
property GUI displays all control vertices in a
regular grid. The coordinates of each vertex will be shown when
the mouse pointer hovers over it. This also works if the control points
lump together in 3D space or have unusual values.
Additionally, the current point selection is visualized by painting the selected vertices in red and the selection may also be adjusted by clicking on the circles. Drag selection is also possible.[∗]
The script "curvature.tcl"
allows to
view the curvature of NURBS curves and NURBS curve providing objects
as property, see also the image above.
If the script is loaded, there is a new entry in the "Custom"
menu
("Add Curvature View to Object"
) that allows to add a new property
("Curvature"
) to an individual curve object.
The "Curvature"
property GUI displays the curvature of the curve as
live and interactive diagram.
The diagram will be updated if the curve changes.
The diagram can be zoomed by dragging with the leftmost mouse button
and panned by dragging with the rightmost mouse button (in zoomed state).
Zooming is also possible with the mouse wheel.
The zoomed state is conveyed by prepending/appending "..." to/on the respective label of the horizontal scale.
Note that when panning, the new section of the curve will be re-scaled to completely fill the Y-axis.
For NURBS curve objects the real knot value range will be shown on the x axis whereas for NURBS curve providing objects a relative knot value range ([0, 1]) will be displayed.
A click on the "k"
label toggles between absolute and logarithmic
scaling of the Y-axis.
There is a resize handle that allows to adapt the size of the diagram to the property canvas.
The "x3dom-nurbs"
script implements the
<NurbsPatchSurface>
and <NurbsTrimmedSurface>
X3D NURBS nodes for x3dom (see http://www.x3dom.org/
) in
JavaScript.
After loading of the scene into the web browser, the NURBS surfaces
from these nodes are tessellated into <IndexedTriangleSet>
nodes.
This allows to directly publish NURBS
models on the web without prior conversion to a polygonal representation
which is cumbersome, inflexible, and leads to higher bandwidth consumption.
The tessellator is based on idea and example code from A. J. Chung and A. J. Field: "A Simple Recursive Tessellator for Adaptive Surface Triangulation" in Journal of Graphics Tools Vol. 5, Iss. 3, 2000.
The implementation spans four script files:
x3dom-nurbs-nodes.js
– interface of the tessellator to x3domx3dom-nurbs-pool.js
– worker management (current pool size is 3)x3dom-nurbs-worker.js
– a workerx3dom-nurbs-tess.js
– the tessellatorIn order to use the tessellator just add the following to your XHTML file
after inclusion of "x3dom.js"
:
<script type="text/javascript" src="x3dom-nurbs-pool.js"/>
<script type="text/javascript" src="x3dom-nurbs-nodes.js"/>
As the tessellator is fully automatic, no further adjustments are needed.
Proper XHTML files can be created using the X3D export in x3dom-mode, see section X3D (Web3D) export options.
While the tessellator runs in the background an initial polygonal
representation that is directly derived from the control polygon of
the NURBS surface is shown. Additionally, a busy prompt is displayed,
see also the image below.
As the busy prompt is derived from the x3dom loading prompt, it may also
be styled with the "x3dom-progress"
style in "x3dom.css"
.
The tessellation runs in so called webworkers, processes that run in
parallel to the main browser thread, in order to not block user interaction
and employ multi-core CPUs.
The webworker pool is currently hard coded to only use three such
webworkers at any given time. This value may be adapted easily in
"x3dom-nurbs-pool.js"
(e.g. if your average target CPU has more cores).
Note that each webworker will tessellate a single NURBS surface, i.e. scenes
with only one surface will not benefit from the parallelism.
By default, the tessellator tries to create a tessellation that represents all important surface features in a way that a visual inspection from mid to close viewing distance does not reveal the nature of the underlying triangular representation. This may be too fine/slow for objects that are never viewed from close distance or too coarse for very detailed objects.
Therefore, and in concordance with the respective suggestions of the X3D
specification, the tessellation quality and speed may be adjusted using the
"uTessellation"
and "vTessellation"
attributes of the
<NurbsPatchSurface>
or
<NurbsTrimmedSurface>
nodes as explained in the next sections.
If no "uTessellation"
attribute is specified, or its value
is positive, the tessellator uses the so called object space sampling
mode. In this mode the tessellator subdivides an initial set of triangles
recursively until all edges of those triangles are shorter than a given
threshold value (in object space). The threshold value is set automatically
so that an object extending one unit by one unit in object space is subdivided
to about 15 by 15 by two triangles.
The "uTessellation"
attribute value is simply multiplied into
this automatically determined threshold.
Therefore "uTessellation"
values larger than 1.0 lead to a coarser
and faster tessellation, whereas values smaller than 1.0 lead to a
finer and slower tessellation.
Note that in this mode the value of the "vTessellation"
attribute is not considered at all.
Also note that in highly curved regions of the surface and at trim edges, even smaller triangles than determined by the edge length criterion may be created.
If the "uTessellation"
attribute value is negative, the
tessellator switches to parametric space sampling.
In this mode also the "vTessellation"
attribute is considered.
As in the object space sampling mode an automatic threshold value is
computed, but here the extension of the object in parametric space
(i.e. the number of control points) is used. This actually results
in two threshold values, one for each parametric dimension.
The "uTessellation"
and "vTessellation"
attributes are
multiplied into those thresholds.
Therefore, values larger than -1.0 (in absolute value) lead to a coarser and faster tessellation in the respective dimension. Values smaller than -1.0 (in absolute value) lead to a finer and slower tessellation in the respective dimension. This means a value of -2.0 leads to roughly half as many triangles compared to the default and a value of -0.5 leads to twice as many triangles when compared to the default in the respective parametric dimension.
As the edge length computation is simpler and no curvature analysis is taking place, the parametric space sampling is considerably faster than object space sampling.
Note that at trim curve edges even smaller triangles than determined by the edge length criterion may be created.
To aid in parameterisation of the "uTessellation"
and
"vTessellation"
attributes, a "normalPerVertex"
attribute
can be added to the respective <NurbsPatchSurface>
or
<NurbsTrimmedSurface>
node. This attribute will then also
be set for the corresponding <IndexedTriangleSet>
node
that is created by the tessellator.
If the value of this attribute is "false"
, x3dom will display
this surface in a flat shaded style and the tesselated triangles will be
visible allowing easier judgment and adjustment of the tesselation quality.
Due to memoization of surface points, parametric values must not exceed:
Texture coordinates are always directly derived from the parametric values.
Surface normals are not computed by the tessellator, but by x3dom. This can lead to normals that are off for very coarse tessellations but is much faster. Another benefit of this approach is, that normals in non-differentiable surface points (e.g. the poles of the standard NURBS sphere) do not flip.
There is no support for the following nodes:
<NurbsTextureCoordinate>
,<NurbsSet>
,<NurbsSweptSurface>
,<NurbsSwungSurface>
,<NurbsCurve>
, and all<Nurbs*Interpolator>
nodes.These scripts implement Script objects, see also section Script Object.
The file "tcone.tcl"
is a Script object script that creates
truncated cones with arguments
similar to the cylinder primitive, see also the above image.
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "TConeAttr"
to the Script object to see it.
These are the parameters of the truncated cone:
"Closed"
toggles whether the object should
be automatically sealed (closed by matching cap surfaces)."ThetaMax"
is the sweeping angle of the cone in degrees,
default is 360.
"ZMin"
is the base of the cone, default is 0."ZMax"
is the peak of the cone, default is 1."RMin"
is the radius of the cone at the base, default is 1."RMax"
is the radius of the cone at the peak, default is 0.5.Internally, the script creates a Hyperboloid; further information about conversion capabilities and RIB export may be found in section Hyperboloid.
An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/tcone.ay"
.
The file "hdisk.tcl"
is a Script object script that creates
a disk with a hole, also called an annulus.
See also the above image.
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "HDiskAttr"
to the Script object to see it.
These are the parameters of the disk with hole:
"ThetaMax"
is the sweeping angle of the disk in degrees,
default is 360.
"RMin"
is the inner radius of the disk or radius of the hole,
default is 0.5."RMax"
is the outer radius of the disk, default is 1.0.Internally, the script creates a Hyperboloid; further information about conversion capabilities and RIB export may be found in section Hyperboloid.
An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/hdisk.ay"
.
The file "cbox.tcl"
is a Script object script that creates a NURBS
surface in the form of a box with a cylindrical topology, see also the
image above.
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "CBoxAttr"
to the Script object to see it.
These are the parameters of the cylindrical box:
"Width"
extension of the box along the X-axis, default is 1.0."Depth"
extension of the box along the Z-axis, default is 1.0."Height"
extension of the box along the Y-axis, default is 1.0.In contrast to the standard Box object, the cylindrical box converts to a single NURBS patch. However, this patch has poles and, consequently, shading artefacts may appear on the top and down side. Texturing this object is also challenging.
An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/cbox.ay"
.
The file "tcircle.tcl"
is a Script object script that creates
NURBS circles with a triangular base, see also the above image.
In contrast to the standard nine point NURBS circle with rectangular base, the triangular circle consists of just seven control points. This can save some memory, e.g. in long sweep objects. However, the parameterisation of the triangular circle is also slightly worse. Furthermore, only full circles that start on the positive X-axis are supported.
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "TCircleAttr"
to the Script object to see it.
These are the parameters of the triangular circle:
"Radius"
radius of the circle, default is 1.0.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/tcircle.ay"
.
The script "helix.tcl"
creates a NURBS curve that forms a helix,
see also the above image.
This script must be used in a Script object of type "Create"
(see section
Script Object).
There is also a property GUI provided; one must
add a "NP"
tag of value "HelixAttr"
to the Script object to see it.
These are the parameters of the helix:
"Length"
is the number of control points in the curve,
default is 30."Radius"
is the radius of the helix, default is 2.0."Angle"
is the offset angle of from one point to the next, default
is 45.0."DZ"
is the offset along z from one point to the next, default is
0.25.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/helix.ay"
.
The script "spiral.tcl"
creates a NURBS curve that forms a spiral,
see also the above image.
This script must be used in a Script object of type "Create"
(see section
Script Object).
There is also a property GUI provided; one must
add a "NP"
tag of value "SpiralAttr"
to the Script object to see it.
These are the parameters of the spiral:
"Length"
is the number of control points in the curve,
default is 30."Angle"
is the offset angle of from one point to the next, default
is 45.0."RMin"
is the start radius value, default is 0.1."RDiff"
is the radius difference from one point to the next,
default is 0.1.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/spiral.ay"
.
The file "oval.tcl"
is a Script object script that creates
NURBS curves in the form of an oval, here: two half circles connected
by straight lines, see also the above image.
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "OvalAttr"
to the Script object to see it.
These are the parameters of the oval:
"Length"
distance of the two half circle apexes on the x axis,
default is 2.0."Radius"
radius of the half circles, default is 1.0.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/oval.ay"
.
The file "filletnc.tcl"
is a Script object script that creates
a fillet NURBS curve between two other curves with adjustable individual
tangent lengths, see also the above image.
This script must be used in a Script object of type "Modify"
(see section
Script Object) and instances
of the curves to connect should be children of the Script object.
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "FilletNCAttr"
to the Script object to see it.
These are the parameters of the fillet:
"TanLenS"
tangent length at start of fillet,"TanLenT"
tangent length at end of fillet.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/filletnc.ay"
.
If instead of two instances of individual curves, two instances of
a single curve are present as children, the fillet will close the
parameter curve.
An example scene file of this special setup is distributed with Ayam,
see the file:
"ayam/scn/scripts/filletncc.ay"
.
The file "dualsweep.tcl"
is a Script object script that creates
a NURBS surface from three parameter curves similar to birailing but
with cross section curves perpendicular to both rails,
see also the above image.
The first curve is the so called cross section. This curve must be
planar and defined in the YZ-plane. It is the leftmost open curve in the
upper example image.
The second curve is the first rail curve. This curve should start in
the starting point of the cross section curve. It is the lower closed curve
in the upper example image.
The third parameter curve is the second rail curve. This curve should
start in the end point of the cross section curve. It is the upper closed curve
in the upper example image.
This script must be used in a Script object of type "Modify"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "DualSweepAttr"
to the Script object to see it.
These are the parameters of the DualSweep:
"Type"
similar to the corresponding property of the Sweep object,
this allows to set the type of the resulting surface (open, closed, or
periodic)."Sections"
number of sections to use, also works in similar
fashion as for the Sweep object
(see also
SweepAttr Property).
The default value is 0, i.e. the number of sections are determined
from the parameter curves dimensions.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/dualsweep.ay"
.
The script "tsurf.tcl"
creates a translational surface from two
parameter curves, see also the above image.
The control points of the translational surface are created by copying
the control points of the first curve n times, where
n is the number of control points of the second curve, while also
offsetting the points according to the offset of the nth control point to
the first control point of the second curve.
The curves do not need to touch in any point, but if they start in the same point, the translational surface will interpolate both curves.
Rational parameter curves are currently not supported.
This script must be used in a Script object of type "Modify"
(see section
Script Object).
As the surface is completely defined by the parameter curves, there are
no additional parameters and there is, consequently, also no property GUI.
An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/tsurf.ay"
.
The script "extruden.tcl"
extrudes a NURBS curve along
its normal, see also the above image.
If the curve object has a MN tag, it will take precedence
over the normal computation via "getPlaneNormal"
. This is faster and
also allows to create sheared extrusions.[∗]
Internally, the script creates a Skin from two curves, therefore, arbitrarily oriented and non-planar curves are supported.
This script must be used in a Script object of type "Modify"
(see section
Script Object).
For convenience, there is also a property GUI; one must add a "NP"
tag
of value "ExtrudeNAttr"
to the Script object to see it.
These are the parameters of the extrusion:
"Height"
is the amount of displacement of the second curve
along the normal, default is 1.0.An example scene file containing such an object is distributed with Ayam,
see the file:
"ayam/scn/scripts/extruden.ay"
.
"jtD"
Since Ayam 1.18 there is a complete example script for the JavaScript
scripting interface distributed as "polyhedron.js"
which
creates polyhedrons from Conway notations.
The script is based on the online Polyhedron VRML generator by
George W. Hart:
http://www.georgehart.com/virtual-polyhedra/conway_notation.html
This script must be used in a Script object of type "Create"
(see section
Script Object).
For convenience, there is also a property GUI; to make this GUI visible
a "NP"
tag of value "PolyhedronAttr"
must be added to the Script
object.
The Conway notation defines a set of operations executed consecutively on a seed/basic shape. The script currently supports the following seeds and operations (information taken from George W. Harts fine web pages, see above).
Seeds:
The Platonic solids are denoted T, O, C, I, and D, according to their
first letter. Other polyhedra which are implemented here include prisms:
Pn, antiprisms: An, and pyramids: Yn, where n is a number (3 or greater)
which must be specified to indicate the size of the base, e.g. ,
Y3=T, P4=C, and A3=O.
Operations:
Currently, d, t, k, a, j, s, g, e, b, o, m, r, and p are defined.
They are motivated by the operations needed to create the Archimedean
solids and their duals from the Platonic solids. The following tables
explain the operations in more detail:
Letter | Name | Description |
d | dual | The dual of a polyhedron has a vertex for each face, and a face for each vertex, of the original polyhedron, e.g. dC=O. |
t / t n | truncate all / just n-fold vertices | Truncating a polyhedron cuts off each vertex, producing a new n-sided face for each n-fold vertex. |
k / k n | kis all / just n-sided faces | The kis operation divides each n-sided face into n triangles. A new vertex is added in the center of each face. |
a | ambo | The ambo operation can be thought of as truncating to the edge midpoints. It produces a polyhedron, aX, with one vertex for each edge of X. |
j | join | The join operator is dual to ambo, so jX=dadX=daX. jX is like kX without the original edges of X. |
e | expand | Each face of X is separated from all its neighbors and reconnected with a new 4-sided face, corresponding to an edge of X. An n-gon is then added to connect the 4-sided faces at each n-fold vertex. |
s | snub | The snub operation can be thought of as eC followed by the operation of slicing each of the new 4-fold faces along a diagonal into two triangles. With a consistent handedness to these cuts, all the vertices of sX are 5-fold. |
g | gyro | The dual operation to s is g. g is like k but with the new edges connecting the face centers to the 1/3 points on the edges rather than the vertices. |
b | bevel | The bevel operation can be defined by bX=taX. |
o | ortho | Dual to e, oX=deX=jjX. oX has the effect of putting new vertices in the middle of each face of X and connecting them, with new edges, to the edge midpoints of X. |
m | meta | Dual to b, m is like k and o combined; new edges connect new vertices at the face centers to the old vertices and new vertices at the edge midpoints. |
Letter | Name | Description |
r | reflect | Changes a left-handed solid to right handed, or vice versa, but has no effect on a reflexible solid. So rC=C, but compare sC and rsC. |
p | propellor | Makes each n-gon face into a "propellor" of an n-gon surrounded by n quadrilaterals, e.g. pT is the tetrahedrally stellated icosahedron. Try pkD and pt6kT. p is a self-dual operation, i.e., dpdX=pX and dpX=pdX, and p also commutes with a and j, i.e. paX=apX. |
These abbreviated explanations were again taken from George W. Hart.
This sections contains the documentation of the JavaScript scripting
interface which is available after loading of the "jsinterp"
plugin.
The JavaScript scripting interface exists since Ayam 1.18 and is based on the Mozilla SpiderMonkey JavaScript engine.
Upon loading, the "jsinterp"
plugin creates one JavaScript
context that lives (with all variables and objects defined therein)
until Ayam exits.
The JavaScript functionality may be accessed from the Tcl scripting interface
via the "jsEval"
command. The command can be used either to
directly execute JavaScript code provided via the commands argument
(Tcl code in bold):
» jsEval {var a = 0; a = a + 5.5; tclset("a", a);}
or to execute JavaScript code from a file:
» jsEval -f scriptfile.js
Note, that this command is not available in the safe interpreter.
Furthermore, Script object scripts may also be implemented in JavaScript, provided the first line of the script is a comment that instructs Ayam to use the JavaScript interpreter:
/* Ayam, use: JavaScript */
var a = 0;
...
Note that the JavaScript scripting context inherits the limitations
of the calling Tcl context.
For example, when running in a Script object,
the following code fails:
tcleval("exit");
because the Tcl command "exit"
is not available in the safe interpreter.
The command will not fail, when the calling context is the main Tcl
interpreter; one can e.g. type into the Ayam console:
» jsEval {tcleval("exit");}
and Ayam quits (see also section:
Safe Interpreter).
This subsection informs about the global functions additionally available in the Ayam JavaScript interpreter.
Those are converted Tcl commands (e.g. "crtOb()"
),
"tcleval()"
, "tclvar()"
, and "tclset()"
.
Converted Commands:
The functionality of Ayam is accessible from JavaScript via a larger
set of global functions, named as the corresponding Tcl commands.
For instance, Ayam objects can be created in JavaScript using a function call
like this:
crtOb("NCircle");
or, with additional arguments:
crtOb("NCircle", "-radius", 3.0);
In general, all commands available in the safe Ayam Tcl interpreter are also
available as function (refer to section
Procedures and Commands
for a more or less complete list of those commands).
Note that Tcl procedures are generally not available as global JavaScript
function, but they can be called using "tcleval()"
as documented
in the next paragraph.
tcleval():
This global JavaScript function allows to evaluate arbitrary
Tcl scripts, delivered as string argument:
var a = 42;
a = tcleval("puts " + a + "; return 5;");
tcleval("puts " + a);
/* expected output: 42 5 */
The "tcleval()"
function provides access to all the
functionality of Ayam that is just available as a Tcl procedure.
Note that return values are properly transferred back to JavaScript
according to the rules for data conversion as documented below.
However, due to an intermediate conversion to string data, the overhead of
such a call is considerable and bulk data transport should be arranged
by other means, see below.
tclvar():
Using the JavaScript function "tclvar()"
a link between a Tcl
variable and a corresponding variable in the
JavaScript context may be established.
The "tclvar()"
function essentially creates a write trace on the Tcl
variable, so that changes on the Tcl side are always automatically
reflected on the JavaScript side:
tclvar("a");
tcleval("set a 42");
tcleval("puts " + a);
/* expected output: 42 */
Mind that the corresponding variable on the JavaScript side does
not exist until the first write operation on the Tcl variable
occurs.
The Tcl variable, in turn, does not have to exist, when the
"tclvar()"
function is called (i.e. all the work is done
in the trace callback). If the variable name contains a namespace
specifier, this namespace has to exist, when "tclvar()"
is called.
Even though it looks a perfect fit, "tclvar()"
can not be used to
manage a property data array (if the array contains components
to be saved to Ayam scene files). This is, because upon reading a scene
file with such saved array items, the items will be read (and put into
the Tcl context) before the script can establish the write trace using
"tclvar()"
and the data from the scene file never arrives in the
JavaScript context.
There is no easy way to get around this.
A suggested way to manage a property data array is shown in the
complete examples section below.
tclset():
The third global JavaScript function is "tclset()"
that
allows to efficiently set Tcl variables from the JavaScript context
avoiding conversion to string data and back.
For example:
var a = 3.3;
var b = new Array(1, 3, 5);
tclset("a", a);
tclset("b", b);
sets the Tcl variable "a"
to the floating point value 3.3,
and "b"
to a list of integer values
{ 1 3 5 }
.
tclset("SphereAttrData(Radius)", 1.2);
sets the Radius
element in the SphereAttrData
array;
or contain namespace specifiers, for example
tclset("::MyNameSpace::Radius", 1.2);
sets the Radius
variable in the MyNameSpace
namespace.
When data is transferred from the Tcl to the JavaScript side
(e.g. while converting return values of "tcleval()"
or variable
values linked via "tclvar()"
),
the following conversions are in effect:
Scalar data types will be converted to their directly matching counterparts,
except for Booleans, which will be converted to integer values.
Lists will be converted to Array objects (nesting is allowed and will
produce accordingly nested arrays).
Associative arrays will be converted to objects with named properties.
Unicode strings are currently not supported.
See also the table below.
Tcl | JavaScript |
Boolean (true, false) | Integer (1, 0) |
Integer (2) | Integer (2) |
Double (3.14) | Double (3.14) |
String ("mystr") | String ("mystr") |
List ({0 1 2}) | Array ((0, 1, 2)) |
Array (mya(mye) = 0.1) | Object (mya.mye = 0.1) |
When data is transferred from the JavaScript side to the Tcl side (e.g. as function argument), the following conversions are in effect: Scalar data types will be converted to their directly matching counterparts, Array objects will be converted to lists (nesting is allowed and will produce accordingly nested lists). Unicode strings and objects of a type other than Array (e.g. Boolean) are currently not supported. See also the following table.
JavaScript | Tcl |
Integer (2) | Integer (2) |
Double (3.14) | Double (3.14) |
String ("mystr") | String ("mystr") |
Array ((0, 1, 2)) | List ({0 1 2}) |
The transport/conversion of object properties (to e.g. associative array elements) can be arranged manually like this:
var a = new Object();
a.b = 3.14;
tclset("a(b)", a.b);
This section contains two complete examples for Script objects written in JavaScript.
For the first example use Script object type "Modify"
and put a Sphere
as child object of the Script object.
/* Ayam, use: JavaScript */ tclvar("SphereAttrData"); getProp(); if(SphereAttrData) { tclset("SphereAttrData(ZMin)", -SphereAttrData.Radius); tclset("SphereAttrData(ZMax)", SphereAttrData.Radius); setProp(); }
First, a link from the original Sphere object property data array
"SphereAttrData"
is established, so that when "getProp()"
(a converted Tcl Ayam command) is called, also the JavaScript
object "SphereAttrData"
is filled with meaningful data.
The next line (the if
) is a safety measure that prevents the script
from failing if the child object of the Script object is not a Sphere
object.
Now the radius value is transferred back to Tcl directly into
the property data array to the ZMin and ZMax entries respectively
with the help of "tclset()"
.
Finally, the modified property is transferred back to the Sphere object
again with a converted Tcl Ayam command "setProp()"
.
The next example shows, how to manage a property GUI in a JavaScript
implemented Script object script. Use Script object type "Create"
and add a tag "NP MyProp"
to see the property GUI.
/* Ayam, use: JavaScript, save array: MyPropData */ var MyPropData = new Object(); if(!tcleval("info exists MyPropData;")) { /* initial script run (but not when loaded from scene file!) */ MyPropData.MyItem = tcleval("set MyPropData(MyItem) 1.0;"); tcleval("set MyPropData(SP) {MyItem};"); } else { /* all following script runs (and also when loaded from scene file!) */ MyPropData.MyItem = tcleval("set MyPropData(MyItem);"); } if(!tcleval("info exists MyPropGUI;")) { tcleval("set ::phw [addPropertyGUI MyProp \"\" \"\"];"); tcleval("addParam $::phw MyPropData MyItem;"); } crtOb("Sphere"); sL(); getProp(); tclset("SphereAttrData(Radius)", MyPropData.MyItem); tclset("SphereAttrData(ZMin)", -MyPropData.MyItem); tclset("SphereAttrData(ZMax)", MyPropData.MyItem); setProp();
This example demonstrates how to manage property data using the
JavaScript object variable "MyPropData"
. The property data
can be saved to and read from Ayam scene files with the help of
a mirroring array variable on the Tcl side (also named
"MyPropData"
).
To make this work properly, the initialisation of the JavaScript
object must be constrained to the first script run: when the
property data was read from a scene file, initialisation must
not be run, instead the read data must be fetched from the Tcl
context.
This is what the first "if"
statement, checking for existence
of the mirroring Tcl array variable, in above example is all about.
Following this scheme of dual mirroring data structures on the
Tcl and JavaScript sides, now the property GUI is created, which is also
constrained to just one script run by a similar "if"
statement.
After the GUI, a Sphere object is created and parameterised according to the data in the property GUI, which is used as radius, zmin, and zmax value.
This sections contains the documentation of the Lua scripting
interface which is available after loading of the "luainterp"
plugin.[∗]
Upon loading, the "luainterp"
plugin creates one Lua
context that lives (with all variables and objects defined therein)
until Ayam exits.
The Lua functionality may be accessed from the Tcl scripting interface
via the "luaEval"
command. The command can be used either to
directly execute Lua code provided via the commands argument
(Tcl code in bold):
» luaEval {a = 0; a = a + 5.5; tclset("a", a);}
or to execute Lua code from a file:
» luaEval -f scriptfile.lua
Note, that this command is not available in the safe interpreter.
Furthermore, Script object scripts may also be implemented in Lua, provided the first line of the script is a comment that instructs Ayam to use the Lua interpreter:
-- Ayam, use: Lua
a = 0
...
Note that the Lua scripting context inherits the limitations
of the calling Tcl context.
For example, when running in a Script object,
the following code fails:
tcleval("exit")
because the Tcl command "exit"
is not available in the safe interpreter.
The command will not fail, when the calling context is the main Tcl
interpreter; one can e.g. type into the Ayam console:
» luaEval {tcleval("exit")}
and Ayam quits (see also section:
Safe Interpreter).
This subsection informs about the global functions additionally available in the Ayam Lua interpreter.
Those are converted Tcl commands (e.g. "crtOb()"
),
"tcleval()"
, "tclvar()"
,
and "tclset()"
.
Converted Commands:
The functionality of Ayam is accessible from Lua via a larger
set of global functions, named as the corresponding Tcl commands.
For instance, Ayam objects can be created in Lua using a function call
like this:
crtOb("NCircle")
or, with additional arguments:
crtOb("NCircle", "-radius", 3.0)
In general, all commands available in the safe Ayam Tcl interpreter are also
available as function (refer to section
Procedures and Commands
for a more or less complete list of those commands).
Note that Tcl procedures are generally not available as global Lua function,
but they can be called using "tcleval()"
as documented
in the next paragraph.
tcleval():
This Lua function allows to evaluate arbitrary
Tcl scripts, delivered as string argument:
a = 42
a = tcleval("puts " .. a .. "; return 5;")
tcleval("puts " .. a)
-- expected output: 42 5
The "tcleval()"
function provides access to all the
functionality of Ayam that is just available as a Tcl procedure.
Note that return values are properly transferred back to Lua
according to the rules for data conversion as documented below.
However, due to an intermediate conversion to string data, the overhead of
such a call is considerable and bulk data transport should be arranged
by other means, see below.
tclvar():
Using the Lua function "tclvar()"
a link between a Tcl variable
and a corresponding variable in the Lua context can be established.
The "tclvar()"
function creates a write trace on the Tcl
variable, so that changes on the Tcl side are always automatically
reflected on the Lua side:
tclvar("a")
tcleval("set a 42")
tcleval("puts " .. a)
-- expected output: 42
Mind that the corresponding variable on the Lua side does
not exist until the first write operation onto the Tcl
variable occurs.
The Tcl variable, in turn, does not have to exist, when the
"tclvar()"
function is called (i.e. all the work is done
in the trace callback). If the variable name contains a namespace
specifier, this namespace has to exist, when "tclvar()"
is called.
Even though it looks a perfect fit, "tclvar()"
can not be used to
manage a property data array (if the array contains components
to be saved to Ayam scene files). This is, because upon reading a scene
file with such saved array items, the items will be read (and put into
the Tcl context) before the script can establish the write trace using
"tclvar()"
and the data from the scene file never arrives in the Lua
context.
There is no easy way to get around this.
A suggested way to manage a property data array is shown in the
complete examples section below.
tclset():
The third global Lua function is "tclset()"
that
allows to efficiently set Tcl variables from the Lua context
avoiding conversion to string data and back.
For example:
a = 3.3
b = {1, 3, 5}
tclset("a", a)
tclset("b", b)
sets the Tcl variable "a"
to the floating point value 3.3,
and "b"
to a list of integer values
{ 1 3 5 }
.
tclset("SphereAttrData(Radius)", 1.2)
sets the Radius
element in the SphereAttrData
array;
or contain namespace specifiers, for example
tclset("::MyNameSpace::Radius", 1.2)
sets the Radius
variable in the MyNameSpace
namespace.
When data is transferred from the Tcl to the Lua side
(e.g. while converting return values of "tcleval()"
or variable
values linked via "tclvar()"
),
the following conversions are in effect:
Scalar data types will be converted to their directly matching counterparts.
Lists will be converted to array-tables (nesting is allowed and will
produce accordingly nested tables).
Associative arrays will be converted to tables with properly named keys.
Unicode strings are currently not supported.
See also the table below.
Tcl | Lua |
Boolean (true, false) | Boolean (true, false) |
Integer (2) | Integer (2) |
Double (3.14) | Double (3.14) |
String ("mystr") | String ("mystr") |
List ({0 1 2}) | Array ({0, 1, 2}) |
Array (mya(mye) = 0.1) | Table (mya.mye = 0.1) |
When data is transferred from the Lua side to the Tcl side (e.g. as function argument), the following conversions are in effect: Scalar data types will be converted to their directly matching counterparts, array-tables will be converted to lists (nesting is allowed and will produce accordingly nested lists). Sparse and mixed tables are currently not supported. Unicode strings are also currently not supported. See also the following table.
Lua | Tcl |
Boolean (true, false) | Boolean (true, false) |
Integer (2) | Integer (2) |
Double (3.14) | Double (3.14) |
String ("mystr") | String ("mystr") |
Array ({0, 1, 2}) | List ({0 1 2}) |
The transport/conversion of table entries (to e.g. associative array elements) can be arranged manually like this:
a.b = 3.14
tclset("a(b)", a.b)
This section contains two complete examples for Script objects written in Lua.
For the first example use Script object type "Modify"
and put a Sphere
as child object of the Script object.
-- Ayam, use: Lua tclvar("SphereAttrData") getProp() if SphereAttrData then tclset("SphereAttrData(ZMin)", -SphereAttrData.Radius) tclset("SphereAttrData(ZMax)", SphereAttrData.Radius) setProp() end
First, a link from the original Sphere object property data array
"SphereAttrData"
is established, so that when "getProp()"
(a converted Tcl Ayam command) is called, also the Lua
object "SphereAttrData"
is filled with meaningful data.
The next line (the if
) is a safety measure that prevents the script
from failing if the child object of the Script object is not a Sphere
object.
Now the radius value is transferred back to Tcl directly into
the property data array to the ZMin and ZMax entries respectively
with the help of "tclset"
.
Finally, the modified property is transferred back to the Sphere object
again with a converted Tcl Ayam command "setProp()"
.
The next example shows, how to manage a property GUI in a Lua
implemented Script object script. Use Script object type "Create"
and add a tag "NP MyProp"
to see the property GUI.
-- Ayam, use: Lua, save array: MyPropData if tcleval("info exists MyPropData;") == 0 then -- initial script run (but not when loaded from scene file!) MyPropData = {} MyPropData.MyItem = tcleval("set MyPropData(MyItem) 1.0;") tcleval("set MyPropData(SP) {MyItem};") else -- all following script runs (and also when loaded from scene file!) MyPropData = {} MyPropData.MyItem = tcleval("set MyPropData(MyItem);") end if tcleval("info exists MyPropGUI;") == 0 then -- create property GUI "MyProp" tcleval("set ::phw [addPropertyGUI MyProp \"\" \"\"];") tcleval("addParam $::phw MyPropData MyItem;") end crtOb("Sphere") sL() getProp() tclset("SphereAttrData(Radius)", MyPropData.MyItem) tclset("SphereAttrData(ZMin)", -MyPropData.MyItem) tclset("SphereAttrData(ZMax)", MyPropData.MyItem) setProp()
This example demonstrates how to manage property data using the
Lua object variable "MyPropData"
. The property data
can be saved to and read from Ayam scene files with the help of
a mirroring array variable on the Tcl side (also named
"MyPropData"
).
To make this work properly, the initialisation of the Lua
object must be constrained to the first script run: when the
property data was read from a scene file, initialisation must
not be run, instead the read data must be fetched from the Tcl
context.
This is what the first "if"
statement, checking for existence
of the mirroring Tcl array variable, in above example is all about.
Following this scheme of dual mirroring data structures on the
Tcl and Lua sides, now the property GUI is created, which is also
constrained to just one script run by a similar "if"
statement.
After the GUI, a Sphere object is created and parameterised according to the data in the property GUI, which is used as radius, zmin, and zmax value.