Syntax Reference
The following is a cheat sheet style reference for all operators in DSLCAD. Please refer to the examples folder for even more reference on how to build parts.
Cheat Sheet
Syntax
var name = value;create a variable called name that stores valuevalue;draw the value, each script can only draw one thingb(name=a)pass a into the name parameter of function ba ->name b()pipe a into the name parameter of function b./file(name=a)run a file as if it were a functionmodel.dataaccess data of a modellist[5]get the fifth item of a listif a: something() else: something_else();test a and follow one branch depending on the value
Lists
[1,2,3]make a list with three numbersmap MY_LIST as NAME: OPERATIONloop over every entry in MY_LISTreduce MY_LIST as NAME1,NAME2: OPERATIONcombine every item in MY_LISTreduce MY_LIST from BASE as NAME1,NAME2: OPERATIONcombine every item in MY_LIST starting from BASE
Operators
a + badditiona - bsubtractiona * bmultiplicationa / bdivisiona % bmoduloa ^ bpower
Logic
a < bless thana <= bless than or equala == bequala != bnot equala > bgreater thana >= bgreater than or equala and blogical anda or blogical ornot alogical not
Properties
point.{x,y,z}properties of points2d_value.{center}properties of 2D objects3d_value.{center}properties of 3D objects
Math
pi()constant pirad_to_deg(radians=number)convert radians to degreesdeg_to_rad(degrees=number)convert degrees to radianssin(degrees=number)sin operationsin(radians=number)sin operationcos(degrees=number)cos operationcos(radians=number)cos operationtan(degrees=number)tan operationtan(radians=number)tan operationround(number=number)round to the nearest whole numberceil(number=number)round up to a whole numberfloor(number=number)round down to a whole numbersqrt(number=number)square root of a number
2D
point(x=[number], y=[number], z=[number])create a new 2D pointline(start=point, end=point)create a line between two pointssquare(x=[number], y=[number])create a squarecircle(radius=[number])create a circlearc(start=point, center=point, end=point)create an arcing line between three pointsunion(left=edge, right=edge)combine two edgesface(parts=list)make a closed face from a list of points, lines and arcstranslate(shape=edge, x=[number], y=[number], z=[number])move an edgerotate(shape=edge, angle=[number])rotate an edgerotate(shape=edge, x=[number], y=[number], z=[number])rotate an edgescale(shape=edge, scale=number)scale an edgecenter(shape=edge, x=[bool], y=[bool], z=[bool])center an edgeoffset(shape=edge, distance=number)offset an edge
3D
extrude(shape=edge, x=[number], y=[number], z=[number])extrude a face into a 3D shaperevolve(shape=edge, x=[number], y=[number], z=[number])extrude a face into a 3D shape around an axiscube(x=[number], y=[number], z=[number])create a cubesphere(radius=[number])create a spherecylinder(radius=[number], height=[number])create a cylinderunion(left=shape, right=shape)combine two shapeschamfer(shape=shape, radius=number)chamfer edgesfillet(shape=shape, radius=number)fillet edgesdifference(left=shape, right=shape)cut one shape out of anotherintersect(left=shape, right=shape)intersection between two shapestranslate(shape=shape, x=[number], y=[number], z=[number])move a shaperotate(shape=shape, x=[number], y=[number], z=[number])rotate a shapescale(shape=shape, scale=number)scale a shapescale(shape=shape, x=[number], y=[number], z=[number])scale a shapecenter(shape=shape, x=[bool], y=[bool], z=[bool])center a shapeslice(left=shape, right=edge)cut a slice out of a shapeslice(left=shape, right=shape)cut a slice out of a shape
Lists
length(list=list)get the length of a listrange(start=[number], end=number)create a list of numbers from a range
Text
string(item=*)convert to textformat(message=text, ...)format text using {my_arg} style formattingformatln(message=text, ...)format text with newline