KCL defines the following types and keywords the language.
All these types can be nested in various forms where nesting applies. Like arrays can hold objects and vice versa.
Constant declaration
Constants are defined with a name and a value, like so:
Currently you cannot redeclare a constant.
Objects
An object is defined with {} braces. Here is an example object:
To get the property of an object, you can call myObj.a, which in the above
example returns 0.
ImportedGeometry
Using import you can import geometry defined using other CAD software. In KCL,
these objects have type ImportedGeometry and can mostly be treated like any
other solid (they can be rotated, scaled, etc.), although there is no access to
their internal components. See the modules and imports docs for more
detail on importing geometry.
Tags
Tags are used to give a name (tag) to a specific path.
Tag declarations - TagDecl
The syntax for declaring a tag is $myTag. Tags are used for bodies (such as extrude cap faces). For sketches, reference segment names directly.
Example: Referencing sketch segments and tagging cap faces
In this example, you reference sketch segments by their names (e.g., line4). Tags (using $) are only needed for cap faces or other body features.
When a function requires declaring a new tag (using the $ syntax), the argument has type TagDecl.
Tag identifiers
A tag created using a tag declarator can be used by writing its name without the $, e.g., myTag.
Where necessary to disambiguate from tag declarations, we call these tag identifiers.
In the example above we use the tag identifier rectangleSegmentA001 to get the angle of the segment
using segAng(rectangleSegmentA001).
Tags can identify an edge or face of a solid. Functions that take a tag identifier as an argument will use either TaggedEdge (for the edge of a solid) or TaggedFace.
For sketches, always use the segment name (e.g., line1, line2).
START and END
START and END are special tags
for identifying the starting and ending faces of an extruded solid.
Tag Scope
Tags are scoped globally if declared in the root context. For bodies, you can use the tag anywhere in the file. For sketches, always use the segment name directly.
If you find any issues using any of the above expressions or syntax,
please file an issue with the ast label on the modeling-app
repo.