yapcad.manufacturing package
Submodules
yapcad.manufacturing.connectors module
Interior connector generation for beam segmentation.
This module provides functions to create interior connectors that join segmented swept elements. Connectors fit inside hollow profiles and provide structural continuity across cut planes.
- yapcad.manufacturing.connectors.add_terminal_connectors_to_segment(segment_solid: Any, provenance: SweptElementProvenance, *, add_start: bool = False, add_end: bool = False, connector_length: float | None = None, fit_clearance: float = 0.18) Any[source]
Union terminal connector tabs with a segment’s endpoints.
Use this to add male tabs to the ends of arc segments that will slot into female holes in rings or other structures.
- Parameters:
segment_solid – The segment solid to modify
provenance – SweptElementProvenance with profile and spine data
add_start – Add terminal tab at start (t=0) of spine
add_end – Add terminal tab at end (t=1) of spine
connector_length – Length of terminal tabs (auto-computed if None)
fit_clearance – Clearance for fit
- Returns:
Modified segment solid with terminal tabs unioned
- Raises:
ValueError – If provenance lacks required data
RuntimeError – If boolean union fails
- yapcad.manufacturing.connectors.compute_connector_length(profile_width: float, profile_height: float, spine: Dict[str, Any], center_parameter: float, *, length_factor: float = 3.0, min_arc_degrees: float = 15.0) float[source]
Compute the appropriate connector length.
For straight sections, length is based on profile size. For curved sections, length may be extended to span a minimum arc.
- Parameters:
profile_width – Profile width
profile_height – Profile height
spine – Path3d dict
center_parameter – Where connector is centered (t in [0, 1])
length_factor – Multiple of largest profile dimension
min_arc_degrees – Minimum arc span for curved sections
- Returns:
Connector length in mm
- yapcad.manufacturing.connectors.compute_connector_profile_dimensions(outer_width: float, outer_height: float, wall_thickness: float, fit_clearance: float) Tuple[float, float][source]
Compute connector cross-section dimensions.
The connector fits inside the hollow interior with specified clearance.
- Parameters:
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness of hollow profile
fit_clearance – Clearance per side for desired fit
- Returns:
Tuple of (connector_width, connector_height)
- yapcad.manufacturing.connectors.compute_connector_spec(element_id: str, cut_parameter: float, outer_width: float, outer_height: float, wall_thickness: float, spine: Dict[str, Any], *, fit_clearance: float = 0.18, connector_id: str | None = None) ConnectorSpec[source]
Compute full connector specification for a cut point.
- Parameters:
element_id – ID of parent swept element
cut_parameter – Where cut occurs (t in [0, 1])
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness
spine – Path3d of parent element
fit_clearance – Desired fit clearance
connector_id – Optional ID (auto-generated if None)
- Returns:
ConnectorSpec object with all computed values
- yapcad.manufacturing.connectors.compute_inner_profile_dimensions(outer_width: float, outer_height: float, wall_thickness: float) Tuple[float, float][source]
Compute inner void dimensions from outer profile and wall thickness.
- Parameters:
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness
- Returns:
Tuple of (inner_width, inner_height)
- yapcad.manufacturing.connectors.create_connector_region2d(width: float, height: float, *, corner_radius: float = 0.0) List[source]
Create a rectangular region2d for the connector profile.
- Parameters:
width – Connector width
height – Connector height
corner_radius – Optional fillet radius for corners
- Returns:
yapCAD region2d (list of polylines with proper winding)
- yapcad.manufacturing.connectors.create_interior_connector(outer_profile_width: float, outer_profile_height: float, spine: Dict[str, Any], center_parameter: float, *, wall_thickness: float, connector_length: float | None = None, fit_clearance: float = 0.18, corner_radius: float = 0.0) Any[source]
Create an interior connector solid.
The connector fits inside the hollow interior of a swept beam element, spanning across a cut plane to join two segments.
- Parameters:
outer_profile_width – Width of outer beam profile
outer_profile_height – Height of outer beam profile
spine – Path3d that the original beam follows
center_parameter – Location along spine (t in [0, 1]) where cut occurs
wall_thickness – Wall thickness of hollow beam
connector_length – Length of connector (auto-computed if None)
fit_clearance – Clearance for desired fit (mm per side)
corner_radius – Optional fillet radius for connector corners
- Returns:
yapCAD solid representing the connector
- yapcad.manufacturing.connectors.create_terminal_connector(outer_profile_width: float, outer_profile_height: float, spine: Dict[str, Any], end: str, *, wall_thickness: float, connector_length: float | None = None, fit_clearance: float = 0.18, corner_radius: float = 0.0) Any[source]
Create a terminal connector tab at the start or end of a spine.
Terminal connectors extend outward from arc endpoints and are designed to slot into female holes in rings or other structures.
- Parameters:
outer_profile_width – Width of outer beam profile
outer_profile_height – Height of outer beam profile
spine – Path3d that the beam follows
end – “start” for t=0 end, “end” for t=1 end
wall_thickness – Wall thickness of hollow beam
connector_length – Length of connector tab (auto-computed if None)
fit_clearance – Clearance for desired fit (mm per side)
corner_radius – Optional fillet radius for connector corners
- Returns:
yapCAD solid representing the terminal connector tab
- yapcad.manufacturing.connectors.offset_rectangular_profile(width: float, height: float, clearance: float) Tuple[float, float][source]
Offset a rectangular profile inward by clearance.
- Parameters:
width – Original profile width
height – Original profile height
clearance – Amount to shrink per side
- Returns:
Tuple of (new_width, new_height)
- Raises:
ValueError – If clearance would result in zero or negative dimensions
yapcad.manufacturing.data module
Data structures for manufacturing post-processing.
This module defines the core data structures used for beam segmentation and assembly planning.
- class yapcad.manufacturing.data.ConnectorSpec(id: str, parent_element_id: str, center_parameter: float, length: float, fit_clearance: float = 0.2, profile_type: str = 'box')[source]
Bases:
objectSpecification for an interior connector.
- class yapcad.manufacturing.data.CutPoint(element_id: str, parameter: float, connector_length: float | None = None, fit_clearance: float = 0.2, union_connector_with: str = 'a')[source]
Bases:
objectSpecification for a segmentation cut.
Defines where and how to cut a swept element to create segments that fit within build volume constraints.
- union_connector_with
Which segment gets the connector tab - “a”: First segment (lower t) - “b”: Second segment (higher t) - “none”: Connector is separate piece
- Type:
- class yapcad.manufacturing.data.Segment(id: str, solid: ~typing.Any, parent_element_id: str, parameter_range: ~typing.Tuple[float, float], has_connector_tab: bool = False, connector_type: str = 'none', mates_with: ~typing.List[str] = <factory>, bounding_box: ~typing.List | None = None)[source]
Bases:
objectA segment resulting from splitting a swept element.
- solid
yapCAD solid geometry
- Type:
Any
- connector_type
Type of connector mating (“male”, “female”, “none”) - “male”: Has protruding connector tab - “female”: Hollow interior receives male tab - “none”: No connector at this boundary
- Type:
- bounding_box
[[xmin,ymin,zmin,1], [xmax,ymax,zmax,1]]
- Type:
List | None
- class yapcad.manufacturing.data.SegmentationResult(segments: ~typing.List[~yapcad.manufacturing.data.Segment], connectors: ~typing.List[~yapcad.manufacturing.data.ConnectorSpec] = <factory>, assembly_graph: dict = <factory>, build_volume_ok: bool = True, warnings: ~typing.List[str] = <factory>, assembly_instructions: str = '')[source]
Bases:
objectComplete result of a segmentation operation.
- segments
List of resulting segment objects
- Type:
- connectors
List of connector specifications (for reference)
- Type:
- connectors: List[ConnectorSpec]
- class yapcad.manufacturing.data.SweptElementProvenance(id: str, operation: str, outer_profile: Any, spine: Any, inner_profile: Any | None = None, wall_thickness: float | None = None, semantic_type: str = 'structural_beam', metadata: dict = <factory>)[source]
Bases:
objectProvenance data for a swept element.
Captures how a swept solid was created, enabling intelligent segmentation that preserves structural intent.
- outer_profile
The outer boundary region2d
- Type:
Any
- inner_profile
Inner void region2d (None for solid profiles)
- Type:
Any | None
- spine
The path3d the profile was swept along
- Type:
Any
yapcad.manufacturing.path_utils module
Path3D utilities for manufacturing post-processing.
This module provides functions for evaluating and manipulating path3d objects, which are essential for beam segmentation operations.
- yapcad.manufacturing.path_utils.compute_cut_plane(path3d: Dict[str, Any], t: float) Tuple[List[float], List[float]][source]
Compute the cut plane at a parameter along the path.
The cut plane is perpendicular to the path tangent at the given parameter.
- Parameters:
path3d – Dict with ‘segments’ list
t – Global parameter in [0, 1]
- Returns:
Tuple of (point, normal) defining the plane - point: A point on the plane (the path point at t) - normal: Unit normal to the plane (the path tangent at t)
- yapcad.manufacturing.path_utils.evaluate_path3d_at_t(path3d: Dict[str, Any], t: float) Tuple[List[float], List[float]][source]
Evaluate a path3d at a global parameter value.
- Parameters:
path3d – Dict with ‘segments’ list of line/arc segments
t – Global parameter in [0, 1] across entire path
- Returns:
Tuple of (point, tangent) at parameter t - point: [x, y, z] position on path - tangent: [tx, ty, tz] unit tangent vector
- Raises:
ValueError – If path has no segments or t is out of range
- yapcad.manufacturing.path_utils.extract_sub_path(path3d: Dict[str, Any], t_start: float, t_end: float) Dict[str, Any][source]
Extract a portion of a path3d between two parameters.
- Parameters:
path3d – Original path dict
t_start – Start parameter in [0, 1]
t_end – End parameter in [0, 1], must be > t_start
- Returns:
New path3d dict containing only the portion between t_start and t_end
- Raises:
ValueError – If t_start >= t_end or parameters out of range
- yapcad.manufacturing.path_utils.length_to_parameter(path3d: Dict[str, Any], arc_length: float) float[source]
Convert an arc length to a global parameter.
- Parameters:
path3d – Dict with ‘segments’ list
arc_length – Distance along the path from start
- Returns:
Global parameter t in [0, 1]
yapcad.manufacturing.rings module
Ring generation and female hole creation for manufacturing.
This module provides functions to create base and cradle rings with female holes that receive terminal connectors from arcs.
- yapcad.manufacturing.rings.add_female_holes_to_ring(ring_solid: Any, attachment_points: List[Tuple[Tuple[float, float, float], Tuple[float, float, float]]], outer_width: float, outer_height: float, wall_thickness: float, hole_depth: float | None = None, fit_clearance: float = 0.18) Any[source]
Subtract female holes at arc attachment positions.
- Parameters:
ring_solid – Ring solid to modify
attachment_points – List of (position, direction) tuples
outer_width – Beam profile width
outer_height – Beam profile height
wall_thickness – Wall thickness
hole_depth – Depth of holes (auto-computed if None)
fit_clearance – Fit clearance for holes
- Returns:
Ring solid with female holes subtracted
- yapcad.manufacturing.rings.compute_arc_attachment_point(ring_radius: float, attachment_angle_deg: float, ring_center: Tuple[float, float, float] = (0.0, 0.0, 0.0), ring_tilt_deg: float = 0.0, ring_tilt_axis: str = 'x') Tuple[Tuple[float, float, float], Tuple[float, float, float]][source]
Compute where an arc attaches to a ring.
Returns the position on the ring centerline and the radial direction pointing inward (toward ring center).
- Parameters:
ring_radius – Radius of ring
attachment_angle_deg – Angle around ring where arc attaches
ring_center – Center of ring
ring_tilt_deg – Ring tilt angle
ring_tilt_axis – Axis ring is tilted around
- Returns:
Tuple of (position, inward_direction)
- yapcad.manufacturing.rings.compute_ring_cuts_avoiding_holes(ring_circumference: float, max_segment_length: float, hole_angles_deg: List[float], min_distance_from_hole: float = 30.0, *, target_segments: int | None = None) List[float][source]
Compute cut parameters for ring that avoid female hole positions.
Produces evenly-spaced segments with cuts placed to avoid holes. The algorithm finds cut positions that result in equal-length segments (relative to t=0) while keeping cuts away from hole locations.
For equal segments on a closed ring, we need cuts at positions that divide [0, 1) into equal parts. With N segments, cuts should be at 1/N, 2/N, …, (N-1)/N. If holes are at these positions, we find alternate cut positions that still produce equal segments.
- Parameters:
ring_circumference – Total circumference of ring in mm
max_segment_length – Maximum segment length in mm
hole_angles_deg – Angles where holes are located (0-360)
min_distance_from_hole – Minimum distance from hole center in mm
target_segments – If specified, use this many segments instead of computing from max_segment_length. Useful when build volume constraints allow fewer segments than the length calculation.
- Returns:
List of cut parameters (0-1) that avoid hole locations
- yapcad.manufacturing.rings.create_female_hole_solid(position: Tuple[float, float, float], direction: Tuple[float, float, float], outer_width: float, outer_height: float, wall_thickness: float, hole_depth: float, fit_clearance: float = 0.18) Any[source]
Create a solid to subtract from a ring for a female connector hole.
The hole allows a male terminal connector to slot in.
- Parameters:
position – Starting position of hole (on ring surface)
direction – Direction hole extends (into ring)
outer_width – Width of beam profile (for sizing hole)
outer_height – Height of beam profile (for sizing hole)
wall_thickness – Wall thickness of beam
hole_depth – How deep the hole extends
fit_clearance – Clearance to add for fit
- Returns:
yapCAD solid representing the hole volume to subtract
- yapcad.manufacturing.rings.create_ring_profile(outer_width: float, outer_height: float, wall_thickness: float) List[source]
Create a hollow rectangular profile (region2d) for a ring.
- Parameters:
outer_width – Width of outer profile
outer_height – Height of outer profile
wall_thickness – Wall thickness
- Returns:
yapCAD region2d (outer boundary, inner hole)
- yapcad.manufacturing.rings.create_ring_solid(radius: float, outer_width: float, outer_height: float, wall_thickness: float, center: Tuple[float, float, float] = (0.0, 0.0, 0.0), tilt_angle_deg: float = 0.0, tilt_axis: str = 'x', ring_id: str = 'ring') Tuple[Any, SweptElementProvenance][source]
Create a hollow box-beam ring with provenance tracking.
- Parameters:
radius – Radius to centerline of profile
outer_width – Width of beam profile
outer_height – Height of beam profile
wall_thickness – Wall thickness for hollow profile
center – Center point of ring
tilt_angle_deg – Tilt angle in degrees
tilt_axis – Axis to tilt around
ring_id – Identifier for the ring
- Returns:
Tuple of (ring_solid, SweptElementProvenance)
- yapcad.manufacturing.rings.create_ring_spine(radius: float, center: Tuple[float, float, float] = (0.0, 0.0, 0.0), tilt_angle_deg: float = 0.0, tilt_axis: str = 'x', num_segments: int = 72) Dict[str, Any][source]
Create a circular path3d for a ring.
- Parameters:
radius – Radius of the ring (to centerline of profile)
center – Center point of the ring (x, y, z)
tilt_angle_deg – Tilt angle in degrees (0 = horizontal)
tilt_axis – Axis to tilt around (“x”, “y”, or “z”)
num_segments – Number of line segments to approximate the circle
- Returns:
yapCAD path3d dictionary with ‘segments’ key
- yapcad.manufacturing.rings.trim_segment_against_ring(segment_solid: Any, ring_solid: Any) Any[source]
Trim a segment by subtracting the ring solid from it.
This creates a clean interface where the arc meets the ring, removing any overlap between the arc segment and ring geometry.
- Parameters:
segment_solid – Arc segment to trim
ring_solid – Ring solid to subtract
- Returns:
Trimmed segment solid
yapcad.manufacturing.segmentation module
Beam segmentation for manufacturing post-processing.
This module provides functions to segment swept elements (beams, pipes) at specified cut planes, creating printable segments with interior connectors for reassembly.
- yapcad.manufacturing.segmentation.build_connector_solids(provenance: SweptElementProvenance, connector_specs: List[ConnectorSpec]) List[Tuple[ConnectorSpec, Any]][source]
Build actual connector solids from specifications.
- Parameters:
provenance – SweptElementProvenance with profile and spine data
connector_specs – List of ConnectorSpec from segmentation
- Returns:
List of (ConnectorSpec, solid) tuples
- yapcad.manufacturing.segmentation.compute_optimal_cuts(provenance: SweptElementProvenance, max_segment_length: float, *, prefer_straight_cuts: bool = True) List[CutPoint][source]
Compute optimal cut locations for a given max segment length.
Analyzes the spine and proposes cut locations that: - Keep segments under max_segment_length - Prefer cuts at straight sections (not mid-curve) - Maintain structural integrity
- Parameters:
provenance – SweptElementProvenance with spine data
max_segment_length – Maximum length of any single segment
prefer_straight_cuts – Try to cut at straight sections when possible
- Returns:
List of CutPoint at optimal locations
- yapcad.manufacturing.segmentation.extract_segment_between_planes(solid: Any, plane1_point: List[float], plane1_normal: List[float], plane2_point: List[float], plane2_normal: List[float]) Any[source]
Extract a segment of a solid between two cutting planes.
This is designed for closed rings where a single half-space cut doesn’t correctly identify the segment. We cut with both planes to isolate the segment between them.
The normals should point OUTWARD from the segment (toward the parts to remove).
- Parameters:
solid – yapCAD solid (typically a closed ring)
plane1_point – Point on first cutting plane
plane1_normal – Normal pointing away from segment (toward part to remove)
plane2_point – Point on second cutting plane
plane2_normal – Normal pointing away from segment (toward part to remove)
- Returns:
The segment between the two planes
- yapcad.manufacturing.segmentation.segment_closed_ring(solid: Any, spine: Dict[str, Any], cut_parameters: List[float]) List[Any][source]
Segment a closed ring using two-plane extraction.
For closed rings, single half-space cuts don’t work correctly because the geometry wraps around. This function uses two cutting planes per segment to properly isolate each piece.
- Parameters:
solid – The complete ring solid
spine – Path3d representing the ring’s sweep path
cut_parameters – Sorted list of t values where cuts occur (0 < t < 1)
- Returns:
List of segment solids in parameter order (segment 0 is [0, t0], etc.)
- Raises:
RuntimeError – If extraction fails
ValueError – If cut_parameters is empty or invalid
- yapcad.manufacturing.segmentation.segment_swept_element(provenance: SweptElementProvenance, cut_points: List[CutPoint], *, build_connectors: bool = True, union_connectors: bool = True) SegmentationResult[source]
Segment a swept element at the specified cut points.
Takes a swept element (beam, pipe, etc.) with its provenance data and produces segments that can be individually manufactured and reassembled.
- Parameters:
provenance – SweptElementProvenance with profile, spine, and metadata
cut_points – List of CutPoint specifying where to cut
build_connectors – Whether to generate interior connector solids
union_connectors – Whether to union connectors with segments (male/female) When True, connectors are integrated into segments based on CutPoint.union_connector_with. When False, connectors are separate.
- Returns:
SegmentationResult with segments, connectors, and assembly info
- yapcad.manufacturing.segmentation.split_solid_at_plane(solid: Any, plane_point: List[float], plane_normal: List[float]) Tuple[Any, Any][source]
Split a solid into two parts at a plane.
Uses OCC’s boolean operations to cut the solid with a half-space defined by the plane.
NOTE: This works well for open paths (arcs, beams). For closed rings, use segment_closed_ring() or extract_segment_between_planes() instead.
- Parameters:
solid – yapCAD solid to split
plane_point – [x, y, z] point on the cutting plane
plane_normal – [nx, ny, nz] normal vector (points toward “B” side)
- Returns:
solid_a: portion on negative side of plane (lower parameter)
solid_b: portion on positive side of plane (higher parameter)
- Return type:
Tuple of (solid_a, solid_b) where
- Raises:
RuntimeError – If OCC is not available or splitting fails
Module contents
Manufacturing post-processing for yapCAD.
This module provides tools for preparing yapCAD designs for manufacturing, including beam segmentation for build volume constraints and interior connector generation.
Phase 1 Implementation
Beam segmentation for hollow swept elements
Interior connectors with configurable fit tolerances
Path3D evaluation utilities
Assembly planning with mating relationships
Example Usage
>>> from yapcad.manufacturing import (
... CutPoint, segment_swept_element, SweptElementProvenance
... )
>>>
>>> # Define provenance for a swept beam
>>> provenance = SweptElementProvenance(
... id="main_beam",
... operation="sweep_adaptive",
... outer_profile=outer_region2d,
... spine=path3d,
... wall_thickness=2.0,
... metadata={'solid': beam_solid}
... )
>>>
>>> # Define cut points
>>> cuts = [
... CutPoint("main_beam", parameter=0.33),
... CutPoint("main_beam", parameter=0.67),
... ]
>>>
>>> # Segment the beam
>>> result = segment_swept_element(provenance, cuts)
>>> print(f"Created {result.segment_count} segments")
- class yapcad.manufacturing.ConnectorSpec(id: str, parent_element_id: str, center_parameter: float, length: float, fit_clearance: float = 0.2, profile_type: str = 'box')[source]
Bases:
objectSpecification for an interior connector.
- class yapcad.manufacturing.CutPoint(element_id: str, parameter: float, connector_length: float | None = None, fit_clearance: float = 0.2, union_connector_with: str = 'a')[source]
Bases:
objectSpecification for a segmentation cut.
Defines where and how to cut a swept element to create segments that fit within build volume constraints.
- union_connector_with
Which segment gets the connector tab - “a”: First segment (lower t) - “b”: Second segment (higher t) - “none”: Connector is separate piece
- Type:
- class yapcad.manufacturing.Segment(id: str, solid: ~typing.Any, parent_element_id: str, parameter_range: ~typing.Tuple[float, float], has_connector_tab: bool = False, connector_type: str = 'none', mates_with: ~typing.List[str] = <factory>, bounding_box: ~typing.List | None = None)[source]
Bases:
objectA segment resulting from splitting a swept element.
- solid
yapCAD solid geometry
- Type:
Any
- connector_type
Type of connector mating (“male”, “female”, “none”) - “male”: Has protruding connector tab - “female”: Hollow interior receives male tab - “none”: No connector at this boundary
- Type:
- bounding_box
[[xmin,ymin,zmin,1], [xmax,ymax,zmax,1]]
- Type:
List | None
- class yapcad.manufacturing.SegmentationResult(segments: ~typing.List[~yapcad.manufacturing.data.Segment], connectors: ~typing.List[~yapcad.manufacturing.data.ConnectorSpec] = <factory>, assembly_graph: dict = <factory>, build_volume_ok: bool = True, warnings: ~typing.List[str] = <factory>, assembly_instructions: str = '')[source]
Bases:
objectComplete result of a segmentation operation.
- segments
List of resulting segment objects
- Type:
- connectors
List of connector specifications (for reference)
- Type:
- connectors: List[ConnectorSpec]
- class yapcad.manufacturing.SweptElementProvenance(id: str, operation: str, outer_profile: Any, spine: Any, inner_profile: Any | None = None, wall_thickness: float | None = None, semantic_type: str = 'structural_beam', metadata: dict = <factory>)[source]
Bases:
objectProvenance data for a swept element.
Captures how a swept solid was created, enabling intelligent segmentation that preserves structural intent.
- outer_profile
The outer boundary region2d
- Type:
Any
- inner_profile
Inner void region2d (None for solid profiles)
- Type:
Any | None
- spine
The path3d the profile was swept along
- Type:
Any
- yapcad.manufacturing.add_female_holes_to_ring(ring_solid: Any, attachment_points: List[Tuple[Tuple[float, float, float], Tuple[float, float, float]]], outer_width: float, outer_height: float, wall_thickness: float, hole_depth: float | None = None, fit_clearance: float = 0.18) Any[source]
Subtract female holes at arc attachment positions.
- Parameters:
ring_solid – Ring solid to modify
attachment_points – List of (position, direction) tuples
outer_width – Beam profile width
outer_height – Beam profile height
wall_thickness – Wall thickness
hole_depth – Depth of holes (auto-computed if None)
fit_clearance – Fit clearance for holes
- Returns:
Ring solid with female holes subtracted
- yapcad.manufacturing.add_terminal_connectors_to_segment(segment_solid: Any, provenance: SweptElementProvenance, *, add_start: bool = False, add_end: bool = False, connector_length: float | None = None, fit_clearance: float = 0.18) Any[source]
Union terminal connector tabs with a segment’s endpoints.
Use this to add male tabs to the ends of arc segments that will slot into female holes in rings or other structures.
- Parameters:
segment_solid – The segment solid to modify
provenance – SweptElementProvenance with profile and spine data
add_start – Add terminal tab at start (t=0) of spine
add_end – Add terminal tab at end (t=1) of spine
connector_length – Length of terminal tabs (auto-computed if None)
fit_clearance – Clearance for fit
- Returns:
Modified segment solid with terminal tabs unioned
- Raises:
ValueError – If provenance lacks required data
RuntimeError – If boolean union fails
- yapcad.manufacturing.build_connector_solids(provenance: SweptElementProvenance, connector_specs: List[ConnectorSpec]) List[Tuple[ConnectorSpec, Any]][source]
Build actual connector solids from specifications.
- Parameters:
provenance – SweptElementProvenance with profile and spine data
connector_specs – List of ConnectorSpec from segmentation
- Returns:
List of (ConnectorSpec, solid) tuples
- yapcad.manufacturing.compute_arc_attachment_point(ring_radius: float, attachment_angle_deg: float, ring_center: Tuple[float, float, float] = (0.0, 0.0, 0.0), ring_tilt_deg: float = 0.0, ring_tilt_axis: str = 'x') Tuple[Tuple[float, float, float], Tuple[float, float, float]][source]
Compute where an arc attaches to a ring.
Returns the position on the ring centerline and the radial direction pointing inward (toward ring center).
- Parameters:
ring_radius – Radius of ring
attachment_angle_deg – Angle around ring where arc attaches
ring_center – Center of ring
ring_tilt_deg – Ring tilt angle
ring_tilt_axis – Axis ring is tilted around
- Returns:
Tuple of (position, inward_direction)
- yapcad.manufacturing.compute_connector_length(profile_width: float, profile_height: float, spine: Dict[str, Any], center_parameter: float, *, length_factor: float = 3.0, min_arc_degrees: float = 15.0) float[source]
Compute the appropriate connector length.
For straight sections, length is based on profile size. For curved sections, length may be extended to span a minimum arc.
- Parameters:
profile_width – Profile width
profile_height – Profile height
spine – Path3d dict
center_parameter – Where connector is centered (t in [0, 1])
length_factor – Multiple of largest profile dimension
min_arc_degrees – Minimum arc span for curved sections
- Returns:
Connector length in mm
- yapcad.manufacturing.compute_connector_profile_dimensions(outer_width: float, outer_height: float, wall_thickness: float, fit_clearance: float) Tuple[float, float][source]
Compute connector cross-section dimensions.
The connector fits inside the hollow interior with specified clearance.
- Parameters:
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness of hollow profile
fit_clearance – Clearance per side for desired fit
- Returns:
Tuple of (connector_width, connector_height)
- yapcad.manufacturing.compute_connector_spec(element_id: str, cut_parameter: float, outer_width: float, outer_height: float, wall_thickness: float, spine: Dict[str, Any], *, fit_clearance: float = 0.18, connector_id: str | None = None) ConnectorSpec[source]
Compute full connector specification for a cut point.
- Parameters:
element_id – ID of parent swept element
cut_parameter – Where cut occurs (t in [0, 1])
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness
spine – Path3d of parent element
fit_clearance – Desired fit clearance
connector_id – Optional ID (auto-generated if None)
- Returns:
ConnectorSpec object with all computed values
- yapcad.manufacturing.compute_cut_plane(path3d: Dict[str, Any], t: float) Tuple[List[float], List[float]][source]
Compute the cut plane at a parameter along the path.
The cut plane is perpendicular to the path tangent at the given parameter.
- Parameters:
path3d – Dict with ‘segments’ list
t – Global parameter in [0, 1]
- Returns:
Tuple of (point, normal) defining the plane - point: A point on the plane (the path point at t) - normal: Unit normal to the plane (the path tangent at t)
- yapcad.manufacturing.compute_inner_profile_dimensions(outer_width: float, outer_height: float, wall_thickness: float) Tuple[float, float][source]
Compute inner void dimensions from outer profile and wall thickness.
- Parameters:
outer_width – Outer profile width
outer_height – Outer profile height
wall_thickness – Wall thickness
- Returns:
Tuple of (inner_width, inner_height)
- yapcad.manufacturing.compute_optimal_cuts(provenance: SweptElementProvenance, max_segment_length: float, *, prefer_straight_cuts: bool = True) List[CutPoint][source]
Compute optimal cut locations for a given max segment length.
Analyzes the spine and proposes cut locations that: - Keep segments under max_segment_length - Prefer cuts at straight sections (not mid-curve) - Maintain structural integrity
- Parameters:
provenance – SweptElementProvenance with spine data
max_segment_length – Maximum length of any single segment
prefer_straight_cuts – Try to cut at straight sections when possible
- Returns:
List of CutPoint at optimal locations
- yapcad.manufacturing.compute_ring_cuts_avoiding_holes(ring_circumference: float, max_segment_length: float, hole_angles_deg: List[float], min_distance_from_hole: float = 30.0, *, target_segments: int | None = None) List[float][source]
Compute cut parameters for ring that avoid female hole positions.
Produces evenly-spaced segments with cuts placed to avoid holes. The algorithm finds cut positions that result in equal-length segments (relative to t=0) while keeping cuts away from hole locations.
For equal segments on a closed ring, we need cuts at positions that divide [0, 1) into equal parts. With N segments, cuts should be at 1/N, 2/N, …, (N-1)/N. If holes are at these positions, we find alternate cut positions that still produce equal segments.
- Parameters:
ring_circumference – Total circumference of ring in mm
max_segment_length – Maximum segment length in mm
hole_angles_deg – Angles where holes are located (0-360)
min_distance_from_hole – Minimum distance from hole center in mm
target_segments – If specified, use this many segments instead of computing from max_segment_length. Useful when build volume constraints allow fewer segments than the length calculation.
- Returns:
List of cut parameters (0-1) that avoid hole locations
- yapcad.manufacturing.create_connector_region2d(width: float, height: float, *, corner_radius: float = 0.0) List[source]
Create a rectangular region2d for the connector profile.
- Parameters:
width – Connector width
height – Connector height
corner_radius – Optional fillet radius for corners
- Returns:
yapCAD region2d (list of polylines with proper winding)
- yapcad.manufacturing.create_female_hole_solid(position: Tuple[float, float, float], direction: Tuple[float, float, float], outer_width: float, outer_height: float, wall_thickness: float, hole_depth: float, fit_clearance: float = 0.18) Any[source]
Create a solid to subtract from a ring for a female connector hole.
The hole allows a male terminal connector to slot in.
- Parameters:
position – Starting position of hole (on ring surface)
direction – Direction hole extends (into ring)
outer_width – Width of beam profile (for sizing hole)
outer_height – Height of beam profile (for sizing hole)
wall_thickness – Wall thickness of beam
hole_depth – How deep the hole extends
fit_clearance – Clearance to add for fit
- Returns:
yapCAD solid representing the hole volume to subtract
- yapcad.manufacturing.create_interior_connector(outer_profile_width: float, outer_profile_height: float, spine: Dict[str, Any], center_parameter: float, *, wall_thickness: float, connector_length: float | None = None, fit_clearance: float = 0.18, corner_radius: float = 0.0) Any[source]
Create an interior connector solid.
The connector fits inside the hollow interior of a swept beam element, spanning across a cut plane to join two segments.
- Parameters:
outer_profile_width – Width of outer beam profile
outer_profile_height – Height of outer beam profile
spine – Path3d that the original beam follows
center_parameter – Location along spine (t in [0, 1]) where cut occurs
wall_thickness – Wall thickness of hollow beam
connector_length – Length of connector (auto-computed if None)
fit_clearance – Clearance for desired fit (mm per side)
corner_radius – Optional fillet radius for connector corners
- Returns:
yapCAD solid representing the connector
- yapcad.manufacturing.create_ring_profile(outer_width: float, outer_height: float, wall_thickness: float) List[source]
Create a hollow rectangular profile (region2d) for a ring.
- Parameters:
outer_width – Width of outer profile
outer_height – Height of outer profile
wall_thickness – Wall thickness
- Returns:
yapCAD region2d (outer boundary, inner hole)
- yapcad.manufacturing.create_ring_solid(radius: float, outer_width: float, outer_height: float, wall_thickness: float, center: Tuple[float, float, float] = (0.0, 0.0, 0.0), tilt_angle_deg: float = 0.0, tilt_axis: str = 'x', ring_id: str = 'ring') Tuple[Any, SweptElementProvenance][source]
Create a hollow box-beam ring with provenance tracking.
- Parameters:
radius – Radius to centerline of profile
outer_width – Width of beam profile
outer_height – Height of beam profile
wall_thickness – Wall thickness for hollow profile
center – Center point of ring
tilt_angle_deg – Tilt angle in degrees
tilt_axis – Axis to tilt around
ring_id – Identifier for the ring
- Returns:
Tuple of (ring_solid, SweptElementProvenance)
- yapcad.manufacturing.create_ring_spine(radius: float, center: Tuple[float, float, float] = (0.0, 0.0, 0.0), tilt_angle_deg: float = 0.0, tilt_axis: str = 'x', num_segments: int = 72) Dict[str, Any][source]
Create a circular path3d for a ring.
- Parameters:
radius – Radius of the ring (to centerline of profile)
center – Center point of the ring (x, y, z)
tilt_angle_deg – Tilt angle in degrees (0 = horizontal)
tilt_axis – Axis to tilt around (“x”, “y”, or “z”)
num_segments – Number of line segments to approximate the circle
- Returns:
yapCAD path3d dictionary with ‘segments’ key
- yapcad.manufacturing.create_terminal_connector(outer_profile_width: float, outer_profile_height: float, spine: Dict[str, Any], end: str, *, wall_thickness: float, connector_length: float | None = None, fit_clearance: float = 0.18, corner_radius: float = 0.0) Any[source]
Create a terminal connector tab at the start or end of a spine.
Terminal connectors extend outward from arc endpoints and are designed to slot into female holes in rings or other structures.
- Parameters:
outer_profile_width – Width of outer beam profile
outer_profile_height – Height of outer beam profile
spine – Path3d that the beam follows
end – “start” for t=0 end, “end” for t=1 end
wall_thickness – Wall thickness of hollow beam
connector_length – Length of connector tab (auto-computed if None)
fit_clearance – Clearance for desired fit (mm per side)
corner_radius – Optional fillet radius for connector corners
- Returns:
yapCAD solid representing the terminal connector tab
- yapcad.manufacturing.evaluate_path3d_at_t(path3d: Dict[str, Any], t: float) Tuple[List[float], List[float]][source]
Evaluate a path3d at a global parameter value.
- Parameters:
path3d – Dict with ‘segments’ list of line/arc segments
t – Global parameter in [0, 1] across entire path
- Returns:
Tuple of (point, tangent) at parameter t - point: [x, y, z] position on path - tangent: [tx, ty, tz] unit tangent vector
- Raises:
ValueError – If path has no segments or t is out of range
- yapcad.manufacturing.extract_segment_between_planes(solid: Any, plane1_point: List[float], plane1_normal: List[float], plane2_point: List[float], plane2_normal: List[float]) Any[source]
Extract a segment of a solid between two cutting planes.
This is designed for closed rings where a single half-space cut doesn’t correctly identify the segment. We cut with both planes to isolate the segment between them.
The normals should point OUTWARD from the segment (toward the parts to remove).
- Parameters:
solid – yapCAD solid (typically a closed ring)
plane1_point – Point on first cutting plane
plane1_normal – Normal pointing away from segment (toward part to remove)
plane2_point – Point on second cutting plane
plane2_normal – Normal pointing away from segment (toward part to remove)
- Returns:
The segment between the two planes
- yapcad.manufacturing.extract_sub_path(path3d: Dict[str, Any], t_start: float, t_end: float) Dict[str, Any][source]
Extract a portion of a path3d between two parameters.
- Parameters:
path3d – Original path dict
t_start – Start parameter in [0, 1]
t_end – End parameter in [0, 1], must be > t_start
- Returns:
New path3d dict containing only the portion between t_start and t_end
- Raises:
ValueError – If t_start >= t_end or parameters out of range
- yapcad.manufacturing.length_to_parameter(path3d: Dict[str, Any], arc_length: float) float[source]
Convert an arc length to a global parameter.
- Parameters:
path3d – Dict with ‘segments’ list
arc_length – Distance along the path from start
- Returns:
Global parameter t in [0, 1]
- yapcad.manufacturing.offset_rectangular_profile(width: float, height: float, clearance: float) Tuple[float, float][source]
Offset a rectangular profile inward by clearance.
- Parameters:
width – Original profile width
height – Original profile height
clearance – Amount to shrink per side
- Returns:
Tuple of (new_width, new_height)
- Raises:
ValueError – If clearance would result in zero or negative dimensions
- yapcad.manufacturing.parameter_to_length(path3d: Dict[str, Any], t: float) float[source]
Convert a global parameter to arc length.
- Parameters:
path3d – Dict with ‘segments’ list
t – Global parameter in [0, 1]
- Returns:
Arc length from path start to parameter t
- yapcad.manufacturing.path_length(path3d: Dict[str, Any]) float[source]
Compute the total arc length of a path3d.
- Parameters:
path3d – Dict with ‘segments’ list
- Returns:
Total length in same units as path coordinates
- yapcad.manufacturing.segment_closed_ring(solid: Any, spine: Dict[str, Any], cut_parameters: List[float]) List[Any][source]
Segment a closed ring using two-plane extraction.
For closed rings, single half-space cuts don’t work correctly because the geometry wraps around. This function uses two cutting planes per segment to properly isolate each piece.
- Parameters:
solid – The complete ring solid
spine – Path3d representing the ring’s sweep path
cut_parameters – Sorted list of t values where cuts occur (0 < t < 1)
- Returns:
List of segment solids in parameter order (segment 0 is [0, t0], etc.)
- Raises:
RuntimeError – If extraction fails
ValueError – If cut_parameters is empty or invalid
- yapcad.manufacturing.segment_swept_element(provenance: SweptElementProvenance, cut_points: List[CutPoint], *, build_connectors: bool = True, union_connectors: bool = True) SegmentationResult[source]
Segment a swept element at the specified cut points.
Takes a swept element (beam, pipe, etc.) with its provenance data and produces segments that can be individually manufactured and reassembled.
- Parameters:
provenance – SweptElementProvenance with profile, spine, and metadata
cut_points – List of CutPoint specifying where to cut
build_connectors – Whether to generate interior connector solids
union_connectors – Whether to union connectors with segments (male/female) When True, connectors are integrated into segments based on CutPoint.union_connector_with. When False, connectors are separate.
- Returns:
SegmentationResult with segments, connectors, and assembly info
- yapcad.manufacturing.split_solid_at_plane(solid: Any, plane_point: List[float], plane_normal: List[float]) Tuple[Any, Any][source]
Split a solid into two parts at a plane.
Uses OCC’s boolean operations to cut the solid with a half-space defined by the plane.
NOTE: This works well for open paths (arcs, beams). For closed rings, use segment_closed_ring() or extract_segment_between_planes() instead.
- Parameters:
solid – yapCAD solid to split
plane_point – [x, y, z] point on the cutting plane
plane_normal – [nx, ny, nz] normal vector (points toward “B” side)
- Returns:
solid_a: portion on negative side of plane (lower parameter)
solid_b: portion on positive side of plane (higher parameter)
- Return type:
Tuple of (solid_a, solid_b) where
- Raises:
RuntimeError – If OCC is not available or splitting fails
- yapcad.manufacturing.trim_segment_against_ring(segment_solid: Any, ring_solid: Any) Any[source]
Trim a segment by subtracting the ring solid from it.
This creates a clean interface where the arc meets the ring, removing any overlap between the arc segment and ring geometry.
- Parameters:
segment_solid – Arc segment to trim
ring_solid – Ring solid to subtract
- Returns:
Trimmed segment solid