gumyr / build123d

A python CAD programming library
Apache License 2.0
510 stars 86 forks source link

GD&T #278

Open gumyr opened 1 year ago

gumyr commented 1 year ago

Geometric Dimensioning and Tolerancing

Using the built-in GD&T functionality of OpenCascade, add something like cq_warehouse.drafting to build123d.

Discord's GIgahawk describes a potential API:

with BuildPart() as part:
    Box(length, width, thickness)
    datum_feat_a = part.faces().sort_by(Axis.Z)[0]
    datum_feat_b = part.faces().sort_by(Axis.X)[0]
    datum_feat_c = part.faces().sort_by(Axis.Y)[0]
    datum_a = create_datum(datum_feat_a, "A")
    datum_b = create_datum(datum_feat_b, "B")
    datum_c = create_datum(datum_feat_c, "C")
    cyl = Cylinder(radius=center_hole_dia / 2, height=thickness, mode=Mode.SUBTRACT)
    set_gdt(
        cyl,
        Gdt.POSITION, # symbol type
        1,  # tolerance
        (datum_a, datum_b, datum_c)  # datums
        mod=GdtMod.MMC  # modifier, pass a number to indicate unequally disposed profile
        dia=True
    )
gumyr commented 1 year ago

1st pass complete with 7924dffd19f02336e5b80ab024d7a3a9fe6d0a3a (and associated commits).

gumyr commented 1 year ago

Consider a genetic algorithm (like scipy.optimize.differential_evolution) to auto place the drafting objects. The scoring system found with DimensionLine would need to be extended to all of the drafting objects and enhanced to provide a robust scoring system to the genetic algorithm to work with.