© 2025 Alexander Hajnal v1.0.0
A set of useful constants for OpenSCAD that closely follow those in the C standard library and Perl.
To include in your code by placing this file in the same directory as your OpenSCAD script and including the following in your script:
include <c_constants.scad>;
A stand-alone demo/test script can be found in c_constants-test.scad.
Please submit any bug reports or feature requests via GitHub.
A number of variables are defined containing strings that represent various special characters in 7-bit ASCII character set. These are:
compat_SOH= 0x01 → SOH (start of heading)compat_STX= 0x02 → STX (start of text)compat_ETX= 0x03 → ETX (end of text)compat_EOT= 0x04 → EOT (end of transmission)compat_ENQ= 0x05 → ENQ (enquiry)compat_ACK= 0x06 → ACK (acknowledge)compat_BEL= 0x07 → BEL (bell)compat_BS= 0x08 → BS (backspace)compat_HT= 0x09 → HT (horizontal tab)compat_LF= 0x0A → LF (new line)compat_VT= 0x0B → VT (vertical tab)compat_FF= 0x0C → FF (form feed)compat_CR= 0x0D → CR (carriage ret)compat_SO= 0x0E → SO (shift out)compat_SI= 0x0F → SI (shift in)compat_DLE= 0x10 → DLE (data link escape)compat_DC1= 0x11 → DC1 (device control 1)compat_DC2= 0x12 → DC2 (device control 2)compat_DC3= 0x13 → DC3 (device control 3)compat_DC4= 0x14 → DC4 (device control 4)compat_NAK= 0x15 → NAK (negative acknowledge)compat_SYN= 0x16 → SYN (synchronous idle)compat_ETB= 0x17 → ETB (end of trans. blk)compat_CAN= 0x18 → CAN (cancel)compat_EM= 0x19 → EM (end of medium)compat_SUB= 0x1A → SUB (substitute)compat_ESC= 0x1B → ESC (escape; non-standard escape sequence)compat_FS= 0x1C → FS (file separator)compat_GS= 0x1D → GS (group separator)compat_RS= 0x1E → RS (record separator)compat_US= 0x1F → US (unit separator)compat_DEL= 0x7F → DEL (delete)
The null character (NULL = 0x00) is not representable in OpenSCAD.
In addition to the single characters above the compat_WHITESPACE variable contains all of the valid 7-bit ASCII whitespace characters (space, FF, NL [a.k.a. LF], CR, HT, and VT).
Major versions indicate a non-backwards-compatible change to the API.
Minor versions indicate substantial new features or bug fixes.
Subminor versions indicate changes that don't [yet] warrant incrementing the minor version number.
A suffix may be added when the changes are so inconsequential that incrementing the version number isn't warranted. This may include things like tweaks to comment formatting, indents, and the like. It does not include any changes to the code's logic or syntax.
-
c_constants_version()Returns the c_constants library version as an OpenSCAD list:[ Major, Minor, Subminor, Suffix ](e.g.
[ 1, 0, 2, "bis" ]) -
c_constants_version_string()Returns the c_constants library version as an OpenSCAD list:"Major.Minor.SubminorSuffix"(e.g.
"1.0.2bis") -
c_constants_require( major, minor, subminor )Require at least the specified version of c_constants. Throws a fatal error if thec_constantslibrary version is less than the one specified. All arguments are optional. Note that the suffix is ignored.Throws a fatal error if the c_constants library version is less than the one specified.
This is a module and returns no value.
-
c_constants_require_exact(major,minor,subminor)Require a specific version of c_constantsThrows a fatal error if the c_constants library version does not equal the one specified. All arguments are optional. Note that the suffix is ignored.
This is a module and returns no value.
Note: To require any version of c_constants with a specific major (i.e. with a compatible API) but with at least a given revision (minor or minor.subminor) use e.g.:
c_constants_require_exact(major=1); // Any 1.x.y version
c_constants_require(major=1, minor=2); // Version 1.2.y or later
-
c_constants_version_major()Returns thec_constantslibrary major version number as an integer. -
c_constants_version_minor()Returns thec_constantslibrary minor version number as an integer. -
c_constants_version_subminor()Returns thec_constantslibrary subminor version number as an integer. -
c_constants_version_suffix()Returns thec_constantslibrary version suffix as a string.
1.0.0 [2025-11-24] Initial public release
- Initial version