Turtle Script

The following commands can be parsed with Turtle Script within the logic panel of shape nodes.

Values inside () are optional.

mov x y (a)move to x y (degrees)
teleport turtle to location (direction)
drw x ydraw to location x y
dir adirection angle in degrees
0 is east, 90 is north
bezier ax ay ahx ahy bhx bhy bx by segmentscubic bezier with 2 handles
start handle1 handle2 end segments
molding type ax ay bx by segments tensionpoint-to-point tension curves
type* start end segments tension
*type: cove, ovolo, cymarecta, cymareversa, dome
rmov dx dyrelative move offset-x offset-y
skips over the offset, restarts the UV map
*shape must be OPEN
rdrw dx dyrelative draw offset-x offset-y
newpnew point creates a vertex in-situ and restarts the UV map
movfwd c (d)move forward (offset)
*shape must be OPEN
fwd c (d)forward (offset)
back c (d)back (offset)
right c (d)right (offset)
left c (d)left (offset)
turnl arotate counter-clockwise angle
turnr arotate clockwise angle
arcr a r sarc right angle radius segments
arcl a r s arc left angle radius segments
closedadds a segment connecting the last point to the first, and removes overlapped vertices
*required for ‘manifold topology’
*changes options under INPUT/OUTPUT
*also a bool switch under Output/Input
setset the value on a parameter
set parameter value
letcreate a temporary variable
let var value
loop repeat (count) (step)open a loop and repeat until done
(counter name) (steps per count)
endloopterminate loop
if conditionalopen a conditional directive when true
if boolrun conditional when bool is true
if !boolrun conditional when bool is false
endifterminate conditional directive
GTgreater than conditional
LTless than conditional
GEgreater or equal conditional
LElesser or equal conditional
EQequal conditional
NEnot equal conditional
//comment line
+

*
/
(
)
add
subtract (negative)
multiply
divide
order of operations
mathf functionsfunction returns a value
sqrt(pow(width,2)+pow(height,2))
Archimatix mathf functions
parameter nameuses the value of the node’s parameter
DetailLevelread-only parameter from graph setting: 0-1
*reduces segments on all nodes: 0.5 is 50%
*generate LOD models by reducing vertices
if DetailLevel LT .67

Example scripts:

The best way to learn AX Turtle Script is to open the Logic panel on any 2D shape node to see how it was made.

Parameter names on the node become dynamic variables in the script.

mov width/2 0 90
drw 0 height/2
drw –width/2 0
drw 0 –height/2

Output Shape: closed
if shift_origin
molding cove –width height 0 0 segs tension
endif

if !shift_origin
molding cove 0 height width 0 segs tension
endif

Output Shape: open
if inputHypotenuse
if solveWidth
set width Sqrt(hypotenuse*hypotenuseheight*height)
endif
set height Sqrt(hypotenuse*hypotenusewidth*width)
endif

set hypotenuse Sqrt(width*width+height*height)
set theta Atan2(height,width)
mov 0 0 90
right width
fwd height

Output Shape: closed
if bX GE aX
let mdX abs(bXaX)/(segs-1)
endif
if bX LT aX
let mdX -abs(bXaX)/(segs-1)
endif
if bY GE aY
let mdY abs(bYaY)/(segs-1)
endif
if bY LT aY
let mdY -abs(bYaY)/(segs-1)
endif
if cX GE bX
let ndX abs(cXbX)/(segs-1)
endif
if cX LT bX
let ndX -abs(cXbX)/(segs-1)
endif
if cY GE bY
let ndY abs(cYbY)/(segs-1)
endif
if cY LT bY
let ndY -abs(cYbY)/(segs-1)
endif

mov aX aY
loop segs i
mov aX+mdX*i aY+mdY*i
drw bX+ndX*i bY+ndY*i
endloop

Output Shape: open

Comments are closed.