Expressions, units, and tolerances
CadFlow's expression layer separates symbolic design intent from numeric geometry. Its unit layer prevents invalid dimensional combinations, while tolerance objects describe intervals and dependency graphs for manufacturing analysis.
Expressions
Public expression types represent constants, parameters, unary and binary operations, comparisons, conditionals, and supported mathematical functions. Build expressions through the public constructors and operators, then evaluate them against an explicit parameter environment.
width = cad.var("width", 40.0)
wall = cad.var("wall", 2.0)
inner = width - 2 * wall
value = inner.evaluate({"width": 50.0, "wall": 2.5})
Parameter names should be stable identifiers. Evaluation rejects missing required parameters, invalid types, unsupported operations, and domain errors such as invalid square roots or division by zero.
Dimensions and quantities
A quantity pairs a scalar expression or value with a physical dimension. Addition and comparison require compatible dimensions. Multiplication and division derive a new dimension. Trigonometric and transcendental functions enforce their documented dimension rules.
Use explicit conversion helpers at file, UI, and solver boundaries. Preserve unit labels with serialized engineering values; a plain float cannot prove whether it represents millimeters, meters, degrees, or radians.
Tolerances
Tolerance APIs describe nominal values, permitted variation, statistical assumptions, and dependency relationships. They can compute interval or statistical contributions and return structured reports.
Typical sequence:
- Define named source dimensions and their tolerances.
- Build the dependent expression or tolerance graph.
- Select the supported analysis method.
- Evaluate the result and inspect contributors, limits, and diagnostics.
- Record units and assumptions alongside the report.
Tolerance analysis characterizes the declared model. It does not infer process capability, correlations, or distribution shape that were not provided.
Interoperability with geometry
Evaluate expressions and convert quantities before calling compact Model methods, which accept numeric values:
width_mm = float(width.evaluate(parameters))
with cad.Model() as model:
body = model.box(width_mm, 30.0, 4.0)
Validate finite values and expected dimensions before dispatch. Keep the symbolic source and evaluated parameter set in Model JSON or application metadata when the geometry must be reproduced.
The expressions, units, and tolerances catalog lists all 59 public symbols with exact signatures.