Peyep CGA 函数参考几何细分 · 2026.1
版本首页查看 demo →
← 返回 2026.1 分类导航

几何细分 Geometry Subdivision · 12 个函数

切分、退让、组件提取——把体块拆成可分别处理的部件

split native ✓ cpp-fast ✓ 已验证 560 条 · gold 官方文档 ↗ #
沿指定轴按比例 / 尺寸切分形状
签名(6 种重载)
split(axis) { size : operations | ... }
split(axis) { size : operations | ... }*
split(axis, adjustMode) { size : operations | ... }
split(axis, adjustMode) { size : operations | ... }*
split(direction, surfaceParameterization, uvSet) { size : operations | ... }
split(direction, surfaceParameterization, uvSet) { size : operations | ... }*
参数说明
参数类型说明
axisselector{ x | y | z }— Scope axis to split along.
adjustModeselector
directionselector{ u | v }— Texture-space axis to split along.
surfaceParameterizationselector
uvSetfloatNumber of texture a set/layer( integer number (range[0,9]). The numbering corresponds to the texture layers of the material attribute.
sizefloat
operations—A sequence of shape operations to execute on the newly created shape.
*—Repeat switch: the repeat switch triggers the repetition of the defined split into the current shape's scope, as many times as possible. The number of repetitions and floating dimensions are adapted to the best solution (best number of repetitions and least stretching).
官方说明(英文原文)

XYZ Split (Cartesian Space)

The split operation subdivides the current shape along the specified scope axis into a set of smaller shapes. For each size-operation block inside the curly brackets, a new shape is pushed onto the shape stack, a number of shape operations is executed and the shape on top of the shape stack is popped again.

If the optional repeat switch * is appended to the split operation, the content of {...} is repeated as often as it fully fits into the scope's dimension along the selected axis.

The geometry of the current shape is cut with a plane perpendicular to the split axis at every intersection between two blocks (i.e. at size1, size2, ... sizen-1). Hollow meshes are closed after the cut, i.e. cutting planes introduce new surfaces to preserve the volume.

Splits can be nested, i.e. a size : operation block can be replaced by a {...} block. In theory, the nested level is unlimited.

UV Split (Texture Space)

Splits can also be applied in the 2d uv texture domain. Texture coordinates define a 2d parameter space on a 3d surface. Examples of such parameterizations are streets (u along the w street direction, v along the width) and facades (generated with setupProjection() and projectUV(), u along the width and v along the height). This permits to operate directly on the surface. In general, uv coordinates are in the [0,1] range and not connected to a unit like meters or yards on the surface (defined by the underlying mesh). Setting the direction parameter to unitSpace permits to operate directly on the surface, i.e. work in units (e.g. meters or yards). Depending on the geometry and type of parameterization there is some inherent distortion in this conversion.

Borders (start, end) of the uv split are defined by the minimal and maximal values found in the selected uv coordinates. The general syntax of the split is the same as in the cartesian case described above, i.e. relative and floating operators (' and ~) can be used as well as the repeat operator (*). See the examples below.

Shape attributes

Each generated shape will have a number of attributes set:

  • split.index: The zero-based index of the selected component.
  • split.total: The total number of components selected by the selector.

Index and total are global; for instance

...
     primitiveCube()
     split(x) { '0.1 : A | '0.1 : B }*

will create 5 shapes with rule A interleaved with 5 shapes with rule B where split.index goes from 0 to 9 with all even numbers on rule A and all odd numbers on rule B while split.total will be 10.

For more information see split attribute.

官方示例(共 15 个,展示前 3 个) · 点击展开
X(h)-->
   s('1,'h,'1)
   color("#0000ff")
	
Y(h)-->
   s('1,'h,'1)
   color("#ffff00")
	
Z(h)-->
   s('1,'h,'1)
   color("#00ff00")
A-->
   split(x){ '0.5 : Z 
           | '0.1 : Y(2) 
           | '0.2 : X(1) }
A-->
   split(x){ ~0.5 : Z 
           | ~0.1 : Y(2) 
           | ~0.2 : X(1) }
我方已验证示例:基础挤出 + 颜色(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@Range(min=0, max=20, step=0.5)
attr height = 10
attr roofColor = "#333333"
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(height)
color(1,0.5,0.2)
comp(f){side:Facade|top:Roof}
Facade --> split(y) { ~1 : Floor }*
Floor --> color(0.7,0.75,0.8)
Roof --> roofHip(30) color(roofColor)
splitArea native ✓ cpp-fast ✓ 已验证 1 条 · screened 官方文档 ↗ #
按目标面积切分形状
签名(4 种重载)
splitArea(axis) { area : operations | ... }
splitArea(axis) { area : operations | ... }*
splitArea(axis, adjustMode) { area : operations | ... }
splitArea(axis, adjustMode) { area : operations | ... }*
参数说明
参数类型说明
axisselector{ x | y | z }— Scope axis to split along.
adjustMode—
areafloat
operations—A sequence of shape operations to execute on the newly created shape.
*—Repeat switch: the repeat switch triggers the repetition of the defined split into the current shape's scope, as many times as possible. The number of repetitions and floating dimensions are adapted to the best solution (best number of repetitions and least stretching).
官方说明(英文原文)

The splitArea operation subdivides the geometry of the current shape along the specified scope axis into a set of shapes with geometric areas specified by the area parameter. This operation works on planar 2D geometry and almost planar geometry. The area accuracy breaks down with nonplanar geometry. This operation does not apply to 3D geometry such as meshes or highly nonplanar geometry.

For each specified area, the current shape's geometry is cut with planes perpendicular to the split axis such that the resulting shape contains geometry with the specified area.

The optional repeat switch * can be used to repeat the content within a { ... }* block as many times as it fully fits into the scope's dimension along the selected axis.

官方示例(共 9 个,展示前 3 个) · 点击展开
Red     -->                          // red
   color(1, 0, 0)                       
   print("area(R) = " + geometry.area)

Yellow  -->                         // yellow
   color(1, 1, 0)                       
   print("area(Y) = " + geometry.area)

Green   -->                         // green
   color(0, 1, 0)                       
   print("area(G) = " + geometry.area)

Cyan    -->                         // cyan
   color(0, 1, 1)                      
   print("area(C) = " + geometry.area)

Blue    -->                         // blue
   color(0, 0, 1)                       
   print("area(B) = " + geometry.area)

Magenta -->                         // magenta
   color(1, 0, 1)                      
   print("area(M) = " + geometry.area)

Pink    -->                         // semi-transparent pink
   color(1, 0.5, 0.5, 0.3)
Lot -->
   print("total area = " + geometry.area)
   splitArea(x) { '0.7 : Green
                | '0.3 : Yellow }
Lot -->
   print("total area = " + geometry.area)
   splitArea(x) { '0.2 : ColorMe }*

ColorMe -->
   case split.index == 0 :
      Red
   case split.index == 1 :
      Yellow
   case split.index == 2 :
      Green
   case split.index == 3 :
      Cyan
   else :
      Blue
splitAndSetbackPerimeter native ✓ cpp-fast ✓ 已验证 18 条 · silver 官方文档 ↗ #
周向切分并整体退让的组合细分
签名(4 种重载)
splitAndSetbackPerimeter(splitOffset) { Length : depth : operations | ... } { remainder : operations }
splitAndSetbackPerimeter(splitOffset) { Length : depth : operations | ... }* { remainder : operations }
splitAndSetbackPerimeter(splitOffset, firstEdgeIndex, selectedEdgesMask) { Length : depth : operations | ... } { remainder : operations }
splitAndSetbackPerimeter(splitOffset, firstEdgeIndex, selectedEdgesMask) { Length : depth : operations | ... }* { remainder : operations }
参数说明
参数类型说明
splitOffsetfloatThe offset of the start of the split pattern. The relative operator ' permits values relative to the total length of all selected edges.
firstEdgeIndexfloatIndex of the edge where the split pattern starts (0-based). Too large or negative indices are modulo wrapped to a correct index. Default is 0.
selectedEdgesMaskbool[]An array containing a Boolean value for each face edge determining whether the edge is part of the operation. By default all edges are selected.
lengthfloat
depth—The setback distance of the edge section.
operations—A sequence of shape operations to execute on the newly created shape.
*—Repeat switch: the repeat switch triggers the repetition of the defined split as many times as possible. The number of repetitions and floating dimensions are adapted to the best solution (best number of repetitions and least stretching).
remainder—A sequence of shape operations to execute on the remainder of the polygon.
官方说明(英文原文)

The splitAndSetbackPerimeter operation combines concepts from the split and setback operations: First the perimeter of a polygon is split into sections according to the specified lengths. Then each section is setback by its respective depth. Finally, a new shape is generated for each section and for the remainder of the polygon.

By default, the split pattern is evaluated along the entire perimeter of the polygon, starting on the first edge and going counterclockwise around the polygon. The start of the split pattern can be moved using a splitOffset. To use the operation independent on the underlying geometry index order, the firstEdgeIndex and selectedEdgesMask can be set, typically with functions evaluating the spatial context (see examples below). Technically, the operation can be restricted to a part of the perimeter by setting the firstEdgeIndex and passing a selectedEdgesMask. In this case, the selected edges are arranged in a chain on which the split is done. The array must be in face-edge order, i.e. the first element refers to the first edge of the first face, the second element to the second edge of the first face, and so on. Shared edges are considered separately for each face. If the array does not contain enough elements the respective missing face edges are considered not to be selected. If the array contains more elements than the number of total face edges the respective elements are ignored. Such an array could be constructed using the comp function with the component selector set to fe (face edges).

Geometry tags

The operation automatically applies semantic component tags to the resulting edge components. Refer to the setback operation for more details.

官方示例(共 6 个,展示前 3 个) · 点击展开
Lot --> splitAndSetbackPerimeter(6) 
    { 40 : 5 : Yellow |
      20 : 10 : Blue  } 
    { remainder : Grey }

Yellow --> color("#F2BB1D")
Blue   --> color("#3957A5")
Grey   --> color("#CAC9C6")
Lot --> splitAndSetbackPerimeter('0.1) 
    { '0.5  : 10 : extrude(15) Yellow |
      ~1    : 0  : NIL                |
      '0.4  : 8  : extrude(10) Blue   |
      ~1    : 0  : NIL                } 
    { remainder : Grey }
const INF = 100000

// (8)[0.0,16.5,INF,INF,INF,INF,INF,-15.0]
frontXCoords = comp(fe) { front : pivot.px | all : INF }

// 7
frontLeftMostEdgeIndex = sortIndices(frontXCoords)[0]

// (8)[true,true,false,false,false,false,false,true]
frontEdgesMask = comp(fe) { front : true }

Lot --> splitAndSetbackPerimeter(0,
            frontLeftMostEdgeIndex, frontEdgesMask)
    { ~1   : 0  : NIL                |
     '0.7  : 10 : extrude(12) Yellow | 
      ~1   : 0  : NIL                } 
    { remainder : Grey }
我方已验证示例:learning case #146(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/**
 * splitAndSetbackPerimeter - Context-based Edge Selection Example
 * 使用基于上下文的函数来选择边
 * 
 * 使用 firstEdgeIndex 和 selectedEdgesMask 参数对以周长前边为中心的部分进行退缩。
 * 在本例中,comp 和 sortIndices 函数以及枢轴属性用于查找最左侧的前边的索引并构造边选择掩膜。
 */

const INF = 100000

// Simplified: hardcoded values for a 10x10 rect (4 edges)
frontLeftMostEdgeIndex = 0
frontEdgesMask = [true, true, false, false]

@StartRule
Lot --> splitAndSetbackPerimeter(0,
            frontLeftMostEdgeIndex, frontEdgesMask)
    { ~1   : 0  : NIL            …
comp native ✓ cpp-fast ✓ 已验证 456 条 · gold 官方文档 ↗ #
组件提取:把面 / 边 / 顶点拆成独立形状分别处理
签名(2 种重载)
comp(component) { selector operator operations | ... }
comp(component, scopeAlignment) { selector operator operations | ... }
参数说明
参数类型说明
componentselector
scopeAlignmentselector
operator—
operations—A sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The comp operation (component split) allows to divide a shape into its topological components, which are either faces, edges, vertices, groups, materials, or holes. The components can be selected using either their index or a set of selectors. Group and material components satisfy a specific selection keyword if at least one geometric component (usually a face) satisfies it. The selected components are transformed to a new shape and processed by a sequence of shape operations. Depending on the operator, either one shape is created for each individual selected component ( : ), one shape is created for the whole set of selected components ( = ) or one shape is created for each connected subset of selected components ( =: ). Two components are connected if their faces share an edge. Components without faces are connected if they share a vertex.

The selection parameters of a component split work in a excluding manner: if a parameter has selected a specific component, this component cannot be part of another selection (from left to right).

The local coordinate systems (pivot and scope) of the newly generated shapes are aligned according to the geometry's topology; the component split is one of the few shape operations which manipulate the pivot of a shape. This behavior is deactivated when scopeAlignment is set to noAlign.

  • f

    In the case of a face component split, the x-axis will be parallel to the first edge of the face and the z-axis wil point along the face's normal. The pivot will be positioned at the first vertex of the first edge of the face; the scope will be the bounding box of the face, i.e.the z-dimension of the emerging shape's scope is set to zero. See an example.

  • e

    In the case of an edge component split, the x-axes of the pivot an the scope are along the edge and the z-axes point along the average of the normals of the neighboring faces. The y- and z-dimension of the scope are set to zero and the x-dimension is the length of the edge. The pivot will be positioned at one of the endpoints of the edge. The indexing of edges is as follows: index 0 is the first edge of the first face, index 1 the second edge of the first face etc. Shared edges are skipped on second encounter. See an example.

  • fe

    In contrast to edges, face edges are considered separately for each face. Indexing is done firstly per face and secondly per edge, but shared edges are not skipped. Furthermore, contrary to edges, face edges have a unique direction determined by the orientation of the face they belong to. The x-axes of the pivot and the scope are directed in face orientation and the z-axes point out of the face orthogonally to the edge and the face normal. The pivot is positioned at the first vertex of the face edge. See an example.

  • v

    In case of a vertex component split, the pivot is positioned at the vertex, the z-axes will point along the average of the normals of the neighboring faces and all scope dimensions are set to zero. See an example.

  • fv

    In contrast to vertices, face vertices are considered separately for each face. Indexing is done firstly per face and secondly per vertex. The x-axes of the pivot and the scope are directed in face orientation (i.e., tangential) and the z-axes point out of the face orthogonally to the tangent and the face normal. The y-axes are along the face normal. The pivot is positioned at the vertex. If applied on an edge component the tangent/x-axis point along the edge direction. See an example.

Comp shape attributes

Each generated shape has a number of comp shape attributes set, see comp attribute.

Trim planes

Additionally, for faces, the component split generates trim planes. Trim planes are placed along the shared edges of the new faces in a bisecting angle. The purpose of trim planes is twofold. On one side, trimming handles geometry intersections on the boundary of two neighboring faces, and on the other side, trimming is used to handle non-rectangular faces. The trim planes are applied using the insert operation, primitive operations, or the trim operation.

According to the direction of the shared edge, trim planes are classified into horizontal and vertical planes. They can be switched on or off by setting the trim attribute to true or false. By default, trimming is activated for vertical trim planes and deactivated for horizontal trim planes. Check the trim planes examples below.

Note:

Trim planes are only generated if the : operator is used.

Trim planes can be configured in the procedural runtime preferences.

Occluder shape

An occluder shape is automatically generated before the component split is applied. The occluder shape is made available for unlabeled occlusion queries.

Roof edges

There is a number of selectors which are designed to classify typical roof edges:

  • eave—Horizontal border edges on the bottom of the roof. The edges are always oriented anti-clockwise around the original face.
  • hip—Inside edges connected to at least one eave edge. Hip edges are always oriented upwards, i.e. the ending point has larger y-coordinate than the starting point.
  • valley—Inside edges where the two connected faces form a concavity. Valley edges are always oriented upwards, i.e. the ending point has larger y-coordinate than the starting point.
  • ridge—Inside edges which are not hip or valley. Ridge edges are always oriented upwards, i.e. the ending point has larger y-coordinate than the starting point.

These selectors can only be applied on the edge component splits.

The figure below shows examples.

Street selectors

Components adjacent to a street can be selected with the street.front selector, rear components can be selected with the street.back selector, and components in between front and back can be selected with the street.left and street.right selectors. street.side combines left and right components. Below are examples of the street.xxx selectors.

These selectors depend on the availability of the streetWidth attribute map; see Auto-generated street width attributes. If the attribute is not available, component selection falls back to theobject.xxx selectors.

官方示例(共 31 个,展示前 3 个) · 点击展开
Lot -->
   extrude(5)
   color(1,1,1,0.75)
Lot -->
   extrude(5)
   comp(f) { right : color(1,1,0,0.75) Right. | 
             side  : color(1,1,1,0.75) Side.  }
Lot -->
   extrude(5)
   comp(f,noAlign) { right : color(1,1,0,0.75) Right. | 
                     side  : color(1,1,1,0.75) Side.  }
我方已验证示例:基础挤出 + 颜色(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@Range(min=0, max=20, step=0.5)
attr height = 10
attr roofColor = "#333333"
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(height)
color(1,0.5,0.2)
comp(f){side:Facade|top:Roof}
Facade --> split(y) { ~1 : Floor }*
Floor --> color(0.7,0.75,0.8)
Roof --> roofHip(30) color(roofColor)
innerRect native ✓ cpp-fast ✓ 已实现未验证 官方文档 ↗ #
取当前形状的内接矩形
签名(1 种重载)
innerRectangle( alignment) { selector operator operations | ... }
参数说明
参数类型说明
operator—
operations—A sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The innerRectangle operation finds for each face of the current shape's geometry the largest rectangle which is fully inside the face.

Note:

The face must not have self-intersections.

官方示例(共 5 个,展示前 3 个) · 点击展开
Lot-->	
   innerRectangle(scope) {shape     : Color | 
                          remainder : Color}
Color-->
   color(rand(1),rand(1),rand(1))
Lot-->
   innerRectangle(edge) {shape     : Color | 
                         remainder = Color}
Lot-->
   innerRectangle(scope) { shape     : Extrude | 
                           remainder : Color }
Extrude-->
   extrude(5)
Color-->
   color(0,1,0)
setback native ✓ cpp-fast ✓ 已验证 70 条 · gold 官方文档 ↗ #
按距离整体退让轮廓
签名(4 种重载)
setback(distance) { selector operator operations | ... }
setback(distance, uvSet) { selector operator operations | ... }
setback(distances) { selector operator operations | ... }
setback(distances, uvSet) { selector operator operations | ... }
参数说明
参数类型说明
distancefloatThe setback distance.
distancesfloat[]An array containing setback distances separately for each face edge.
uvSetfloatThe uv set to use for uv-based selectors. Default is 0.
operator—
operations—A sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The setback operation selects a number of edges and sets them back by a given distance. This is similar to the polygon offset operation, with the difference that only a subset of the edges are setback.

A common setback distance can be specified for all edges. Alternatively, a separate distance for each face edge can be specified by passing an array of setback distances instead of a single setback distance to the operation. The array must be in face-edge order, i.e. the first element is the distance of the first edge of the first face, the second element is the distance of the second edge of the first face, and so on. Shared edges are considered separately for each face. If the array does not contain enough elements no setback is performed on the respective missing face edges. If the array contains more elements than the number of total face edges the respective setback distances are ignored. Such an array could be constructed using the comp function with the component set to fe (face edges). The setbackPerEdge operation provides a more convenient way to set individual setback distances without having to construct an array manually.

Component tags

All setback operations automatically apply semantic component tags to the resulting edge components:

Shape

"setback.front"

"setback.back"

"setback.side"

Blue: original selected edges.

Green: new setback edges.

Yellow: side edges.

setback(4) { front : Shape }

Remainder

"setback.back"

"setback.side"

"setback.remainder"

Green: new setback edges.

Yellow: side edges.

Purple: original edges.

setback(4) { front : NIL 
           | remainder : Remainder }

For more information on working with component tags, refer to:

官方示例(共 4 个,展示前 3 个) · 点击展开
LotInner --> Lot

Lot-->
   setback(5) { street.front = Garten   |
                remainder    : Building }
    	
Garten --> color("#00ff00")

Building -->
   offset(-3, inside)
   extrude(world.up, rand(5, 15))
// (9)[1,6,1,6,1,6,1,6,1]
const dists = comp(fe) { all : 
                         case comp.index%2 == 
                              0 : 1
                         else   : 6 }

Lot --> setback(dists) { all       = Garden   |
                         remainder : Building }
// (9)[4,0,2,0.5,5,0.5,2,2,0]
const dists = comp(fe) { inside = 0   |
                         front  :
                           case comp.index == 
                                0 : 4
                           else   : 5 |
                         back   = 2   |
                         side   = 0.5 }

Lot --> setback(dists) { all       = Garden   |
                         remainder : Building }
我方已验证示例:setback 内院(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
setback(2) { streetSide : Garden | remainder : Building }
Building --> extrude(9) color(0.7,0.7,0.75)
Garden --> color(0.2,0.7,0.3)
setbackPerEdge native ✓ cpp-fast ✓ 已验证 2 条 · screened 官方文档 ↗ #
按每条边分别设置退让距离
签名(2 种重载)
setbackPerEdge(distance ) { selector operator operations | ... }
setbackPerEdge(distance, uvSet) { selector operator operations | ... }
参数说明
参数类型说明
distancefloatAn expression that specifies the setback distance. It is evaluated per face edge.
uvSet, selector, operator, operations—All other parameters are the same as for the setback operation.
官方说明(英文原文)

The setbackPerEdge operation is similar to the setback operation. The only difference is that the setback distance is evaluated several times and individually for each face edge. Shared edges are considered separately for each face. Therefore, a different distance can be set for each edge.

At the time distance is evaluated the current shape equals to one of the respective face edge components. More precisely, the current geometry, pivot and scope equals to the face edge component of the comp operation (with the compSelector set to fe). Furthermore, comp attributes can be accessed.

Note:

setbackPerEdge(distance) { selector operator operations | ... }

is a shortcut for

setback(comp(fe) { all : distance } ) { selector operator operations | ... }

This means internally an array is constructed by the comp function and passed to the setback operation.

官方示例(共 7 个,展示前 3 个) · 点击展开
Lot1 --> setback(rand(5))
          { front = Red | back = Blue | left = Green }

Lot2 --> setbackPerEdge(rand(5))
          { front = Red | back = Blue | left = Green }
const dists = [3,2,1,0,0,1,2,3]

dist = dists[comp.index]

Lot --> setbackPerEdge(dist) { all = Green }
Lot --> setback(comp(fe){all:dist}) { all = Green }
Lot --> setback(dists)              { all = Green }
setbackToArea native ✓ cpp-fast ✓ 已验证 3 条 · silver 官方文档 ↗ #
退让轮廓直至满足目标面积
签名(6 种重载)
setbackToArea(area) { selector operator operations | ... }
setbackToArea(area, uvSet) { selector operator operations | ... }
setbackToArea(area, minDistances) { selector operator operations | ... }
setbackToArea(area, minDistances, uvSet) { selector operator operations | ... }
setbackToArea(area, minDistances, maxDistances) { selector operator operations | ... }
setbackToArea( area, minDistances, maxDistances, uvSet) { selector operator operations | ... }
参数说明
参数类型说明
areafloatThe desired area of the setback remainder. Must be >0.
minDistances, maxDistancesfloat[]An array containing setback distances separately for each face edge. The applied setback will be in this range.
uvSet, selector, operator, operations—All other parameters are the same as for the setback operation.
官方说明(英文原文)

The setbackToArea operation is similar to the setback operation. The difference is that setback distances are automatically chosen such that the remainder fulfills a given area.

If no minDistances are given the setback distances are chosen to be equal for each edge. If minDistances are specified then these distances are increased by a common offset such that area is satisfied. Optionally, maxDistances define maximum values for the applied distances.

The desired area cannot be achieved when the minimum distances are too large, the maximum distances are too small or the area of the current shape is smaller than the specified area.

Note:

The remainder depends on the setbacks of selected edges. If you are only interested in the remainder shape you still have to provide a setback selector:

setbackToArea(area) { all = NIL | remainder = X. }

Geometry tags

The operation automatically applies semantic component tags to the resulting edge components. Refer to the setback operation for more details.

官方示例(共 4 个,展示前 3 个) · 点击展开
Left --> setbackToArea(100) { all      = NIL   |
                             remainder = Green }

Right --> setbackToArea(geometry.area - 300)
                            { all      = Green }
attr area = 100

Lot --> setbackToArea(area) { front     = Blue  |
                              left      = Red   |
                              remainder = Green }
Lot --> setbackToArea(100) { all       = Blue  |
                             remainder = Green }
我方已验证示例:learning case #183(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* setbackToArea operation example */
Lot -->
  primitiveCube()
  setbackToArea(10)
  color("#0000ff")
shapeL native ✓ cpp-fast ✓ 已验证 33 条 · gold 官方文档 ↗ #
生成 L 形 footprint 组合体
签名(1 种重载)
shapeL(frontWidth, leftWidth) { selector operator operations | ... }
参数说明
参数类型说明
frontWidthfloatWidth of corresponding wing.
operatorfloat
operationsfloatA sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The shapeL, shapeU, shapeO operations select a number of edges, depending on predefined spatial selectors, and set them back by a user-defined distance.

Note:

These operations are another way of applying setbacks. For example

shapeL(frontWidth, leftWidth) { selector operator operations | ... }

can also be achieved with the setback operation and the comp function:

setback( comp(fe) { front=frontWidth | left=leftWidth } ) { selector operator operations | ... }

Component tags

The operations automatically apply semantic component tags to the resulting edge components.

"setback.front"

"setback.back"

"setback.side"

"setback.remainder"

Blue: original edges in shape

Green: new setback edges.

Yellow: side edges.

Purple: original edges in remainder.

Left   --> shapeL(4,4) { shape    : Shape
                       | remainder: Remainder }

Middle --> shapeU(4,4,4) { ... }
Right  --> shapeO(4,4,4,4) { ... }

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

官方示例 · 点击展开
attr myFrontDepth = 5
attr myLeftWidth = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3,inside)
   shapeL(myFrontDepth,myLeftWidth) { shape : Footprint | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myLeftWidth  = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3, inside)
   shapeU(myFrontDepth,myRightWidth,myLeftWidth) { shape     : Footprint 
                                                 | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myBackDepth  = 2
attr myLeftWidth  = 11

LotInner -->
   Lot
        
Lot -->
   offset( -3, inside)
   shapeO( myFrontDepth, myRightWidth, myBackDepth, myLeftWidth ) 
         { shape : Footprint | remainder : NIL }

Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
我方已验证示例:shapeL(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(16, 16)
shapeL(10, 10){ shape : Shape | remainder : Remainder }
Shape --> extrude(8) color(0.9, 0.6, 0.2)
Remainder --> color(0.2, 0.7, 0.3)
shapeU native ✓ cpp-fast ✓ 已验证 17 条 · gold 官方文档 ↗ #
生成 U 形 footprint 组合体
签名(1 种重载)
shapeU(frontWidth, rightWidth, leftWidth) { selector operator operations | ... }
参数说明
参数类型说明
frontWidthfloatWidth of corresponding wing.
operatorfloat
operationsfloatA sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The shapeL, shapeU, shapeO operations select a number of edges, depending on predefined spatial selectors, and set them back by a user-defined distance.

Note:

These operations are another way of applying setbacks. For example

shapeL(frontWidth, leftWidth) { selector operator operations | ... }

can also be achieved with the setback operation and the comp function:

setback( comp(fe) { front=frontWidth | left=leftWidth } ) { selector operator operations | ... }

Component tags

The operations automatically apply semantic component tags to the resulting edge components.

"setback.front"

"setback.back"

"setback.side"

"setback.remainder"

Blue: original edges in shape

Green: new setback edges.

Yellow: side edges.

Purple: original edges in remainder.

Left   --> shapeL(4,4) { shape    : Shape
                       | remainder: Remainder }

Middle --> shapeU(4,4,4) { ... }
Right  --> shapeO(4,4,4,4) { ... }

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

官方示例 · 点击展开
attr myFrontDepth = 5
attr myLeftWidth = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3,inside)
   shapeL(myFrontDepth,myLeftWidth) { shape : Footprint | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myLeftWidth  = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3, inside)
   shapeU(myFrontDepth,myRightWidth,myLeftWidth) { shape     : Footprint 
                                                 | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myBackDepth  = 2
attr myLeftWidth  = 11

LotInner -->
   Lot
        
Lot -->
   offset( -3, inside)
   shapeO( myFrontDepth, myRightWidth, myBackDepth, myLeftWidth ) 
         { shape : Footprint | remainder : NIL }

Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
我方已验证示例:shapeU(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(16, 16)
shapeU(5, 5, 5){ shape : Shape | remainder : Remainder }
Shape --> extrude(8) color(0.9, 0.6, 0.2)
Remainder --> color(0.2, 0.7, 0.3)
shapeO native ✓ cpp-fast ✓ 已验证 24 条 · gold 官方文档 ↗ #
生成 O 形(回字形)footprint 组合体
签名(1 种重载)
shapeO(frontWidth, rightWidth, backWidth, leftWidth ) { selector operator operations | ... }
参数说明
参数类型说明
frontWidthfloatWidth of corresponding wing.
operatorfloat
operationsfloatA sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The shapeL, shapeU, shapeO operations select a number of edges, depending on predefined spatial selectors, and set them back by a user-defined distance.

Note:

These operations are another way of applying setbacks. For example

shapeL(frontWidth, leftWidth) { selector operator operations | ... }

can also be achieved with the setback operation and the comp function:

setback( comp(fe) { front=frontWidth | left=leftWidth } ) { selector operator operations | ... }

Component tags

The operations automatically apply semantic component tags to the resulting edge components.

"setback.front"

"setback.back"

"setback.side"

"setback.remainder"

Blue: original edges in shape

Green: new setback edges.

Yellow: side edges.

Purple: original edges in remainder.

Left   --> shapeL(4,4) { shape    : Shape
                       | remainder: Remainder }

Middle --> shapeU(4,4,4) { ... }
Right  --> shapeO(4,4,4,4) { ... }

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

官方示例 · 点击展开
attr myFrontDepth = 5
attr myLeftWidth = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3,inside)
   shapeL(myFrontDepth,myLeftWidth) { shape : Footprint | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myLeftWidth  = 11

LotInner -->
   Lot
		
Lot -->
   offset(-3, inside)
   shapeU(myFrontDepth,myRightWidth,myLeftWidth) { shape     : Footprint 
                                                 | remainder : NIL }
	
Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
attr myFrontDepth = 5
attr myRightWidth = 3
attr myBackDepth  = 2
attr myLeftWidth  = 11

LotInner -->
   Lot
        
Lot -->
   offset( -3, inside)
   shapeO( myFrontDepth, myRightWidth, myBackDepth, myLeftWidth ) 
         { shape : Footprint | remainder : NIL }

Footprint -->
   extrude(rand(10,20)) 
   color(1,0,0)
我方已验证示例:shapeO(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(16, 16)
shapeO(2, 2, 2, 2){ shape : Shape | remainder : Remainder }
Shape --> extrude(8) color(0.9, 0.6, 0.2)
Remainder --> color(0.2, 0.7, 0.3)
scatter native ✓ cpp-fast ✓ 已验证 29 条 · silver 官方文档 ↗ #
在表面上随机散布点 / 形状
签名(2 种重载)
scatter(domain, nPoints, distributionType) { operations }
scatter(domain, nPoints, gaussian, scatterMean, scatterStddev) { operations }
参数说明
参数类型说明
domainselector{ surface | volume | scope }—Where to distribute the points. Note that volume only works if applied to a closed surface geometry; i.e. the mesh is not closed, the operation falls back to surface.
nPointsfloatThe number of points to distribute.
distributionTypeselector{ uniform | gaussian }—The random distribution type.
scatterMeanselector{ center | front | back | left | right | top | bottom }— The position in the scope to use as the mean for the gaussian normal distribution. Default value is center.
scatterStddevfloatThe standard deviation for the gaussian normal distribution. Note that this parameter can also be given in relative coordinates (leading to axis-specific standard deviations according to the dimensions of the scope). Default value is 0.16.
operations—A sequence of shape operations to execute on the newly created shape.
官方说明(英文原文)

The scatter operation places point shapes in or on the geometry of the current shape. The parameter nPoints determines how many point shapes are created. The first parameter domain chooses where to distribute the points. Two different random distributions can be used (uniform or gaussian; the optional parameter mean describes the center position of the point cluster relative to the current shape. It currently can be either center (default), front, back, left, right, top, or bottom. The optional parameter deviation describes the standard deviation.

Note that this parameter can also be given in relative coordinates (leading to axis-specific standard deviations according to the dimensions of the scope). Per default the value of deviation is set to '0.16.

The scatter operation does not affect the rotation of the children shapes except if the domain is set to surface. Then the children's scopes are oriented such that the y-direction corresponds to the surface normal.

Note:
  • The children shape's scope sizes are set to 0.
  • The children shape's geometry only contains one vertex, you probably want to insert a geometry using the i operation.
官方示例 · 点击展开
Init-->
   scatter(surface, 100, uniform) { Leaf }
   
Leaf-->
   primitiveCube()
   s(0.2,0.3,0.1)
   color("#ff0000")
Init-->
   scatter(surface, 100, gaussian) { Leaf }
   
Leaf-->
   primitiveCube()
   s(0.2,0.3,0.1)
   color("#ff0000")
Init-->
   scatter(surface, 100, gaussian, left, '0.1) { Leaf }
   
Leaf-->
   primitiveCube()
   s(0.2,0.3,0.1)
   color("#ff0000")
我方已验证示例:learning case #177(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* scatter operation example */
Lot -->
  primitiveCube()
  scatter("surface", 5, "uniform")
  color("#8888ff")