Language Documentation - MacCurdyLab/OpenVCAD-Public GitHub Wiki

Language Overview

OpenVCAD employees a node-based modeling language that is similar to the OpenSCAD language. The key difference is that OpenVCAD was designed to support multi-material designs. OpenVCAD files, or simply .VCAD files are simple text files that express a hierarchical tree of nodes similar to abstract syntax trees (ASTs) or constructive solid geometry (CSG). The OpenVCAD modeling language has three categories of nodes: geometric primitives, composition, and material. The figure below shows how OpenVCAD nodes can be used to generate multi-material designs. OpenVCAD Tree Example

OpenVCAD designs are expressed using a scripting language. The language is a simple text file that contains a root() with any number of child nodes. The following example shows an OpenVCAD script that generates a simple one material object using two geometric primitive nodes and a composition node.

root((-5, -5, -5), (5, 5, 5), (0.05, 0.05, 0.05))
{
    difference()
    {
        sphere(1.0, "red");
        cube(1.0, "red");
    }
}

Simple VCAD Object Example

Coordinate Systems

OpenVCAD supports cartesian, cylindrical, and spherical coordinates systems in all expressions. See Coordinate Systems for more information.

Units

OpenVCAD assumes that all distances are in mm and angles are in degrees.

Nodes

Root Node

The root node is a special node that must be at the start of all .VCAD designs. It contains information about how the design should be compiled in real-world space. The root node takes the form:

root((MIN_X, MIN_Y, MIN_Z), (MAX_X, MAX_Y, MAX_Z), (VOX_X, VOX_Y, VOX_z))
{
    // Children nodes go here
}

Here, the MIN and MAX values form the range in real world coordinates the sample the design across when compiling. The compiler will start a (MIN_X, MIN_Y, MIN_Z) and end at (MAX_X, MAX_Y, MAX_Z). The (VOX_X, VOX_Y, VOX_z) specify the X, Y, and Z voxel dimensions in mm.

Note: A root note is a pseudo union node, meaning that it may have any number of children that are combined into a single node when compiled.

Note: Voxels may be asymmetric as is common with multi-material 3D-printers. This mean that exported PNG stacks may look distorted when using an asymmetric voxel size. If the 3D-printer is configured to use the same asymmetric size, then this will not be a problem.

Other Nodes

OpenVCAD's three node types are documented in the following pages:

  1. Geometric Primitive Nodes: provides an overview of the geometric primitives (leaf nodes) that can be used in OpenVCAD
  2. Composition Nodes: provides an overview of the composition nodes (transforms & boolean operations) that can be used in OpenVCAD
  3. Material Nodes: provides an overview of the material nodes (convolution & functional grading) that can be used in OpenVCAD

Comments

OpenVCAD uses C-style comments. // are used for single line comments and /* */ are used for multi-line comments.