Skip to main content

var

Kind: Function
Domain: Expressions, units, and tolerances
Canonical import: from cadflow import var

Signature

def var(name: 'str', default: 'int | float', comment: 'str | None' = None, tolerance: 'ToleranceLike | None' = None, *, unit: 'UnitLike | None' = None, tolerance_unit: 'UnitLike | None' = None) -> 'Var'

Description

Create a physical or legacy scalar variable.

Create a physical or legacy scalar variable.

tolerance=0.1 declares a symmetric +/-0.1 tolerance. Use a (lower_deviation, upper_deviation) pair for an asymmetric tolerance. tolerance_unit defaults to unit when a nominal unit is declared. Values are converted to canonical CAD units only when evaluated, so the declaration and serialized expression node preserve the user's units.

Variables without unit retain legacy unitless behavior. A unit-aware expression cannot mix declared-unit variables with legacy variables.

Parameters

NameTypeRequiredDefaultSource description
name'str'yes-Not explicitly described in the source docstring.
default'int | float'yes-Not explicitly described in the source docstring.
comment'str | None'noNoneNot explicitly described in the source docstring.
tolerance'ToleranceLike | None'noNoneNot explicitly described in the source docstring.
unit'UnitLike | None'noNoneNot explicitly described in the source docstring.
tolerance_unit'UnitLike | None'noNoneNot explicitly described in the source docstring.

Returns

Type: 'Var'

The source docstring does not declare additional return semantics.

Errors

The source docstring does not declare a narrower exception contract. Invalid types, values, ownership, paths, or backend state may still raise the corresponding public error.

Behavior and constraints

  • The contract below is generated from the current public runtime signature. Check domain notes for ownership and workflow constraints.

Import check

from cadflow import var

See also