Peyep CGA 函数参考范围(Scope) · 2026.0
版本首页查看 demo →
← 返回 2026.0 分类导航

范围(Scope) Scope · 6 个函数

对齐 / 旋转 / 调整当前形状的 scope 坐标系

alignScopeToAxes native ✓ cpp-fast ✓ 已验证 150 条 · gold 官方文档 ↗ #
scope 对齐到世界 / 对象坐标轴
签名(2 种重载)
alignScopeToAxes()
alignScopeToAxes(alignAxes)
参数说明
参数类型说明
alignAxesselector
官方说明(英文原文)

The alignScopeToAxes operation manipulates the scope, the pivot and the geometry attributes such that the scope's axes are parallel to the corresponding axis/axes selected with alignAxes selector. If no alignAxes selector is specified, then world.xyz is used .After this operation, the scope.r and the scope.t vectors are zero and the geometry is projected to the new scope (i.e. stays at the same place in world coordinates).

If alignAxes selects a single axis, the second axis is created as follows:

  • { world.x | object.x }— The z axis is projected onto the world/object coordinates yz-plane.
  • { world.y | object.y }— The x axis is projected to the world/object coordinates xz-plane.
  • { world.z | object.z }— The x axis is then projected to the world coordinates xy-plane.

官方示例 · 点击展开
A-->
   t(5,0,4) s(8,24,8) r(10,20,30)
   i("boxnewsredlowress.obj")
A-->
   t(5,0,4) s(8,24,8) r(10,20,30)
   i("boxnewsredlowress.obj")
   alignScopeToAxes()
A-->
   t(5,0,4) s(8,24,8) r(10,20,30)
   i("boxnewsredlowress.obj")
   alignScopeToAxes(y)
我方已验证示例:alignScopeToAxes(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(4)
r(0, 30, 0)
alignScopeToAxes(world.y)
color(0.5, 1, 0.5)
alignScopeToGeometry native ✓ cpp-fast ✓ 已验证 203 条 · silver 官方文档 ↗ #
scope 对齐到几何
签名(4 种重载)
alignScopeToGeometry(upAxis, faceIndex, edgeIndex)
alignScopeToGeometry(upAxis, faceSelector, edgeIndex)
alignScopeToGeometry(upAxis, faceIndex, edgeSelector)
alignScopeToGeometry(upAxis, faceSelector, edgeSelector)
参数说明
参数类型说明
upAxisselector
faceIndexfloat0-based index of face which contains the edge. Negative indices are modulo-adjusted, i.e. -1 is the last face.
edgeIndexfloat0-based index of edge which will become the new x-axis. Negative indices are modulo-adjusted, i.e. -1 is the last edge. The edge index is relative to the selected face.
官方说明(英文原文)

The alignScopeToGeometry operation manipulates the scope, the pivot and the geometry attributes in the following way:

  1. Select new pivot axis directions that are defined by upAxis selector and the selected face and edge see below.
  2. Calculate the oriented bounding box (OOB) for the geometry along these axes and set pivot.p to the origin of the OOB. The new scope dimensions are set to the OOB.
  3. Transform the geometry into this new coordinate system.

The parameters let you choose an edge of a face in the geometry. The new x-axis of the scope will be parallel to this edge, and the up-axis will be the face's normal.

The geometry is projected to the new scope, i.e. stays at the same place in world coordinates.

官方示例(共 6 个,展示前 3 个) · 点击展开
A--> 
   comp(f) { 25 : Faces }
A--> 
   comp(f) { 25 : Faces }
   alignScopeToGeometry (zUp, any, world.lowest)
A-->
   s(2,3,2)
   i("cylinder.obj")
   B
   comp(f) { 0  : color("#ff0000") 
                  t(0,0,0.01) 
                  X 
           | 32 : color("#0000ff") 
                  t(0,0,0.01) 
                  X }
我方已验证示例:learning case #78(verified_silver)· 点击展开代码 · 示例过大,请复制源码到 demo 运行
/**
 * File:    Fence_On_Graph.cga
 * Created: 18 Nov 2015 17:11:40 GMT
 * Author:  Esri R&D Center Zurich
 */

/*

Input shape:  street shape (shape with UVs), street width >= base_depth

Fences are created along the u direction of the street shape.

Notes on Occlusion:

* Occlusion Labels:  The fence parts (post, middle, base post, base middle, upper post, upper middle)
  are each labeled with the given occlusionLabel.  These labeled parts are meant to be occluders which
  can be found when te…
alignScopeToGeometryBBox native ✓ cpp-fast ✓ 已验证 8 条 · silver 官方文档 ↗ #
scope 对齐到几何包围盒
签名(1 种重载)
alignScopeToGeometryBBox(alignAxes)
参数说明
参数类型说明
alignAxesselector
官方说明(英文原文)

The alignScopeToGeometryBBox operation manipulates the scope and the pivot in the following way:

  • The two scope axes given by alignAxes are aligned such that they span a minimum area bounding rectangle that encloses the footprint of the geometry as seen from the third scope axis. The third scope axis stays fixed. It acts as the rotation axis for the alignment.
  • The first scope axis given by alignAxes becomes the longer extent of the bounding rectangle. The longer extent is
    • the scope x axis for xy and xz,
    • the scope y axis for yx and yz and
    • the scope z axis for zx and zy.
  • The pivot is placed at the origin of the scope.

官方示例 · 点击展开
Lot --> Lot.
Lot --> alignScopeToGeometryBBox(xz)
我方已验证示例:learning case #251(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* alignScopeToGeometryBBox operation - aligns scope to minimum area bounding rectangle */
Lot -->
  extrude(10)
  r(0, 0, 20)
  alignScopeToGeometryBBox("xy")
  color("#ff8800")
rotateScope native ✓ cpp-fast ✓ 已验证 95 条 · gold 官方文档 ↗ #
旋转 scope
签名(1 种重载)
rotateScope(xAngle, yAngle, zAngle)
参数说明
参数类型说明
xAnglefloatAngle in degrees to rotate about the x-axis.
yAnglefloatAngle in degrees to rotate about the y-axis.
zAnglefloatAngle in degrees to rotate about the z-axis.
官方说明(英文原文)

The rotateScope operation rotates the scope of the current shape around the pivot-axes in xyz order. The geometry is not rotated, and the size and translation of the scope is adjusted such that the scope is the geometry's bounding box aligned to the scope axes.

我方已验证示例:rotateScope(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(4)
rotateScope(0, 30, 0)
color(1, 0.5, 0.5)
setPivot native ✓ cpp-fast ✓ 已验证 23 条 · silver 官方文档 ↗ #
设置枢轴(pivot)位置
签名(1 种重载)
setPivot(axisMap, cornerIndex)
参数说明
参数类型说明
axisMapselector
cornerIndexfloatInteger value in [0,7] to select one of the scope's corners to become the new pivot.p.
官方说明(英文原文)

The setPivot operation lets you re-position and re-orient the current shape's pivot. The new orientation will be based on the current shape's scope axes, the axisMap selector and the cornerIndex.

The new pivot.p will lie at a selected corner (cornerIndex) of the current shape's scope, and the pivot will be rotated such that all axes point inside the scope.

The new scope will have zero translation and rotation (relative to the pivot), and will stay at the same place (in world coordinates), but with different axes. The geometry is projected to the new scope (i.e. stays at the same place in world coordinates).

我方已验证示例:cityengine2025example-street-construction(verified_silver)· 点击展开代码 · 示例过大,请复制源码到 demo 运行
/**
 * Author:  Esri
 */

version "2024.0"


# ----------------------------------------
# Directory Paths
# ----------------------------------------

const assetsDirectory = "assets/3D_City_Design_Assets/"
const streetAssetsDirectory = assetsDirectory + "Street_Construction/"
const textureDirectory = streetAssetsDirectory + "textures/"


# ----------------------------------------
# Imported files
# ----------------------------------------

import Plant_Loader: "/ESRI.lib/rules/Plants/Plant_Loade…
mirrorScope native ✓ cpp-fast ✓ 已验证 9 条 · silver 官方文档 ↗ #
翻转 scope 方向
签名(1 种重载)
mirrorScope(xFlip, yFlip, zFlip)
参数说明
参数类型说明
xFlipboolA boolean value (true or false) for the scope x-axis; true means flip along the corresponding axis.
官方说明(英文原文)

The mirrorScope operation mirrors the scope of the current shape.

Note:

The current shape's geometry stays the same.

我方已验证示例:cityengine2025example-altstadthaus(verified_silver)· 点击展开代码 · 示例过大,请复制源码到 demo 运行
/**
 * Author:  Christian
 */

version "2019.1"

###########################################
#
#			ASSETS
#
###########################################

@Enum(grey=1, red=2, white=3)
@Description("1=grey, 2=red, 3=white")
attr design = 33% : 1  33% : 2 else : 3

###NEUE ASSETS###
const win1=
	"tiles/altstadthaus/win1.obj"

//	case design == 1 : "tiles/altstadthaus/win1.obj"
//	case design == 2 : "tiles/altstadthaus/win2.obj"
//	else : "tiles/altstadthaus/win3.obj"

const wintex = 
	case design =…