元編程參考文件

CAD 二維形狀

25 個節點

本頁內容 25

形狀面積

函數

A shape's area, in square model units.

簽名
形狀面積(形狀: Cad Shape) -> 數字
double Area(CadShape shape)

參數

名稱型別預設值說明
形狀Cad Shape—

返回

結果數字
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀包圍盒

函數

The box round a shape, flat at Z = 0.

簽名
形狀包圍盒(形狀: Cad Shape) -> Bounding Box
BoundingBox Bounds(CadShape shape)

參數

名稱型別預設值說明
形狀Cad Shape—

返回

結果Bounding Box
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

圓

函數

A disk centred on the origin, an exact circle; or, given three or more segments, OpenSCAD's regular polygon of that many corners on the circle, the first on +X: circle(r, $fn = segments).

簽名
圓(半徑: 數字, 分段數: 整數) -> Cad Shape
CadShape Circle(double radius, int segments = 0)

參數

名稱型別預設值說明
半徑數字—Its radius: the corners' distance from the middle when it has segments.
分段數整數0Zero for an exact circle, or the number of a polygon's corners (at least three).

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀差集

函數

A shape with every cutter taken away, OpenSCAD's difference() of 2D children: the first child less the others.

簽名
形狀差集 -> Cad Shape
    形狀: Cad Shape
    切除形狀: Cad Shape 陣列
    容差: 數字
CadShape Difference(
    CadShape shape,
    CadShape[] cutters,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape—What is cut.
切除形狀Cad Shape 陣列—What cuts it.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

填充孔洞

函數

A shape without its holes, OpenSCAD's fill(): each region's outer boundary filled, islands in former holes merged in.

簽名
填充孔洞(形狀: Cad Shape, 容差: 數字) -> Cad Shape
CadShape Fill(CadShape shape, double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

OpenSCAD 分段數

函數

How many segments OpenSCAD cuts a circle of a radius into, from its special variables: $fn when it is set, else as many as keep each segment's angle at least Minimum Angle and its length at least Minimum Size, and never fewer than five. Give the count to Cad2D.Circle, Cad.Frustum and the other round operations to reproduce a model that relies on OpenSCAD's facets; leave it out for exact circles.

簽名
OpenSCAD 分段數 -> 整數
    半徑: 數字
    $fn: 整數
    最小角度 $fa: 數字
    最小長度 $fs: 數字
int Fragments(
    double radius,
    int fn = 0,
    double minimumAngle = 0.20943951023931953,
    double minimumSize = 2)

參數

名稱型別預設值說明
半徑數字—The circle's radius.
$fn整數0OpenSCAD's $fn: zero when not set.
最小角度 $fa數字0.20943951023931953OpenSCAD's $fa, in radians: 12° unless set.
最小長度 $fs數字2OpenSCAD's $fs, in model units: 2 unless set.

返回

結果整數
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

由曲線生成形狀

函數

The shape closed curves in the XY plane enclose: even-odd by default, as polygon paths are, so curves inside others are holes; nonzero reads which way each curve runs, as font outlines and most SVG paths do; any fills everything inside any curve.

簽名
由曲線生成形狀 -> Cad Shape
    邊界: Curve 陣列
    填充規則: Curve Fill Rule
    容差: 數字
CadShape FromCurves(
    Curve[] boundaries,
    CurveFillRule fill = CurveFillRule.EvenOdd,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
邊界Curve 陣列—Closed curves lying in the XY plane.
填充規則Curve Fill RuleEven oddWhich points they enclose.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

由區域生成形狀

函數

The shape of planar regions in the XY plane - what CadCurves.BooleanRegions and CadText.Regions give - merged where they overlap.

簽名
由區域生成形狀(區域: Curve Region 陣列, 容差: 數字) -> Cad Shape
CadShape FromRegions(
    CurveRegion[] regions,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
區域Curve Region 陣列—The regions, each an outer boundary with holes.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀凸包

函數

The convex hull of flat shapes, OpenSCAD's hull() of 2D children: the smallest convex shape holding them all. Exact for lines and arcs - the hull of circles is their arcs and the lines tangent to two of them - and within the tolerance for other curves, which are first followed by tangent arcs.

簽名
形狀凸包(形狀: Cad Shape 陣列, 容差: 數字) -> Cad Shape
CadShape Hull(CadShape[] shapes, double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape 陣列—The shapes.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape

備註

Built by turning a direction once round and following, for each, the piece of the shapes furthest along it: a corner, or a stretch of an arc whose outward normal it is; where the furthest piece changes, the hull runs straight from one to the next along the line touching both.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

平面點的凸包

函數

The convex hull of points in the XY plane, as a flat shape; their Z is ignored. Fewer than three points not in a line hold no area and give an empty shape.

簽名
平面點的凸包(點: Point3d 陣列, 容差: 數字) -> Cad Shape
CadShape HullOfPoints(
    Point3d[] points,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
點Point3d 陣列—The points.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀交集

函數

What every shape has in common, OpenSCAD's intersection() of 2D children. An empty list gives an empty shape.

簽名
形狀交集(形狀: Cad Shape 陣列, 容差: 數字) -> Cad Shape
CadShape Intersection(
    CadShape[] shapes,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape 陣列—The shapes.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀閔可夫斯基和

函數

The Minkowski sum of flat shapes, OpenSCAD's minkowski() of 2D children: every point of one added to every point of the next. Exact where one of two shapes is a circle (the other offset by its radius, as OpenSCAD's rounded rectangle is), or one is made of lines and the other is convex; otherwise the shapes' arcs are followed by lines within the tolerance first.

簽名
形狀閔可夫斯基和(形狀: Cad Shape 陣列, 容差: 數字) -> Cad Shape
CadShape Minkowski(CadShape[] shapes, double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape 陣列—The shapes, summed in turn.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape

備註

A shape of lines A plus a convex shape B is A moved by a point of B together with, for each line of A's boundary, the hull of B at its two ends; a shape of lines that is not convex is cut into trapezoids, which are.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

鏡像形狀

函數

A shape mirrored in the line through the origin square to a direction, OpenSCAD's mirror([x, y]): (1, 0) mirrors left to right.

簽名
鏡像形狀 -> Cad Shape
    形狀: Cad Shape
    法向 X: 數字
    法向 Y: 數字
CadShape Mirror(CadShape shape, double normalX, double normalY)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
法向 X數字—The mirror line's normal, along X.
法向 Y數字—The mirror line's normal, along Y.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

圓角偏移

函數

A shape grown or shrunk by a distance with round corners, OpenSCAD's offset(r): growing, every point within the radius of the shape joins it (its Minkowski sum with a disk); shrinking, every point within the radius of its outside leaves it. Boundaries of lines and arcs give exact lines and arcs; other curves are first followed within the tolerance by tangent-continuous arcs.

簽名
圓角偏移(形狀: Cad Shape, 半徑: 數字, 容差: 數字) -> Cad Shape
CadShape Offset(
    CadShape shape,
    double radius,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
半徑數字—How far, in model units: positive grows, negative shrinks.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape

備註

Every boundary is offset whole, exactly: each line and arc moved out (or in) by the distance - an arc tighter than that through its middle and out the other side - with an arc round each corner. Those curves hold every edge of the result but may cross themselves and each other; the plane they cut up is kept face by face where a point inside the face is in the shape or within the distance of it (growing), or in the shape and no nearer its edge than the distance (shrinking). Narrow gaps close and thin parts vanish as they should.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

尖角偏移

函數

A shape grown or shrunk by a distance with sharp corners, OpenSCAD's offset(delta, chamfer): every boundary moves out (or in) square to itself, and corners are carried out to where the moved sides meet, or with Chamfer cut straight across. Sides of lines and arcs stay exact; at a corner of an arc the moved sides are met along their tangents.

簽名
尖角偏移 -> Cad Shape
    形狀: Cad Shape
    距離: 數字
    倒角: 真否
    容差: 數字
CadShape OffsetDelta(
    CadShape shape,
    double delta,
    bool chamfer = false,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
距離數字—How far, in model units: positive grows, negative shrinks.
倒角真否FalseCut the corners across rather than carrying them to a point.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape

備註

Every boundary is offset whole, its corners carried out (or cut) on the side the offset opens and joined straight across where the offset sides cross; the plane those curves cut up is kept face by face where they wind round it positively, as Clipper fills a mitred offset, so the loops a concave corner throws out of a growing shape, and the reversed ones of a shrinking shape's vanished parts, are left out.

所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀輪廓

函數

Copies of every boundary of a shape: each region's outer boundary, then its holes.

簽名
形狀輪廓(形狀: Cad Shape) -> Curve 陣列
Curve[] Outlines(CadShape shape)

參數

名稱型別預設值說明
形狀Cad Shape—

返回

結果Curve 陣列
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

多邊形

函數

A polygon through points, OpenSCAD's polygon(points, paths): with no paths, one boundary through every point in order; with paths, one boundary through each list of point indices. The boundaries are filled even-odd, so a path inside another is a hole, and one inside that an island, whichever way each runs; a boundary that crosses itself fills alternately.

簽名
多邊形 -> Cad Shape
    點: Point3d 陣列
    路徑: 整數陣列陣列
    容差: 數字
CadShape Polygon(
    Point3d[] points,
    int[][] paths,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
點Point3d 陣列—The points; only X and Y are read.
路徑整數陣列陣列—Lists of indices into Points, one a boundary; null for one boundary through every point.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

調整形狀尺寸

函數

A shape scaled about the origin to a width and height, OpenSCAD's resize([x, y], auto): a size of zero keeps that direction as it is, or, with Auto, scales it by the largest factor of the sizes given, keeping the proportions.

簽名
調整形狀尺寸 -> Cad Shape
    形狀: Cad Shape
    寬度: 數字
    高度: 數字
    自動: 真否
CadShape Resize(
    CadShape shape,
    double width,
    double height,
    bool auto = false)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
寬度數字—The new width along X; zero to leave it.
高度數字—The new height along Y; zero to leave it.
自動真否FalseScale the directions given zero with the others.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

旋轉形狀

函數

A shape turned about a point, counter-clockwise seen from +Z, OpenSCAD's rotate(a) about the origin (whose angle is in degrees).

簽名
旋轉形狀 -> Cad Shape
    形狀: Cad Shape
    角度: 數字
    中心 X: 數字
    中心 Y: 數字
CadShape Rotate(
    CadShape shape,
    double angle,
    double centerX = 0,
    double centerY = 0)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
角度數字—How far, in radians.
中心 X數字0The point it turns about, along X.
中心 Y數字0The point it turns about, along Y.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

縮放形狀

函數

A shape scaled about the origin, OpenSCAD's scale([x, y]). A negative factor mirrors it.

簽名
縮放形狀(形狀: Cad Shape, X 向: 數字, Y 向: 數字) -> Cad Shape
CadShape Scale(CadShape shape, double x, double y)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
X 向數字—The factor along X.
Y 向數字—The factor along Y.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

矩形

函數

A rectangle with a corner at the origin, or centred on it: OpenSCAD's square([width, height], center).

簽名
矩形(寬度: 數字, 高度: 數字, 置中: 真否) -> Cad Shape
CadShape Square(
    double width,
    double height,
    bool centered = false)

參數

名稱型別預設值說明
寬度數字—Along X.
高度數字—Along Y.
置中真否FalseCentred on the origin rather than cornered on it.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

文字形狀

函數

Text as a flat shape, OpenSCAD's text(text, size, font, halign, valign): the font's exact outlines, counters as holes, laid out from the origin along +X with lines going down. Size is the em height in model units (OpenSCAD's size is close to the cap height instead). The alignments stand the outline's box on the origin; laid out as is, the text starts at the origin on its first baseline.

簽名
文字形狀 -> Cad Shape
    文字: 文字
    字型: Cad Font
    字型大小: 數字
    水平對齊: Cad Text Horizontal
    垂直對齊: Cad Text Vertical
    容差: 數字
CadShape Text(
    string text,
    CadFont font,
    double size,
    CadTextHorizontal horizontal = CadTextHorizontal.Left,
    CadTextVertical vertical = CadTextVertical.Baseline,
    double tolerance = 1E-06)

參數

名稱型別預設值說明
文字文字—The text; newlines start new lines.
字型Cad Font—The font, captured beforehand (Parametric.CadFonts).
字型大小數字—The em height, in model units.
水平對齊Cad Text HorizontalLeftWhere the text stands across the origin.
垂直對齊Cad Text VerticalBaselineWhere the text stands up and down the origin.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

變換形狀

函數

A shape under a transform that keeps the XY plane where it is, OpenSCAD's multmatrix of a 2D child: any invertible mix of moves, turns, scales, mirrors and shears within the plane.

簽名
變換形狀(形狀: Cad Shape, 變換: Transform) -> Cad Shape
CadShape Transformed(CadShape shape, Transform transform)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
變換Transform—The transform; it must take the XY plane to itself.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

平移形狀

函數

A shape moved, OpenSCAD's translate([x, y]).

簽名
平移形狀(形狀: Cad Shape, X: 數字, Y: 數字) -> Cad Shape
CadShape Translate(CadShape shape, double x, double y)

參數

名稱型別預設值說明
形狀Cad Shape—The shape.
X數字—How far along X.
Y數字—How far along Y.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計

形狀並集

函數

Everything in any of the shapes, OpenSCAD's union() of 2D children. An empty list gives an empty shape.

簽名
形狀並集(形狀: Cad Shape 陣列, 容差: 數字) -> Cad Shape
CadShape Union(CadShape[] shapes, double tolerance = 1E-06)

參數

名稱型別預設值說明
形狀Cad Shape 陣列—The shapes.
容差數字1E-06The model's tolerance, in its units.

返回

結果Cad Shape
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
CAD 二維形狀
所屬包
電腦輔助設計