gumyr / build123d

A python CAD programming library
Apache License 2.0
382 stars 72 forks source link

Add major_radius bool to HexLocations #633

Closed jdegenstein closed 1 week ago

jdegenstein commented 1 month ago

Currently RegularPolygon supports bool major_radius that defaults to True. In order to place hexagonal regular polygons with sides touching with the default option, one must use math to convert the major radius to minor radius (aka the apothem). I propose adding HexLocations(... major_radius: bool = False) which will preserve the existing default behavior, while allowing for better interoperability between RegularPolygon and HexLocations.

with BuildSketch() as s:
    with HexLocations(1,3,3):
        RegularPolygon(1,6)

image

gumyr commented 1 month ago

If one does this:

with BuildSketch() as s:
    with HexLocations(1, 3, 3):
        RegularPolygon(1, 6, major_radius=False)

the hexes touch each other. Is the problem that you want to work with a major radius for both HexLocations and RegularPolygon?

jdegenstein commented 1 month ago

Yes, that is the use-case that I would like to make a bit easier.