Selectors

Renders the 3D model in your browser. The first run downloads the Python runtime (≈30 MB).
from cadbuildr.foundation import *
from cadbuildr.foundation.gen.models import (
    IsCircleRule, ParallelToAxisRule,
)


class SelectorsAssembly(Assembly):
    """Edge-finder rule demos. An `EdgeFinder(rule=...)` picks which edges a
    `Fillet` rounds.

    `IsCircleRule()` matches circular edges only — here it rounds the two
    circular rims of a cylinder while leaving nothing else to touch.
    `ParallelToAxisRule(axis="Z")` matches the four vertical edges of a box —
    the classic "round only the upright corners" pattern.
    """

    def __init__(self):
        # Circular-edge fillet: round the rims of a cylinder.
        class CircularRim(Part):
            def __init__(self):
                s = Sketch(self.xy())
                disc = Cylinder(s.origin, radius=12, height=6)
                self.add_operation(disc)
                self.add_operation(
                    Fillet(
                        solid=disc.expand(),
                        radius=1.5,
                        edge_finder=EdgeFinder(rule=IsCircleRule()),
                    )
                )
                self.paint("tan")

        # Vertical-axis fillet on a box: round the four upright corners.
        class VerticalCorners(Part):
            def __init__(self):
                s = Sketch(self.xy())
                box = Box(s.origin, w=20, h=12, d=10)
                self.add_operation(box)
                self.add_operation(
                    Fillet(
                        solid=box.expand(),
                        radius=2,
                        edge_finder=EdgeFinder(
                            rule=ParallelToAxisRule(axis="Z"),
                        ),
                    )
                )
                self.translate([45, 0, 0])
                self.paint("bright_yellow")

        self.add_component(CircularRim())
        self.add_component(VerticalCorners())


show(SelectorsAssembly())

EdgeFinder and FaceFinder pick subsets of edges or faces on a solid by chaining rules. Pass them to Fillet, Chamfer, Shell, or any operation that accepts a finder.

EdgeFinder()                                      # all edges
  .is_circle()                                    # circular edges only
  .of_type("LINE" | "CIRCLE" | "BSPLINE")         # filter by curve type
  .parallel_to_axis("X" | "Y" | "Z")              # axis-aligned edges
  .length_in_range(min, max)                      # bounded length
  .radius_in_range(min, max)                      # bounded radius (arcs)
  .on_face(face_finder)                           # edges of a chosen face
  .sort_by(by="LENGTH" | "RADIUS",                # rank + take FIRST/LAST/N
            take="FIRST" | "LAST" | "N", n=1)

Rules can be combined — chained calls compose, and rule terms can be nested via EitherRule(rules=[...]) or AndRule(rules=[...]) for disjunctions / conjunctions.

The kernel applies native rules through opencascadejs’s EdgeFinder (curve type, axis direction); compound rules and length/radius ranges are applied as a post-filter on the natively-matched candidate set.