tolerance nut width not possible to adjust
it is not possible to add a margin to the nut width from the gui I need more tolerance as I 3D print the parts.
Current work around manually added a tolerance in get_screw_nut_spec in helper.py. I tried to change your code but although I like your module. Your code style suffers from a lot of boiler plate code... Look at the function; there is a lot of repetitive patterns.. The style is not optimal... Still I do like your module a lot 👍
def get_screw_nut_spec(metric_diameter, metric_length):
width_tol = 3
height_tol = 1
if metric_diameter == 1.6:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=3.2+width_tol, nut_height=1.3+height_tol)
elif metric_diameter == 2:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=4.+width_tol, nut_height=1.6+height_tol)
elif metric_diameter == 2.5:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=5.+width_tol, nut_height=2.+height_tol)
elif metric_diameter == 3:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=5.5+width_tol, nut_height=2.4+height_tol)
elif metric_diameter == 4:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=7.+width_tol, nut_height=3.2+height_tol)
elif metric_diameter == 5:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=8.+width_tol, nut_height=4.7+height_tol)
elif metric_diameter == 6:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=10+width_tol, nut_height=5.2+height_tol)
elif metric_diameter == 8:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=13.+width_tol, nut_height=6.8+height_tol)
elif metric_diameter == 10:
return ObjectProperties(screw_diameter=metric_diameter, screw_length=metric_length,
screw_length_tol=0.1, nut_flat_flat=16.+width_tol, nut_height=8.4+height_tol)
raise ValueError("Unknown screw diameter")
```python
Hello, I did not know this expression, thank you! Yes I am aware that the code is not optimal. I did a bit of refactoring a while ago but I need to continue. This part of code should be modified and configurable by all because the tolerance depends on the machine used. The tolerances of M2 to M6 screws are the one that corresponds to my use. The others, I put them a bit at random.