IamTheCarl / CommandCAD

A script driven CAD program with dimensional analysis.
GNU Affero General Public License v3.0
16 stars 0 forks source link

Command CAD

In my frustration with the state of CAD software as a whole, I lost my mind and wrote my own CAD program. Out of all of the ones I've used, the only ones that are really palatable are OpenSCAD and CAD Query. Command CAD takes most of its inspiration from these two. Command CAD has some critical differences though, like a stronger and convenient type safety for its scripting language and a more modular design.

Please note that Command CAD is in a highly experimental state, do not expect stability, even in the short term

Observe the following example:

main_body = 15;

This is valid syntax for both OpenSCAD and CAD Query. The following critical information is missing:

In the past I've worked around this issue with naming conventions:

main_body_length_cm = 15;

We now know the dimension and the unit, but there are problems:

Command CAD's solution to this problem is to make dimension and unit a part of the language:

let main_body: Length = 15cm;
let nominal_angle_to_sun: Angle = 60deg;
let solar_panel_size: Area = main_body * 1m; // A length * by a length gives an area.
let nominal_power_output: Power = solar_panel_size * nominal_angle_to_sun.sin() * (30w/1m^2); // 30watts per square meter multiplied by square meters results in watts.

Not only is the dimension of measurements tracked and verified for you (preventing common mathematical errors), but the units are automatically converted as well. If I were to do all my calculations using meters and then specify that my STL file should use millimeters, Command CAD will convert all of the final results to millimeters when exporting the STL file.

Dimensional analysis also applies to linear algebra types.

vec3(1m, 2m, 3m) * 4 == vec3(4m, 8m, 12m)
vec3(1m, 2m, 3m) * 4m == vec3(4m^2, 8m^2, 12m^2)

Design Goals

Current features

Alternatives

Other code based CAD programs exist, and with how experimental Command CAD currently is, you should probably prefer them.

CAD Query

OpenSCAD