thread_specs(...): Error Msg

Added helpful error message if thread_specs(...) is unable to
look up designator. Compare PR #36.

closes #37
This commit is contained in:
Adrian Schlatter
2020-06-09 18:07:21 +02:00
parent 63bde7f4f8
commit 703d6a8859

View File

@@ -17,9 +17,12 @@ include <THREAD_TABLE.scad>
function thread_specs(designator, table=THREAD_TABLE) =
/* Returns thread specs of thread-type 'designator' as a vector of
[pitch, Rrotation, Dsupport, section_profile] */
table[search([designator], table, num_returns_per_match=1,
index_col_num=0)[0]][1];
// first lookup designator in table inside a let() statement:
let (specs = table[search([designator], table, num_returns_per_match=1,
index_col_num=0)[0]][1])
// verify that we found something and return it:
assert(!is_undef(specs), str("Designator: '", designator, "' not found")) specs;
module thread(designator, turns, higbee_arc=20, fn=120, table=THREAD_TABLE)
{