流程控制 Flow Control · 3 个函数
形状栈操作与空后继
从形状栈恢复形状
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| operations | — | A sequence of shape operations to execute. |
官方说明(英文原文)
The [ operation pushes the current shape onto the top of the shape stack. It must be matched by a succeeding ] operation, which pops the shape on top of the shape stack and deletes the shape.
官方示例(共 5 个,展示前 3 个) · 点击展开
Lot-->
extrude(15)
r(scopeCenter, 0, 22.5, 0) X
r(scopeCenter, 0, 22.5, 0) X
r(scopeCenter, 0, 22.5, 0) XLot-->
extrude(15)
[ r(scopeCenter, 0, 22.5, 0) X ]
[ r(scopeCenter, 0, 22.5, 0) X ]
[ r(scopeCenter, 0, 22.5, 0) X ]House -->
extrude(10)
comp(f) { top : roofHip(45) Roof. | all = House.}
House -->
[ t(0,10,0) roofHip(45) Roof. ]
extrude(10)
comp(f) { top : NIL | all = House. }我方已验证示例:learning case #111(verified_silver)· 点击展开代码 · 在 demo 中运行 →
@Description("CityEngine CGA 内置字符串与数组函数示例 - splitString / substring / find / replace / sort 等")
@Group("内置函数-字符串与数组")
@Order(37)
// ============================================================
// 内置函数 - 字符串与数组操作
// 演示 splitString, substring, strreplace, replace, toupper, tolower,
// find, findFirst, findAll, findLast, getPrefix, getSuffix, getRange,
// trim, startsWith, endsWith, includes, format,
// size, nRows, nColumns, transpose, setElems, sortIndices, sortRowIndices,
// …
把当前形状压入形状栈
参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| operations | — | A sequence of shape operations to execute. |
官方说明(英文原文)
The [ operation pushes the current shape onto the top of the shape stack. It must be matched by a succeeding ] operation, which pops the shape on top of the shape stack and deletes the shape.
官方示例(共 5 个,展示前 3 个) · 点击展开
Lot-->
extrude(15)
r(scopeCenter, 0, 22.5, 0) X
r(scopeCenter, 0, 22.5, 0) X
r(scopeCenter, 0, 22.5, 0) XLot-->
extrude(15)
[ r(scopeCenter, 0, 22.5, 0) X ]
[ r(scopeCenter, 0, 22.5, 0) X ]
[ r(scopeCenter, 0, 22.5, 0) X ]House -->
extrude(10)
comp(f) { top : roofHip(45) Roof. | all = House.}
House -->
[ t(0,10,0) roofHip(45) Roof. ]
extrude(10)
comp(f) { top : NIL | all = House. }我方已验证示例:learning case #114(verified_silver)· 点击展开代码 · 在 demo 中运行 →
@Description("CityEngine CGA 流程控制函数示例 - case / else / stop / push / pop / NIL")
@Group("流程控制")
@Order(35)
// ============================================================
// 流程控制 Flow Control
// 演示 case, else, stop, push/pop, NIL, p
// ============================================================
@StartRule
Lot --> FlowControlDemo
FlowControlDemo -->
split(x) { ~6: CaseDemo
| ~6: ElseDemo
| ~6: StopDemo
| ~6: PushPopDemo
| ~6: NilDemo
…
终止当前形状,不产生后继
签名(1 种重载)
NIL
官方说明(英文原文)
The NIL operation deletes the current shape from the shape tree. It can be used, for example, to create holes in split operations or to terminate recursive rules.
官方示例 · 点击展开
Lot-->
extrude(10)
split(x){ { ~1 : X
| ~1 : NIL }*
| ~1 : X }attr ErkerFact = 0.8
attr ErkerDepth = 0.8
attr ErkerStop = 2
Lot-->
extrude(10)
X
comp(f) { all : Erker }
Erker-->
case(scope.sx > ErkerStop) :
s('ErkerFact, 'ErkerFact, 0)
center(xy)
alignScopeToGeometry(yUp, 0)
extrude(ErkerDepth)
X
comp(f){top : Erker}
else:
NIL