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>);