Fix for #6: Incorrect bolt lengths #13
@ -705,6 +705,7 @@ def Create_Pan_Head(HOLE_DIA, HEAD_DIA, SHANK_DIA, HEIGHT, RAD1, RAD2, FACE_OFFS
|
||||
|
||||
verts.append([SHANK_RADIUS, 0.0, (0.0 - HEIGHT)])
|
||||
Row += 1
|
||||
washer_face_z = Start_Height - HEIGHT
|
||||
|
||||
verts.append([SHANK_RADIUS, 0.0, (0.0 - HEIGHT) - Start_Height])
|
||||
Row += 1
|
||||
@ -716,7 +717,7 @@ def Create_Pan_Head(HOLE_DIA, HEAD_DIA, SHANK_DIA, HEIGHT, RAD1, RAD2, FACE_OFFS
|
||||
|
||||
# Global_Head_Height = HEIGHT # UNUSED
|
||||
|
||||
return Move_Verts_Up_Z(sVerts, Start_Height), faces, HEIGHT
|
||||
return Move_Verts_Up_Z(sVerts, Start_Height), faces, HEIGHT, washer_face_z
|
||||
|
||||
|
||||
def Create_Dome_Head(HOLE_DIA, HEAD_DIA, SHANK_DIA, HEIGHT, RAD1, RAD2, FACE_OFFSET, DIV_COUNT):
|
||||
@ -843,6 +844,8 @@ def Create_Cap_Head(HOLE_DIA, HEAD_DIA, SHANK_DIA, HEIGHT, RAD1, RAD2, DIV_COUNT
|
||||
verts.append([HEAD_RADIUS - BEVEL, 0.0, 0.0 - HEIGHT])
|
||||
Row += 1
|
||||
|
||||
washer_face_z = -HEIGHT
|
||||
|
||||
# rad2
|
||||
for i in range(0, 100, 10):
|
||||
x = sin(radians(i)) * RAD2
|
||||
@ -855,7 +858,7 @@ def Create_Cap_Head(HOLE_DIA, HEAD_DIA, SHANK_DIA, HEIGHT, RAD1, RAD2, DIV_COUNT
|
||||
|
||||
faces.extend(Build_Face_List_Quads(FaceStart, Row - 1, DIV_COUNT))
|
||||
|
||||
return sVerts, faces, HEIGHT + RAD2
|
||||
return sVerts, faces, HEIGHT + RAD2, washer_face_z
|
||||
|
||||
|
||||
def Create_Hex_Head(FLAT, HOLE_DIA, SHANK_DIA, HEIGHT):
|
||||
@ -868,6 +871,7 @@ def Create_Hex_Head(FLAT, HOLE_DIA, SHANK_DIA, HEIGHT):
|
||||
Undercut_Height = (Half_Flat * (0.05 / 8))
|
||||
Shank_Bevel = (Half_Flat * (0.05 / 8))
|
||||
Flat_Height = HEIGHT - Undercut_Height - Shank_Bevel
|
||||
washer_face_z = -HEIGHT + Undercut_Height
|
||||
# Undercut_Height = 5
|
||||
SHANK_RADIUS = SHANK_DIA / 2
|
||||
Row = 0
|
||||
@ -927,7 +931,6 @@ def Create_Hex_Head(FLAT, HOLE_DIA, SHANK_DIA, HEIGHT):
|
||||
|
||||
x = tan(radians(60 / 3)) * Half_Flat
|
||||
dvec = vec3 - Vector([x, Half_Flat, 0.0])
|
||||
Lowest_Point = -dvec.length
|
||||
verts.append([x, Half_Flat, -dvec.length])
|
||||
|
||||
x = tan(radians(60 / 2)) * Half_Flat
|
||||
@ -1061,7 +1064,7 @@ def Create_Hex_Head(FLAT, HOLE_DIA, SHANK_DIA, HEIGHT):
|
||||
|
||||
Spin_Verts, Spin_Faces = SpinDup(verts, faces, 360, 6, 'z')
|
||||
|
||||
return Spin_Verts, Spin_Faces, 0 - (-HEIGHT)
|
||||
return Spin_Verts, Spin_Faces, 0 - (-HEIGHT), washer_face_z
|
||||
|
||||
|
||||
def Create_12_Point(FLAT, HOLE_DIA, SHANK_DIA, HEIGHT, FLANGE_DIA):
|
||||
@ -1600,9 +1603,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 +1778,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
|
||||
|
||||
|
||||
# ####################################################################
|
||||
@ -2379,13 +2388,16 @@ def Bolt_Mesh(props, context):
|
||||
props.bf_Philips_Bit_Dia / GLOBAL_SCALE * (0.5 / 1.82),
|
||||
props.bf_Phillips_Bit_Depth / GLOBAL_SCALE
|
||||
)
|
||||
|
||||
# Head Mesh
|
||||
# Define the washer face of the bolt, i.e. the underside. Some bolts have a bevel or radius to the shank included
|
||||
# Their head height causes an incorrect shank/thread length determination.
|
||||
washer_face_z = 0 # z-axis height, some Heads return a variable that overwrites this
|
||||
if props.bf_Head_Type == 'bf_Head_Hex':
|
||||
Head_Verts, Head_Faces, Head_Height = Create_Hex_Head(
|
||||
Head_Verts, Head_Faces, Head_Height, washer_face_z = Create_Hex_Head(
|
||||
props.bf_Hex_Head_Flat_Distance / GLOBAL_SCALE, Bit_Dia,
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE, props.bf_Hex_Head_Height / GLOBAL_SCALE
|
||||
)
|
||||
|
||||
elif props.bf_Head_Type == 'bf_Head_12Pnt':
|
||||
Head_Verts, Head_Faces, Head_Height = Create_12_Point_Head(
|
||||
props.bf_12_Point_Head_Flat_Distance / GLOBAL_SCALE, Bit_Dia,
|
||||
@ -2394,7 +2406,7 @@ def Bolt_Mesh(props, context):
|
||||
max(props.bf_12_Point_Head_Flange_Dia / GLOBAL_SCALE, props.bf_12_Point_Head_Flat_Distance / GLOBAL_SCALE)
|
||||
)
|
||||
elif props.bf_Head_Type == 'bf_Head_Cap':
|
||||
Head_Verts, Head_Faces, Head_Height = Create_Cap_Head(
|
||||
Head_Verts, Head_Faces, Head_Height, washer_face_z = Create_Cap_Head(
|
||||
Bit_Dia, props.bf_Cap_Head_Dia / GLOBAL_SCALE,
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE, props.bf_Cap_Head_Height / GLOBAL_SCALE,
|
||||
props.bf_Cap_Head_Dia / GLOBAL_SCALE * (1.0 / 19.0),
|
||||
@ -2407,9 +2419,8 @@ def Bolt_Mesh(props, context):
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE, props.bf_Hex_Head_Height / GLOBAL_SCALE,
|
||||
1, 1, 0, props.bf_Div_Count
|
||||
)
|
||||
|
||||
elif props.bf_Head_Type == 'bf_Head_Pan':
|
||||
Head_Verts, Head_Faces, Head_Height = Create_Pan_Head(
|
||||
Head_Verts, Head_Faces, Head_Height, washer_face_z = Create_Pan_Head(
|
||||
Bit_Dia, props.bf_Pan_Head_Dia / GLOBAL_SCALE,
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE,
|
||||
props.bf_Hex_Head_Height / GLOBAL_SCALE, 1, 1, 0,
|
||||
@ -2431,11 +2442,24 @@ def Bolt_Mesh(props, context):
|
||||
verts.extend(Move_Verts_Up_Z(Head_Verts, Head_Height))
|
||||
faces.extend(Copy_Faces(Head_Faces, Face_Start))
|
||||
|
||||
make_shank = (props.bf_Shank_Length / GLOBAL_SCALE)
|
||||
make_thread = (props.bf_Thread_Length / GLOBAL_SCALE)
|
||||
if washer_face_z != 0:
|
||||
# At this point the mesh is back at z=zero. The washer face may be randomly above this depending on
|
||||
# the head choice. Optional returned variable is used to shorten up the shank/thread.
|
||||
# If the Head function modified the washer_face-z we are here to make a length correction.
|
||||
washer_face = washer_face_z + Head_Height
|
||||
make_shank = (props.bf_Shank_Length / GLOBAL_SCALE) - washer_face
|
||||
if make_shank < 0:
|
||||
# If all the shank length is used up then take it off the thread length
|
||||
make_thread = (props.bf_Thread_Length / GLOBAL_SCALE) + make_shank
|
||||
make_shank = 0
|
||||
|
||||
Face_Start = len(verts)
|
||||
Thread_Verts, Thread_Faces, Thread_Height = Create_External_Thread(
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE, props.bf_Shank_Length / GLOBAL_SCALE,
|
||||
props.bf_Shank_Dia / GLOBAL_SCALE, make_shank,
|
||||
props.bf_Minor_Dia / GLOBAL_SCALE, props.bf_Major_Dia / GLOBAL_SCALE,
|
||||
props.bf_Pitch / GLOBAL_SCALE, props.bf_Thread_Length / GLOBAL_SCALE,
|
||||
props.bf_Pitch / GLOBAL_SCALE, make_thread,
|
||||
props.bf_Crest_Percent,
|
||||
props.bf_Root_Percent, props.bf_Div_Count
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user