Incorrect bolt sizes BoltFactory add-on #6

Open
opened 2024-07-16 17:15:49 +02:00 by Loren Osborn · 3 comments
Contributor

Originally blender/blender-addons#80648 from Alexandr Minakov

(see original for discussion, files and images)

System Information
Operating system: Linux-5.6.0-2-amd64-x86_64-with-debian-10.5 64 Bits
Graphics card: GeForce GTX 960/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.100

Blender Version
Broken: version: 2.90.0, branch: master, commit date: 2020-08-31 11:26, hash: blender/blender@0330d1af29
Worked: (newest version of Blender that worked as expected)

Addon Information
Name: BoltFactory (0, 4, 0)
Author: Aaron Keith

Short description of error
The thread length is always less than the specified "Thread length".

Exact steps for others to reproduce the error
Go to side view, create a bolt. If you count on the grid, you will see that the length to the head is less than indicated in "Thread Length". In any preset. And in different presets this length will be different. And in the M12 preset it is generally difficult to use because of the "Shank Lenght" parameter, which spoils the overall length.
In the screenshot, I alternately chose the M * preset and set the length to 20mm.
image

Originally https://projects.blender.org/blender/blender-addons/issues/80648 from [Alexandr Minakov](@Az3Dip) (see original for discussion, files and images) System Information Operating system: Linux-5.6.0-2-amd64-x86_64-with-debian-10.5 64 Bits Graphics card: GeForce GTX 960/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.100 Blender Version Broken: version: 2.90.0, branch: master, commit date: 2020-08-31 11:26, hash: blender/blender@0330d1af29 Worked: (newest version of Blender that worked as expected) Addon Information Name: BoltFactory (0, 4, 0) Author: Aaron Keith Short description of error The thread length is always less than the specified "Thread length". Exact steps for others to reproduce the error Go to side view, create a bolt. If you count on the grid, you will see that the length to the head is less than indicated in "Thread Length". In any preset. And in different presets this length will be different. And in the M12 preset it is generally difficult to use because of the "Shank Lenght" parameter, which spoils the overall length. In the screenshot, I alternately chose the M * preset and set the length to 20mm. ![image](/attachments/a89620bc-5d45-4027-ab1e-cb93f666e55f)
420 KiB

The incorrect bolt length is due to the blender modelling, as only complete revolutions for the thread are used. The length of a bolt should be the distance from the underside of the head to the tip - in the real world threads have fractional revolutions.

The error comes from this slightly clumsy line:
Num = int((HEIGHT - ((NUM_OF_START_THREADS * PITCH) + (NUM_OF_END_THREADS * PITCH))) / PITCH)
in Create_Thread_Verts.

The fix is rather easy if applied in: Create_External_Thread
Where Create_Thread_End_Verts is called the returned value Lowest_Z_Vert is the tip of the thread, this will be too short by some fraction of a pitch.

Before the verts.extend block of code is the place figure to what has been lost in the model creation vs the requested input, something like:
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%
print("Bolt length is already perfect, length modulo number of thread pitch rotations!")

Three of verts.extend can be shifted down using the function Move_Verts_Up_Z - this has the effect of increasing the shank.
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) ) # Needs moving down by the mini_adder
verts.extend(Move_Verts_Up_Z(Thread_End_Verts, -Mini_adder) ) # Needs moving down by the mini_adder

Finally don't forget to change the return to include the new Z value:
return verts, faces, 0.0 - Lowest_Z_Vert + Mini_adder

The incorrect bolt length is due to the blender modelling, as only complete revolutions for the thread are used. The length of a bolt should be the distance from the underside of the head to the tip - in the real world threads have fractional revolutions. The error comes from this slightly clumsy line: ` Num = int((HEIGHT - ((NUM_OF_START_THREADS * PITCH) + (NUM_OF_END_THREADS * PITCH))) / PITCH) ` in Create_Thread_Verts. The fix is rather easy if applied in: Create_External_Thread Where Create_Thread_End_Verts is called the returned value Lowest_Z_Vert is the tip of the thread, this will be too short by some fraction of a pitch. Before the verts.extend block of code is the place figure to what has been lost in the model creation vs the requested input, something like: ` 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%` ` print("Bolt length is already perfect, length modulo number of thread pitch rotations!")` Three of verts.extend can be shifted down using the function Move_Verts_Up_Z - this has the effect of increasing the shank. ` 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) ) # Needs moving down by the mini_adder` ` verts.extend(Move_Verts_Up_Z(Thread_End_Verts, -Mini_adder) ) # Needs moving down by the mini_adder` Finally don't forget to change the return to include the new Z value: ` return verts, faces, 0.0 - Lowest_Z_Vert + Mini_adder`
Author
Contributor

I hope to review this within 48 hours

I hope to review this within 48 hours
Author
Contributor

@sw-tya, It looks like you have a good handle on this. I look forward to seeing your PR for it.

@sw-tya, It looks like you have a good handle on this. I look forward to seeing your PR for it.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: extensions/add_mesh_BoltFactory#6
No description provided.