adrianschlatter / threadlib

thread library for OpenSCAD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid thread name => unhelpful error message

nohkumado opened this issue · comments

Hello
i hade to make an adapter for a pump, and that pump uses instead of metric threading british non-SI metrics :(
firing up your lib, i added a nut with 1/2" metric, and it exploded in my face....
doing just the thread was fine, but nut&bolt werent't ...
so i nagged the mailing list and Michael foudn out that there was no sanity check for those f...g imperial metrics, and that a fixed -int/-ext were added to the metrics....

i added those sanitize functions to make sure there is no double -int, or -int-ext on the name, and an assert to break the compilation with a n error message pointing to the source of the problem....
so, apart for my fervent, and unfortnately useless, wish that all those non-SI metrics could go down some very distant hell of their own, all my branch does is some parameter checking and correcting (if needed)...

BTW happy to see you are still alive and kicking :D

Can you post the code that „exploded in your face“?

Ah. That is not related to imperial threads, then. The code fails due to the duplicate "-ext" (duplicate because a bolt always has external thread, it cannot have internal thread).

I understand that you wish threadlib to produce a more meaningful error message when someone tries to use a non-existing thread, right?

exactly, with the stuff in my version of the tree an assert is issued when the lookup of the thread name fails (after trying to remove eventual duplicate -ext/-int from the name....
BTW that was also helpful when trying to find a hughe M thread, since at the end of the table, there a quite hughe gaps in the numbering...

Gaps in numbering?

Oh, I just now understand that you apparently found that erroneous example somewhere in the threadlib docs. That would be a bug. Can you point me to the place where that misleading example is?

Well its not really an erroneous example, its just misleading... you put an example of a metric nut, and after wards an example of juste the thread, perhaps a mention, careful, when using thread you aved to add -int/-ext to the name to have the 2 mesures of the thread....

(and inversely, if you take just the thread example and want a nut/bolt, remove the -int/ext part from the name)
and to be more exact, you use metric thread examples for nut&bolt, but imperial for the thread (and i was searching how to specify an imperial thread at that time) , for people like me that think only metrically, they say ok, that's the way you specify metric stuff, and when it comes to imperial, since it evades my logic havin spourious stuff inside it, feels normal ;)

well try for M45 .... doesn't exist... you have either M42 or M48... nothing in between...

Ok. Regarding the misleading error message I'm all with you. So far, threadlib did not produce meaningful errors just because I have not been able to find a nice way to do it, as OpenSCAD has no exception handling and functions can have only a single expression. I have checked out your PR to find out how you did that.

BTW: There are 6 different types of M45 in threadlib :)