OpenSCAD 用户手册/命令词汇表
外观
这是一个快速参考;所有命令的简短摘要,没有示例,只有基本语法。标题是完整章节的链接。
请注意:命令词汇表目前已过时(2015 年 03 月)。
请改用速查表
http://www.openscad.org/cheatsheet/
+ - // also as unary negative * / % // this is mod
< <= == != >= >
&& // logical and || // logical or ! // logical not
<boolean> ? <valIfTrue> : <valIfFalse>
abs ( <value> )
cos ( <degrees> ) sin ( <degrees> ) tan ( <degrees> ) asin ( <value> ) acos ( <value> ) atan ( <value> ) atan2 ( <y_value>, <x_value> )
pow( <base>, <exponent> )
len ( <string> ) len ( <vector> ) len ( <vector_of_vectors> ) min ( <value1>, <value2> ) max ( <value1>, <value2> ) sqrt ( <value> ) round ( <value> ) ceil ( <value> ) floor ( <value> ) lookup( <in_value>, <vector_of_vectors> )
str(string, value, ...)
cube(size = <value or vector>, center = <boolean>);
sphere(r = <radius>);
cylinder(h = <height>, r1 = <bottomRadius>, r2 = <topRadius>, center = <boolean>); cylinder(h = <height>, r = <radius>);
polyhedron(points = [[x, y, z], ... ], triangles = [[p1, p2, p3..], ... ], convexity = N);
scale(v = [x, y, z]) { ... }
(In versions > 2013.03) resize(newsize=[x,y,z], auto=(true|false) { ... } resize(newsize=[x,y,z], auto=[xaxis,yaxis,zaxis]) { ... } // #axis is true|false resize([x,y,z],[xaxis,yaxis,zaxis]) { ... } resize([x,y,z]) { ... }
rotate(a = deg, v = [x, y, z]) { ... } rotate(a=[x_deg,y_deg,z_deg]) { ... }
translate(v = [x, y, z]) { ... }
mirror([ 0, 1, 0 ]) { ... }
multmatrix(m = [tranformationMatrix]) { ... }
color([r, g, b, a]) { ... } color([ R/255, G/255, B/255, a]) { ... } color("blue",a) { ... }
for (<loop_variable_name> = <vector> ) {...}
intersection_for (<loop_variable_name> = <vector_of_vectors>) {...}
if (<boolean condition>) {...} else {...}
assign (<var1>= <val1>, <var2>= <val2>, ...) {...}
union() {...}
difference() {...}
intersection() {...}
render(convexity = <value>) { ... }
! { ... } // Ignore the rest of the design and use this subtree as design root * { ... } // Ignore this subtree % { ... } // Ignore CSG of this subtree and draw it in transparent gray # { ... } // Use this subtree as usual but draw it in transparent pink
module name(<var1>, <var2>, ...) { ...<module code>...}
变量可以默认初始化<var1>=<defaultvalue>
在模块中,可以使用children()引用所有子节点,或children(i)其中i介于0和$children.
在 2010.02 之后
include <filename.scad> (appends whole file)
use <filename.scad> (appends ONLY modules and functions)
filename 可以使用目录(使用 / 字符分隔符)。
在 2010.02 之前
<filename.scad>
$fa is the minimum angle for a fragment. The default value is 12 (degrees)
$fs is the minimum size of a fragment. The default value is 1.
$fn is the number of fragments. The default value is 0.
当 $fa 和 $fs 用于确定圆的片段数量时,OpenSCAD 从未使用少于 5 个片段。
$t
$t 变量用于动画。如果您使用 view->animate 启用动画帧并为“FPS”和“Steps”提供值,则“Time”字段将显示 $t 的当前值。
function name(<var>) = f(<var>);
echo(<string>, <var>, ...);
render(convexity = <val>) {...}
surface(file = "filename.dat", center = <boolean>, convexity = <val>);
square(size = <val>, center=<boolean>); square(size = [x,y], center=<boolean>);
circle(r = <val>);
polygon(points = [[x, y], ... ], paths = [[p1, p2, p3..], ... ], convexity = N);
3D 到 2D 投影
[编辑 | 编辑源代码]projection(cut = <boolean>)
2D 到 3D 拉伸
[编辑 | 编辑源代码]linear_extrude(height = <val>, center = <boolean>, convexity = <val>, twist = <degrees>[, slices = <val>, $fn=...,$fs=...,$fa=...]){...}
rotate_extrude(convexity = <val>[, $fn = ...]){...}
linear_extrude(height = <val>, center = <boolean>, convexity = <val>, twist = <degrees>[...]) import (file = "filename.dxf", layer = "layername")
rotate_extrude(origin = [x,y], convexity = <val>[, $fn = ...]) import (file = "filename.dxf", layer = "layername")
import("filename.stl", convexity = <val>);