gumyr / bd_warehouse

A build123d parametric part collection
Apache License 2.0
31 stars 12 forks source link

Thread "raw" end_finishes add extra loops and has inconsistent length #16

Open MatthiasJ1 opened 7 months ago

MatthiasJ1 commented 7 months ago
ref     = Cylinder(1, 1, align=(Align.CENTER, Align.CENTER, Align.MIN))
fade    = Pos(2.5) * TrapezoidalThread(2, 0.5, 20, 1, end_finishes=("fade", "fade"))
square  = Pos(5)   * TrapezoidalThread(2, 0.5, 20, 1, end_finishes=("square", "square"))
chamfer = Pos(7.5) * TrapezoidalThread(2, 0.5, 20, 1, end_finishes=("chamfer", "chamfer"))
raw     = Pos(10)  * TrapezoidalThread(2, 0.5, 20, 1, end_finishes=("raw", "raw"))
Screenshot
gumyr commented 7 months ago

This is by design. "raw" is a unfinished thread end - that is fast to create - that ensures there is enough extra thread such that all of the other end types can be constructed from it. "raw" is used when the user will fuse the end of the thread into another object (like the head of a screw) where it won't be a problem or when other operations will be performed on the read to trim it to shape.

MatthiasJ1 commented 6 months ago

The constructor specifies:

pitch (float): thread pitch
length (float): thread length

The constructor is called with:

length = 1
pitch = 0.5

Therefore, that should create a thread of length 1 with 2 turns. What we get:

One of the following should be generated for raw ends (ideally have both be two separate options with raw ending on the centerline or border of the thread):

Screenshot

If some internal algorithms require additional thread length, they can easily increase the length of the thread to get extra raw thread to work with. Or if it needs to be an end_finishes, it should be something like "_raw_extended_for_internal_use" and have "raw" follow the spec since it has use as a user-facing option.