Concepts
DSLCAD has some main concepts to understand when modeling. This page does over them at a high level and explains their intended use. For a more detailed list of operations check out the Syntax Reference page.
Shapes
When building anything in DSLCAD you need to start somewhere. Normally this is done by starting with a 2D or 3D shape.
2D Shapes
The basic 2D shapes are made using the square
and circle
functions.
square(x=5, y=7);
circle(radius=7);
3D Shapes
The basic 3D shapes are made using the cube
, sphere
and cylinder
functions.
cube(x=1, y=3, z=5);
sphere(radius=4);
cylinder(radius=2, height=4);
Operations
Moving Objects
Often you need to position objects in 3D space.
The translate
function lets you move an object.
The rotate
function lets you rotate an object around the x, y or z axis.
The scale
function lets scale an object up or down.
// Cube moved up the z axix by 2 units
cube() > translate(z=2);
// Cube rotated 225 degrees
cube() > rotate(z=180 + 45);
// Cube doubled in size
cube() > scale(scale=2);
The center
function lets you center any object on any axis you want.
// Cube centered on the x and y axis.
cube() > center(z=false);
Boolean Operations (CSG)
To manipulate 3D objects DSLCAD uses boolean operations (AKA Constructive Solid Geometry).
You can combine two objects using the union
function. This joins both object into a single object.
// Cube combined with a sphere
cube() > union(sphere(radius=1));
You can cut away at an object using the difference
function. This removes the second object from the first object.
// Cube with a sphere cut out
cube() > difference(sphere(radius=1));
You can get the overlap using the intersect
function. This leaves the overlapping parts of both objects.
// Overlap of a cube and sphere
cube() > intersect(sphere(radius=1));
2D to 3D
2D objects can be converted to 3D objects using the extrude
or revolve
functions.
// Extrude a square into a rectangular cube
square() > extrude(z=2);
// Revolve a square around the y axis to make a half moon
square() > revolve(y=180);
3D to 2D
Sometimes you need a 2D outline of a 3D part, use the slice
function to cut a crosssection.
// Cut the outline of a complex shape
cube()
> union(sphere() > translate(y=0.9))
> center(x=false, y=false)
> slice(square(x=10, y=10));
Scopes
For private variables, you can make use of scopes:
var object = {
var base = 10;
var height = 10;
cube(x=base, y=base, z=height);
};
object;
Parts
Simple projects can get away with single 3D models. For more complex projects it is often useful to break things into multiple parts.
You can make multiple parts in the same script. Just separate each part into its own statement like so:
./part1();
./part2();
If you wanted them to be a single part you can join them with a union
to form
a single object.
./part1() >left union(right=./part2());
Workflow
DSLCAD is designed with an opinionated workflow in mind. Following this will help you build high quality parts quickly.
For every part that you want to build:

Start with 2D sections of it. Currently, the
face
function is the simplest way to create any 2D sketch. 
Extrude your face into a 3D section using
extrude
orrevolve
to bring your face into the 3D world. 
Combine 3D sections using
union
,difference
andintersect
to cut out the final dimensions of your part. 
[OPTIONAL] Use
chamfer
orfillet
to add a polished look to the part.