Peyep CGA 函数参考规则内联与三维布尔 · 2026.0
版本首页查看 demo →
← 返回 2026.0 分类导航

规则内联与三维布尔 Rule Inlining and Boolean 3D · 4 个函数

体块并 / 交 / 差运算与规则内联

inline native ✓ cpp-fast ✓ 已验证 40 条 · silver 官方文档 ↗ #
规则内联:把后继形状合并回当前作用域
签名(6 种重载)
inline Rule
inline subdivision
inline { operations }
inline(geometryMergeStrategy) Rule
inline(geometryMergeStrategy) subdivision
inline(geometryMergeStrategy) { operations }
参数说明
参数类型说明
geometryMergeStrategyselector
Syntax options:—
官方说明(英文原文)

The inline keyword triggers the immediate derivation of the specified rule, subdivision operation, or shape operation sequence. The resulting shapes are then automatically merged into a single shape that replaces the current shape. In case it results in a single shape, it is taken as is. If it results in multiple shapes, their geometries are combined according to the geometryMergeStrategy. By default (if no strategy is specified) the geometries are just appended.

If the inlined shapes have conflicting material attributes, each shape's material is written to the geometry, meaning that all materials are preserved. For other attributes, the value of the current shape is kept if the inlined shapes have conflicting values or if more than one set operation has occurred.

Concept

This is the initial shape.

Two rules are applied to the initial shape: Volumes splits the shape and inserts different assets, while Colorize sets a yellow color. The rules modify the input shape independently and do not affect each other.

This can be observed in the Model Hierarchy where both rules represent the root of a separate shape subtree. The leaf shapes in the full shape tree collectively form the visible model.

Init -->
    Volumes
    Colorize

Colorize --> color(1,1,0) Yellow.

Volumes --> split(x) { '0.5: A | '0.5: B }
    
A --> split(z) { '0.5: Sphere   | '0.5: Beethoven }
B --> split(z) { '0.5: Cylinder | '0.5: Cone }
    
Sphere    --> primitiveSphere
Cylinder  --> primitiveCylinder
Cone      --> primitiveCone
Beethoven --> i("beethoven.obj")

Inlining Volumes enables the two rules to be sequentialized, allowing Colorize to take the combined result of Volumes as input.

Essentially, an inlined rule can be used like a built-in shape operation (e.g., extrude) to directly modify the current shape.

Init -->
    inline Volumes
    Colorize

The subtree generated by an inlined rule (e.g., Volumes) is collapsed and removed from the Model Hierarchy, providing control over the derivation order as well as the structure of the shape tree.

Geometry merge strategy

The correct geometryMergeStrategy depends on the modeling objective:

  • append

    Default. Used to simply collect the geometries of multiple shapes and put them into a single mesh. No geometry cleanup is performed and all components are kept as is.

  • unify

    Used to combine the geometries of intersecting shapes with Boolean operations. Intersecting faces get topologically connected and inner faces are removed.

  • recompose

    Used to topologically recombine the geometries of subdivided shapes. Shapes are automatically reconnected at shared vertices and edges, see Shape Recomposition. The strategy can be used to recombine shapes created with, for example, the split or comp operations.

官方示例(共 9 个,展示前 3 个) · 点击展开
Init -->
    primitiveCube
    print("start: " + geometry.nVertices)
    inline comp(f) { all: SetColor }
    print("inline: " + geometry.nVertices)
    
rampValue = comp.index/comp.total
SetColor -->
    set(material.opacity, 0.9)
    color(colorRamp("spectrum", rampValue))
Init -->
    primitiveCube
    print("start: " + geometry.nVertices)
    inline(recompose) comp(f) { all: SetColor }
    print("inline(recompose): " + geometry.nVertices)
Init --> 
    inline { LayoutA LayoutB }
    ChooseLayout

LayoutA --> offset(-15, border) tag("LayoutA")
LayoutB --> split(x) { 15: tag("LayoutB") Lot. 
                     | ~10: NIL }*

taggedArea(name) = 
    sum(comp(f) { isTagged(name): geometry.area })

ChooseLayout -->
    case taggedArea("LayoutA") > taggedArea("LayoutB"):
          inline Extract("LayoutA")
          Mass
    else: 
          inline Extract("LayoutB")
          Mass

Extract(name) --> 
    comp(f, noAlign) { isTagged(name)= Extract. }
	
Mass --> extrude(30)
我方已验证示例:learning case #70(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/*
Set the material.
Option to fully or partially override material.

Input shape:
	* any

Notes:
	* Full_Override=true (default):
		* Override all material attrs.
	* Full_Override=false:
		* Only override material attrs defined in selected material file.  Do not override any other material attrs.
		* If a color already exists on the input shape, and the selected material does not have a color but has a colormap, then the existing color will continue to exist. The existing color is multiplied wi…
union native ✓ cpp-fast ✓ 已实现未验证 官方文档 ↗ #
三维布尔并集
签名(1 种重载)
union { operationsA | operationsB }
参数说明
参数类型说明
operationsA—A sequence of operations applied on the current shape for operand A.
operationsB—A sequence of operations applied on the current shape for operand B.
官方说明(英文原文)

The union, intersect, and subtract operations perform a Boolean operation with the result of the inlined operationsA (operand A) and the result of the inlined operationsB (operand B). The operands are constructed analogous to using inline(unify), i.e. the shapes resulting from the derivation of operationsA (or operationsB) are first merged using a Boolean union operation.

The first operand A determines the resulting shape and rule attributes and specifies which material is used for overlapping geometry. In case the operands have conflicting material attributes, their materials are first written to the geometry, ensuring that all material properties are preserved.

Component tags

The operations automatically apply semantic component tags to the resulting face components:

"bool.A"

"bool.B"

"bool.cut"

Faces from operand A (blue)

Faces from operand B (green)

Intersection edges (orange)

Left   --> union { Cube | Sphere }
           comp(f) { isTagged("bool.A")   : Blue 
                   | isTagged("bool.B")   : Green  }
           comp(e) { isTagged("bool.cut") : Orange }

Cube   --> primitiveCube
Sphere --> t(0.3,0.3,0.3) primitiveSphere

Middle --> subtract  { Cube | Sphere } ...
Right  --> intersect { Cube | Sphere } ...

Note:
For overlapping faces (2D intersection) both "bool.A" and "bool.B" are applied.

For more information on working with component tags, refer to Auto-tags and Tag propagation.

Open and closed operands

Boolean operations are well defined in 2D (planar planes) and in 3D for closed meshes. In 3D, open operands (planes and meshes with holes) are assumed closed as long as boundaries are not intersected. See the reference table and the example below.

The common use cases of "Plane subtract Volume" and "Plane intersect Volume" are facilitated using the "bool" auto-tags in a subsequent comp operation. This is illustrated in the following example:

subtract { Blue | Green }
intersect { Blue | Green }
comp(f) { isTagged("bool.A") : Blue }

Reference Table

Both operands closed

Open and closed operand

Plane normal pointing up

Open and closed operand

Plane normal pointing down

Open and closed operand

Only partially intersecting

Input operands

union { Blue 
      | Green }
subtract { Blue 
         | Green }
subtract { Green 
         | Blue }
intersect { Blue 
          | Green }
inline(unify) {
    Green 
    Blue 
}

官方示例(共 16 个,展示前 3 个) · 点击展开
Blue   --> color("#0399F5")
Green  --> color("#09DE1F")
Yellow --> color("#FADB19")
Purple --> color("#8D09DE")
Red    --> color("#FF360A")
Orange --> color("#FA9100")
Left     --> subtract { Cube     | Cylinder }
Right    --> subtract { Cylinder | Cube     }

Cube     --> primitiveCube 
             Blue

Cylinder --> t(3,3,3)
             primitiveCylinder
             Green
Left   --> union { Quad   | Circle }
Right  --> union { Circle | Quad }
 
Quad   --> primitiveQuad 
           Blue

Circle --> t(3,0,3)
           primitiveDisk
           Green
subtract native ✓ cpp-fast ✓ 已实现未验证 官方文档 ↗ #
三维布尔差集
签名(1 种重载)
subtract { operationsA | operationsB }
参数说明
参数类型说明
operationsA—A sequence of operations applied on the current shape for operand A.
operationsB—A sequence of operations applied on the current shape for operand B.
官方说明(英文原文)

The union, intersect, and subtract operations perform a Boolean operation with the result of the inlined operationsA (operand A) and the result of the inlined operationsB (operand B). The operands are constructed analogous to using inline(unify), i.e. the shapes resulting from the derivation of operationsA (or operationsB) are first merged using a Boolean union operation.

The first operand A determines the resulting shape and rule attributes and specifies which material is used for overlapping geometry. In case the operands have conflicting material attributes, their materials are first written to the geometry, ensuring that all material properties are preserved.

Component tags

The operations automatically apply semantic component tags to the resulting face components:

"bool.A"

"bool.B"

"bool.cut"

Faces from operand A (blue)

Faces from operand B (green)

Intersection edges (orange)

Left   --> union { Cube | Sphere }
           comp(f) { isTagged("bool.A")   : Blue 
                   | isTagged("bool.B")   : Green  }
           comp(e) { isTagged("bool.cut") : Orange }

Cube   --> primitiveCube
Sphere --> t(0.3,0.3,0.3) primitiveSphere

Middle --> subtract  { Cube | Sphere } ...
Right  --> intersect { Cube | Sphere } ...

Note:
For overlapping faces (2D intersection) both "bool.A" and "bool.B" are applied.

For more information on working with component tags, refer to Auto-tags and Tag propagation.

Open and closed operands

Boolean operations are well defined in 2D (planar planes) and in 3D for closed meshes. In 3D, open operands (planes and meshes with holes) are assumed closed as long as boundaries are not intersected. See the reference table and the example below.

The common use cases of "Plane subtract Volume" and "Plane intersect Volume" are facilitated using the "bool" auto-tags in a subsequent comp operation. This is illustrated in the following example:

subtract { Blue | Green }
intersect { Blue | Green }
comp(f) { isTagged("bool.A") : Blue }

Reference Table

Both operands closed

Open and closed operand

Plane normal pointing up

Open and closed operand

Plane normal pointing down

Open and closed operand

Only partially intersecting

Input operands

union { Blue 
      | Green }
subtract { Blue 
         | Green }
subtract { Green 
         | Blue }
intersect { Blue 
          | Green }
inline(unify) {
    Green 
    Blue 
}

官方示例(共 16 个,展示前 3 个) · 点击展开
Blue   --> color("#0399F5")
Green  --> color("#09DE1F")
Yellow --> color("#FADB19")
Purple --> color("#8D09DE")
Red    --> color("#FF360A")
Orange --> color("#FA9100")
Left     --> subtract { Cube     | Cylinder }
Right    --> subtract { Cylinder | Cube     }

Cube     --> primitiveCube 
             Blue

Cylinder --> t(3,3,3)
             primitiveCylinder
             Green
Left   --> union { Quad   | Circle }
Right  --> union { Circle | Quad }
 
Quad   --> primitiveQuad 
           Blue

Circle --> t(3,0,3)
           primitiveDisk
           Green
intersect native ✓ cpp-fast ✓ 已实现未验证 官方文档 ↗ #
三维布尔交集
签名(1 种重载)
intersect { operationsA | operationsB }
参数说明
参数类型说明
operationsA—A sequence of operations applied on the current shape for operand A.
operationsB—A sequence of operations applied on the current shape for operand B.
官方说明(英文原文)

The union, intersect, and subtract operations perform a Boolean operation with the result of the inlined operationsA (operand A) and the result of the inlined operationsB (operand B). The operands are constructed analogous to using inline(unify), i.e. the shapes resulting from the derivation of operationsA (or operationsB) are first merged using a Boolean union operation.

The first operand A determines the resulting shape and rule attributes and specifies which material is used for overlapping geometry. In case the operands have conflicting material attributes, their materials are first written to the geometry, ensuring that all material properties are preserved.

Component tags

The operations automatically apply semantic component tags to the resulting face components:

"bool.A"

"bool.B"

"bool.cut"

Faces from operand A (blue)

Faces from operand B (green)

Intersection edges (orange)

Left   --> union { Cube | Sphere }
           comp(f) { isTagged("bool.A")   : Blue 
                   | isTagged("bool.B")   : Green  }
           comp(e) { isTagged("bool.cut") : Orange }

Cube   --> primitiveCube
Sphere --> t(0.3,0.3,0.3) primitiveSphere

Middle --> subtract  { Cube | Sphere } ...
Right  --> intersect { Cube | Sphere } ...

Note:
For overlapping faces (2D intersection) both "bool.A" and "bool.B" are applied.

For more information on working with component tags, refer to Auto-tags and Tag propagation.

Open and closed operands

Boolean operations are well defined in 2D (planar planes) and in 3D for closed meshes. In 3D, open operands (planes and meshes with holes) are assumed closed as long as boundaries are not intersected. See the reference table and the example below.

The common use cases of "Plane subtract Volume" and "Plane intersect Volume" are facilitated using the "bool" auto-tags in a subsequent comp operation. This is illustrated in the following example:

subtract { Blue | Green }
intersect { Blue | Green }
comp(f) { isTagged("bool.A") : Blue }

Reference Table

Both operands closed

Open and closed operand

Plane normal pointing up

Open and closed operand

Plane normal pointing down

Open and closed operand

Only partially intersecting

Input operands

union { Blue 
      | Green }
subtract { Blue 
         | Green }
subtract { Green 
         | Blue }
intersect { Blue 
          | Green }
inline(unify) {
    Green 
    Blue 
}

官方示例(共 16 个,展示前 3 个) · 点击展开
Blue   --> color("#0399F5")
Green  --> color("#09DE1F")
Yellow --> color("#FADB19")
Purple --> color("#8D09DE")
Red    --> color("#FF360A")
Orange --> color("#FA9100")
Left     --> subtract { Cube     | Cylinder }
Right    --> subtract { Cylinder | Cube     }

Cube     --> primitiveCube 
             Blue

Cylinder --> t(3,3,3)
             primitiveCylinder
             Green
Left   --> union { Quad   | Circle }
Right  --> union { Circle | Quad }
 
Quad   --> primitiveQuad 
           Blue

Circle --> t(3,0,3)
           primitiveDisk
           Green