Parts and assemblies
CadFlow's product layer separates reusable part geometry from its occurrences in an assembly. A Part owns a body and optional connectors or material; an assembly component references that item with a component ID and placement.
This high-level API is part of the bundled compatibility feature layer and is publicly available from cadflow and cadflow.assembly.
Reuse one part in multiple placements
import cadflow as cad
bolt_body = cad.make_cylinder_rsolid(1.0, 2.0)
bolt_part = cad.make_part_rpart("bolt", bolt_body, name="M2 bolt")
assembly = cad.make_assembly_rassembly("fixture")
assembly = cad.add_component_rassembly(
assembly,
bolt_part,
component_id="bolt_left",
placement=cad.make_placement_rplacement(origin=(-5.0, 0.0, 0.0)),
)
assembly = cad.add_component_rassembly(
assembly,
bolt_part,
component_id="bolt_right",
placement=cad.make_placement_rplacement(origin=(5.0, 0.0, 0.0)),
)
compound = cad.make_compound_from_assembly_rcompound(assembly)
Product values are updated functionally. Assign the returned value from add_component_rassembly instead of expecting in-place mutation.
Assign material explicitly
Part creation and material assignment are separate operations:
aluminum = cad.make_material_rmaterial(
"aluminum_6061",
name="Aluminum 6061",
density=2.7e-6,
density_unit="kg/mm^3",
color=(0.70, 0.70, 0.75),
)
plate = cad.make_part_rpart("base_plate", plate_body, name="Base plate")
plate = cad.assign_material_rpart(plate, aluminum)
Units and engineering properties remain explicit; CadFlow does not infer them from a material name.
Use connectors for design intent
Connectors identify stable mating frames or topology on parts and assemblies. Public constructors cover placement, face, edge, and vertex connectors. Constraint references use component and connector IDs rather than ad hoc transforms.
Typical flow:
- Create the part body.
- Add a named connector to the part.
- Add part occurrences to the assembly.
- Ground one component or otherwise provide a reference.
- Add fixed, revolute, prismatic, gear, belt, or rack-pinion constraints.
- Solve and inspect the
ConstraintReport.
solved = cad.solve_assembly_constraints_rassembly(assembly, strict=False)
report = cad.inspect_assembly_constraints_rconstraintreport(solved)
if not report.ok:
for residual in report.residuals:
print(residual)
Use strict=True in release pipelines when unsolved or inconsistent constraints must fail immediately.
Kinematics versus physical connections
Assembly constraints answer which relative motions are allowed. The cadflow.physical layer describes where parts are joined and how a reduced-order interface carries load. Distributed contact between real faces belongs to cadflow.simulation and a downstream continuum solver.
Do not encode stiffness, friction, preload, or strength as kinematic constraints. Choose the layer that owns the intended claim.
Nested assemblies
Assemblies may contain parts or child assemblies. Placements compose from the root to each leaf. Use stable, unique component IDs at every level; forwarded connectors can expose a child interface at a parent boundary without flattening product structure.