WIP: Fix for #6: Incorrect bolt lengths #13

Draft
sw-tya wants to merge 2 commits from sw-tya/add_mesh_BoltFactory:swtya_BoltLength into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit a3be045159 - Show all commits

View File

@ -1600,9 +1600,10 @@ def Create_Thread_Verts(INNER_DIA, OUTTER_DIA, PITCH, HEIGHT,
Deg_Step = 360.0 / float(DIV_COUNT)
Height_Step = float(PITCH) / float(DIV_COUNT)
NUM_OF_START_THREADS = 4.0
NUM_OF_START_THREADS = 2.0 # Was 4 in the very first submission
NUM_OF_END_THREADS = 3.0
Num = int((HEIGHT - ((NUM_OF_START_THREADS * PITCH) + (NUM_OF_END_THREADS * PITCH))) / PITCH)
# This uses less than the requested bolt length by up to 1 pitch, after 5 revolutions
Row = 0
Crest_Height = float(PITCH) * float(CREST_PERCENT) / float(100)
@ -1774,15 +1775,20 @@ def Create_External_Thread(SHANK_DIA, SHANK_LENGTH, INNER_DIA, OUTTER_DIA,
)
Total_Row += Thread_End_Row
# Make a final correction for the bolt length to mitigate rounding errors during manufacture
Mini_adder = Lowest_Z_Vert + SHANK_LENGTH + LENGTH
if Mini_adder < LENGTH * 0.01:
Mini_adder = 0 # Catches a very thin shim and also negative situations, worst case error is 1%
verts.extend(Shank_Verts)
verts.extend(Thread_Start_Verts)
verts.extend(Thread_Verts)
verts.extend(Thread_End_Verts)
verts.extend(Move_Verts_Up_Z(Thread_Start_Verts, -Mini_adder)) # Needs moving down by the mini_adder
verts.extend(Move_Verts_Up_Z(Thread_Verts, -Mini_adder)) # so that any missing length is added
verts.extend(Move_Verts_Up_Z(Thread_End_Verts, -Mini_adder)) # between the thread and the shank.
faces.extend(Build_Face_List_Quads(Face_Start, DIV_COUNT, Total_Row - 1, 0))
faces.extend(Fill_Ring_Face(len(verts) - DIV_COUNT, DIV_COUNT, 1))
return verts, faces, 0.0 - Lowest_Z_Vert
return verts, faces, 0.0 - Lowest_Z_Vert + Mini_adder
# ####################################################################