Incorrect bolt sizes BoltFactory add-on #6
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
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
I hope to review this within 48 hours
@sw-tya, It looks like you have a good handle on this. I look forward to seeing your PR for it.