Академический Документы
Профессиональный Документы
Культура Документы
Logical Operators
All logical operators take Boolean values as operands and produce a Boolean value.
Conditional Operator
The ?: operator can be used to conditionally evaluate one or another expression. It works
like the ?: operator from the family of C-like programming languages.
? : Conditional operator
Usage Example:
a=1;
b=2;
c= a==b ? 4 : 5;
Vector-Number Operators
The vector-number operators take a vector and a number as operands and produce a new
vector.
Vector Operators
The vector operators take vectors as operands and produce a new vector.
+ add element-wise
- subtract element-wise
The "-" can also be used as prefix operator to element-wise negate a vector.
The vector dot-product operator takes two vectors as operands and produces a scalar.
Matrix Multiplication
* matrix/vector multiplication
Contents
1 Table of Contents
2 Introduction
3 First Steps
3.1 Compiling and rendering our first model
3.2 See also
3.3 There is no semicolon following the translate command
3.4 CGAL Surfaces
3.5 CGAL Grid Only
3.6 The OpenCSG View
3.7 The thrown together view
4 The OpenSCAD User Interface
4.1 View navigation
4.2 View setup
4.2.1 Render modes
4.2.1.1 OpenCSG (F9)
4.2.1.1.1 Implementation Details
4.2.1.2 CGAL (Surfaces and Grid, F10 and F11)
4.2.1.2.1 Implementation Details
4.2.2 View options
5.17.5 floor
5.17.6 ln
5.17.7 len
5.17.8 log
5.17.9 lookup
5.17.10 max
5.17.11 min
5.17.12 norm
5.17.13 pow
5.17.14 rands
5.17.15 round
5.17.16 sign
5.17.17 sqrt
5.17.18 str
5.17.19 Also See search()
5.17.20 cube
5.17.21 sphere
5.17.22 cylinder
5.17.23 polyhedron
5.17.24 scale
5.17.25 resize
5.17.26 rotate
5.17.27 translate
5.17.28 mirror
5.17.29 multmatrix
5.17.30 color
5.17.31 minkowski
5.17.32 hull
5.17.33 union
5.17.34 difference
5.17.35 intersection
5.17.36 render
5.17.37 Background Modifier
5.17.38 Debug Modifier
5.17.39 Root Modifier
5.17.40 Disable Modifier
5.17.41 usage
5.17.42 children (previously: child)
5.17.43 arguments
5.17.44 Special variables
5.17.44.1 $fa, $fs and $fn
5.17.44.2 $t
5.17.44.3 $vpr and $vpt
5.17.45 Echo Statements
5.17.46 Render
5.17.47 Surface
5.17.48 Search
5.17.48.1 Search Usage
5.17.48.2 Search Arguments
5.17.48.3 Search Usage Examples
5.17.48.3.1 Index values return as list
5.17.48.3.2 Search on different column; return Index values
5.17.48.3.3 Search on list of values
5.17.48.3.4 Search on list of strings
5.17.48.3.5 Getting the right results
5.17.49 OpenSCAD Version
5.17.50 parent_module(n) and $parent_modules
6 Using the 2D Subsystem
6.1 square
6.2 circle
6.3 polygon
6.4 import_dxf
6.5 Linear Extrude
6.5.1 Usage
6.5.2 Twist
6.5.3 Center
6.5.4 Mesh Refinement
6.5.5 Scale
6.6 Rotate Extrude
6.6.1 Examples
6.6.2 Mesh Refinement
6.6.3 Extruding a Polygon
6.7 Description of extrude parameters
6.7.1 Extrude parameters for all extrusion modes
6.7.2 Extrude parameters for linear extrusion only
6.8 Linear Extrude
6.9 Rotate Extrude
6.10 Getting Inkscape to work
6.11 Description of extrude parameters
6.11.1 Extrude parameters for all extrusion modes
6.11.2 Extrude parameters for linear extrusion only
6.12 PS/EPS
6.13 SVG
6.14 Makefile automation
7 STL Import and Export
8 Import and Export
8.1 Import
8.1.1 import
8.1.2 import_stl
8.2 STL Export
8.2.1 STL Export
8.2.2 import
8.2.3 import_stl
8.2.4 STL Export
8.3 Dodecahedron
8.4 Bounding Box
8.4.1 Export options
8.4.1.1 Camera and image output
8.4.2 Constants
8.4.3 Command to build required files
8.4.4 Makefile example
8.4.4.1 Automatic targets
8.4.5 Windows notes
9 Building OpenSCAD from Sources
9.1 Prebuilt binary packages
9.2 Building OpenSCAD yourself
9.2.1 Installing dependencies
9.2.2 Building the dependencies yourself
9.2.3 Build the OpenSCAD binary
9.3 Compiling the test suite
9.4 Troubleshooting
9.4.1 Errors about incompatible library versions
9.4.2 OpenCSG didn't automatically build
9.4.3 CGAL didn't automatically build
9.4.4 Compiling is horribly slow and/or grinds the disk
9.4.5 BSD issues
9.4.6 Test suite problems
9.4.7 I moved the dependencies I built and now openscad won't run
9.5 Tricks and tips
9.5.1 Reduce space of dependency build
9.5.2 Preferences
9.5.3 Setup environment to start developing OpenSCAD in Ubuntu
11.04
9.5.4 The Clang Compiler
9.6 Setup
9.7 Requirements
9.8 Build OpenSCAD
9.9 Downloads
9.10 Installing
9.11 Compiling Dependencies
9.11.1 Qt
9.11.2 CGAL
9.11.3 OpenCSG
9.11.4 OpenSCAD
9.12 Building an installer
9.13 Compiling the regression tests
9.14 Troubleshooting
9.14.1 CGAL
9.14.2 References
10 Libraries
11 Library Locations
11.1 Setting OPENSCADPPATH
12 MCAD
13 Other Libraries
14 Command Glossary
14.1 Mathematical Operators
14.2 Mathematical Functions
14.3 String Functions
14.4 Primitive Solids
14.5 Transformations
14.6 Conditional and Iterator Functions
14.7 CSG Modelling
14.8 Modifier Characters
14.9 Modules
14.10 Include Statement
14.11 Other Language Features
14.12 2D Primitives
14.13 3D to 2D Projection
14.14 2D to 3D Extrusion
14.15 DXF Extrusion
14.16 STL Import
15 Index
Trigonometric Functions
cos
Parameters
<degrees>
Decimal. Angle in degrees.
Usage Example:
for(i=[0:36])
translate([i*10,0,0])
cylinder(r=5,h=cos(i*10)*50+60);
sin
Parameters
<degrees>
Decimal. Angle in degrees.
Usage example 1:
for (i = [0:5]) {
echo(360*i/6, sin(360*i/6)*80, cos(360*i/6)*80);
translate([sin(360*i/6)*80, cos(360*i/6)*80, 0 ])
cylinder(h = 200, r=10);
}
Usage example 2:
for(i=[0:36])
translate([i*10,0,0])
cylinder(r=5,h=sin(i*10)*50+60);
tan
Parameters
<degrees>
Decimal. Angle in degrees.
Usage example:
for (i = [0:5]) {
echo(360*i/6, tan(360*i/6)*80);
translate([tan(360*i/6)*80, 0, 0 ])
cylinder(h = 200, r=10);
}
acos
asin
atan
Mathematical arctangent, or inverse tangent, function. Returns the principal value of the
arc tangent of x, expressed in degrees. See: Inverse trigonometric functions
atan2
Mathematical two-argument atan function, taking y as its first argument. Returns the
principal value of the arc tangent of y/x, expressed in degrees. See: atan2
Mathematical absolute value function. Returns the positive value of a signed decimal
number.
Usage examples:
abs(-5.0);
abs(0);
abs(8.0);
Results:
5.0
0.0
8.0
ceil
Mathematical ceiling function. ceil(x) is the smallest integer not less than x.
cross
Calculates the cross product of two vectors in 3D space. The result is a vector that is
perpendicular to both of the input vectors.
Using invalid input parameters (e.g. vectors with a length different from 3 or other types)
will produce an undefined result.
Usage examples:
exp
Mathematical exp function. Returns the base-e exponential function of x, which is the
number e raised to the power x. See: Exponent
floor
Mathematical floor function. floor(x) = is the largest integer not greater than x
ln
len
Usage examples:
str1="abcdef"; len_str1=len(str1);
echo(str1,len_str1);
a=6; len_a=len(a);
echo(a,len_a);
array1=[1,2,3,4,5,6,7,8]; len_array1=len(array1);
echo(array1,len_array1);
array2=[[0,0],[0,1],[1,0],[1,1]]; len_array2=len(array2);
echo(array2,len_array2);
len_array2_2=len(array2[2]);
echo(array2[2],len_array2_2);
Results:
ECHO: "abcdef", 6
ECHO: 6, undef
ECHO: [1, 2, 3, 4, 5, 6, 7, 8], 8
ECHO: [[0, 0], [0, 1], [1, 0], [1, 1]], 4
ECHO: [1, 0], 2
Usage examples:
str2="4711";
for (i=[0:len(str2)-1])
echo(str("digit ",i+1," : ",str2[i]));
Results:
Note that the len() function is not defined when a simple variable is passed as the