-
Notifications
You must be signed in to change notification settings - Fork 64
compat.scad
Backwards Compatability library To use, include this line at the top of your file:
use <compat.scad>
Description:
Returns the value given as v
if it is not undef
.
Otherwise, returns the value of dflt
.
Argument | What it does |
---|---|
v |
Value to pass through if not undef . |
dflt |
Value to return if v is undef . |
Description:
Returns true if given value is not undef
.
Description: Given a value, returns true if it is a string.
Description: Given a value, returns true if it is a boolean.
Description: Given a value, returns true if it is a scalar number.
Description: Given a value, returns true if it is an array/list/vector.
Description: Given various radii and diameters, returns the most specific radius. If a diameter is most specific, returns half its value, giving the radius. If no radii or diameters are defined, returns the value of dflt. Value specificity order is r1, d1, r, d, then dflt
Argument | What it does |
---|---|
r1 |
Most specific radius. |
d1 |
Most specific Diameter. |
r |
Most general radius. |
d |
Most general diameter. |
dflt |
Value to return if all other values given are undef . |
Description:
Given an array, returns number of items in array. Otherwise returns undef
.
Description:
Removes all undef
s from a list.
Description:
Returns the first item in the list that is not undef
.
If all items are undef
, or list is empty, returns undef
.
Description:
Returns true if any item in the given array is not undef
.
Usage:
- scalar_vec3(v, [dflt]);
Description:
If v
is a scalar, and dflt==undef
, returns [v, v, v]
.
If v
is a scalar, and dflt!=undef
, returns [v, dflt, dflt]
.
If v
is a vector, returns the first 3 items, with any missing values replaced by dflt
.
If v
is undef
, returns undef
.
Argument | What it does |
---|---|
v |
Value to return vector from. |
dflt |
Default value to set empty vector parts from. |
Description: If possible, echo a message from a function.
Usage:
- assert_in_list(argname, val, l, [idx]);
Description:
Emulates the newer OpenSCAD assert()
with an in_list()
test.
You can also use this as a function call from a function.
Argument | What it does |
---|---|
argname |
The name of the argument value being tested. |
val |
The value to test if it exists in the list. |
l |
The list to look for val in. |
idx |
If given, and l is a list of lists, look for val in the given index of each sublist. |
Usage:
- assertion(succ, msg);
Description:
Backwards compatible assert() semi-replacement.
If succ
is false, then print an error with msg
.
You can also use this as a function call from a function.
Argument | What it does |
---|---|
succ |
If this is false , trigger the assertion. |
msg |
The message to emit if succ is false . |
Usage:
- echo_error(msg, [pfx]);
Description: Emulates printing of an error message. The text will be shaded red. You can also use this as a function call from a function.
Argument | What it does |
---|---|
msg |
The message to print. |
pfx |
The prefix to print before msg . Default: ERROR
|
Usage:
- echo_warning(msg, [pfx]);
Description: Emulates printing of a warning message. The text will be shaded yellow. You can also use this as a function call from a function.
Argument | What it does |
---|---|
msg |
The message to print. |
pfx |
The prefix to print before msg . Default: WARNING
|
Usage:
- deprecate(name, [suggest]);
Description: Show module deprecation warnings. You can also use this as a function call from a function.
Argument | What it does |
---|---|
name |
The name of the module that is deprecated. |
suggest |
If given, the module to recommend using instead. |
Usage:
- deprecate(name, arg, [suggest]);
Description: Show argument deprecation warnings. You can also use this as a function call from a function.
Argument | What it does |
---|---|
name |
The name of the module/function the deprecated argument is used in. |
arg |
The name of the deprecated argument. |
suggest |
If given, the argument to recommend using instead. |