Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tolerance nut width not possible to adjust #46

Open
hstarmans opened this issue Dec 13, 2020 · 1 comment
Open

tolerance nut width not possible to adjust #46

hstarmans opened this issue Dec 13, 2020 · 1 comment

Comments

@hstarmans
Copy link
Contributor

hstarmans commented Dec 13, 2020

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
@execuc
Copy link
Owner

execuc commented Jan 3, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants