adrianschlatter / threadlib

thread library for OpenSCAD
BSD 3-Clause "New" or "Revised" License
351 stars 34 forks source link

Invalid thread name => unhelpful error message #37

Closed nohkumado closed 4 years ago

nohkumado commented 4 years ago

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

adrianschlatter commented 4 years ago

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

nohkumado commented 4 years ago

hello! sorry for the delay, these mails get buried in the heap of system messages...

here's the code, using your example on the page:

10 //bolt("M4", turns = 5, higbee_arc = 30); 11 bolt("G1/2-ext",turns = 5, higbee_arc = 30);

and that fails, wihtout letting to know why it failed, with my (and Michaels) addition it now raises an alert about the name beeing not the one expected/not in the table....

ciao Bruno

Am Fr., 22. Mai 2020 um 17:29 Uhr schrieb Adrian Schlatter < notifications@github.com>:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/adrianschlatter/threadlib/issues/37#issuecomment-632754283, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADR5CZ2OANX53D7CCSTHBQ3RS2K33ANCNFSM4NHURHIA .

-- Bruno Böttcher

35 rue de la république, FR-6720 Schwindratzheim email: bboett@adlp.org, mobile:bboett@gmail.com Fon:+33 3 88 89 91, Mob:+33 6 76 55 82 68

Dev: Java/Perl/PHP OS:GNU/LINUX, Android

adrianschlatter commented 4 years ago

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?

nohkumado commented 4 years ago

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...

adrianschlatter commented 4 years ago

Gaps in numbering?

adrianschlatter commented 4 years ago

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?

nohkumado commented 4 years ago

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...

adrianschlatter commented 4 years ago

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 :)