CityEngine – Rule File error – Esri Community
我正在使用 CityEngine 版本 2024,并且在以下功能上出现意外的令牌错误:
Lot -->
// Apply setbacks using positional parameters (front, right, back, left)
setback(SETBACK_F, SETBACK_S, SETBACK_R, SETBACK_S)
{ remainder: Footprint | inside: NIL }
完整代码:
// ------------------------------------------------------------
// CityEngine CGA — Simple Massing from Attributes
// Corrected and Refactored for CityEngine 2024
// ------------------------------------------------------------
version "2024.0"
// ==== INPUT ATTRIBUTES (map to your columns) ====
attr PRJ_NAME = ""
attr BLDG_ID = ""
attr PARCEL_ID = ""
attr B_USE_CODE = ""
attr TFLR_H = 3.5 // Typical floor height (m)
attr RTL_FLR_HM = 5.0 // Retail floor height (m)
attr retailFloors = 1 // Number of retail floors (0 = none)
attr BLDG_HT_M = 0.0 // Used in ByHeight
attr FLR_COUNT = 0 // Used in ByFloors
attr GFA_TOTAL = 0.0 // Used in ByGFA
attr FAR = 0.0 // (Optional) Not used in this version
attr LGFLR_CNT = 0 // Basements count (extruded down)
// Setbacks (m)
attr SETBACK_F = 0.0
attr SETBACK_S = 0.0
attr SETBACK_R = 0.0
// Scenario selector: "ByHeight" | "ByFloors" | "ByGFA"
attr scenario = "ByHeight"
// =============================================================
// ==== START RULE ====
// =============================================================
@StartRule
Lot -->
// Apply setbacks using positional parameters (front, right, back, left)
setback(SETBACK_F, SETBACK_S, SETBACK_R, SETBACK_S)
{ remainder: Footprint | inside: NIL }
// =============================================================
// ==== MAIN LOGIC ====
// =============================================================
Footprint -->
case scenario == "ByFloors" && FLR_COUNT > 0:
BuildByFloors
case scenario == "ByGFA" && GFA_TOTAL > 0:
BuildByGFA
else: // "ByHeight" is the default
BuildByHeight
// -------------------------------------------------------------
// Scenario 1: Build using a specific floor count
// -------------------------------------------------------------
BuildByFloors -->
BasementsThenAbove(
min(retailFloors, FLR_COUNT) * RTL_FLR_HM, // podiumH
max(0, FLR_COUNT - min(retailFloors, FLR_COUNT)) * TFLR_H, // typicalH
max(0, FLR_COUNT - min(retailFloors, FLR_COUNT)) // typicalFloors
)
// -------------------------------------------------------------
// Scenario 2: Build by estimating floors from a target GFA
// -------------------------------------------------------------
BuildByGFA -->
case geometry.area > 0 && GFA_TOTAL > 0:
BasementsThenAbove(
min(retailFloors, max(1, ceil(GFA_TOTAL / geometry.area))) * RTL_FLR_HM,
max(0, max(1, ceil(GFA_TOTAL / geometry.area)) - min(retailFloors, max(1, ceil(GFA_TOTAL / geometry.area)))) * TFLR_H,
max(0, max(1, ceil(GFA_TOTAL / geometry.area)) - min(retailFloors, max(1, ceil(GFA_TOTAL / geometry.area))))
)
else:
NIL
// -------------------------------------------------------------
// Scenario 3: Build by deriving floor counts from a total height
// -------------------------------------------------------------
BuildByHeight -->
// If retail fits, build podium then typical; else all typical
case retailFloors > 0 && BLDG_HT_M >= RTL_FLR_HM:
BasementsThenAbove(
retailFloors * RTL_FLR_HM, // podiumH
floor(max(0, BLDG_HT_M - retailFloors * RTL_FLR_HM) / TFLR_H + 0.0001) * TFLR_H,
floor(max(0, BLDG_HT_M - retailFloors * RTL_FLR_HM) / TFLR_H + 0.0001)
)
else:
BasementsThenAbove(
0, // podiumH
floor(max(0, BLDG_HT_M) / TFLR_H + 0.0001) * TFLR_H,
floor(max(0, BLDG_HT_M) / TFLR_H + 0.0001)
)
// =============================================================
// ==== BUILDING GEOMETRY GENERATION ====
// =============================================================
BasementsThenAbove(podiumH, typicalH, typicalFloors) -->
case LGFLR_CNT > 0:
split(y){ -LGFLR_CNT * TFLR_H : Basement | ~1 : Above(podiumH, typicalH, typicalFloors) }
else:
Above(podiumH, typicalH, typicalFloors)
Basement -->
extrude(-LGFLR_CNT * TFLR_H)
color(0.3, 0.3, 0.3)
// This rule creates the above-ground building mass
Above(podiumH, typicalH, typicalFloors) -->
case podiumH > 0 && typicalH > 0:
split(y){ podiumH : Podium | typicalH : Tower(typicalFloors) }
case podiumH > 0: // Only a podium exists
Podium
case typicalH > 0: // Only a tower exists
Tower(typicalFloors)
else:
NIL
Podium -->
extrude(scope.sy)
color(1, 0.92, 0.75)
Tower(typicalFloors) -->
case typicalFloors > 0:
extrude(typicalFloors * TFLR_H)
color(0.8, 0.9, 1.0)
split(y){ TFLR_H : Typical }*
else:
NIL
// =============================================================
// ==== COMPONENT DEFINITIONS (Detailing) ====
// =============================================================
Typical -->
comp(f){ side: Facade | top: Roof | bottom: FloorPlate }
Facade --> color(0.85, 0.9, 1)
Roof --> color(0.7, 0.7, 0.7)
FloorPlate --> color(0.9, 0.9, 0.9)
回复:
挫折操作的语法与 CGA 规则中的语法不同。如果您需要每侧的单独挫折,请参阅挫折 CGA 参考底部的示例。
以下是基本片段:
@Range(min=1, max=25)
attr setback_front = 10
@Range(min=1, max=25)
attr setback_left = 3
@Range(min=1, max=25)
attr setback_right = 2
@Range(min=1, max=25)
attr setback_back = 5
const dists = comp(fe)
{ front : setback_front
| left: setback_left
| right: setback_right
| back: setback_back }
@StartRule
Lot --> setback(dists) { all = Garden. |
remainder : Building }
Building -->
extrude(15)
您对 setback 操作的调用需要遵循正确的语法: setback 操作 – ArcGIS CityEngine 资源 | 文档。
您可能正在寻找类似这样的内容?
setback(SETBACK_F){front: NIL | remainder:
setback(SETBACK_R){back: NIL | remainder:
setback(SETBACK_S){left: NIL | remainder:
setback(SETBACK_S){right: NIL | remainder:Footprint}}}}











没有回复内容