> **本文回答**：取当前屏幕"看得见的图纸范围" `Engine.getScreenBoundsWcs(expandFactor?)`，返回 WCS `BoundingBox`；取屏幕内实体 `Engine.getScreenEntities(expandFactor?)`。`expandFactor` 默认 1.0，>1 会包含部分超出屏幕的实体（适合"预读"场景）。

## 一、最小用法

```js
const bb = Engine.getScreenBoundsWcs();
console.log('WCS:', bb.minX, bb.minY, bb.maxX, bb.maxY);
console.log('size:', bb.width, bb.height);

const ents = Engine.getScreenEntities();
console.log('屏幕内实体数:', ents.length);
```

MCP 参考：`vjcad/example/view/07screenbounds.js`、`vjcad/doc/view/index.md`。

## 二、`expandFactor`

```js
const ents1   = Engine.getScreenEntities(1.0);   // 默认（精确屏幕内）
const ents15  = Engine.getScreenEntities(1.5);   // 1.5 倍（含部分超出）
const ents2   = Engine.getScreenEntities(2.0);   // 2 倍
```

实战：

| 场景 | expandFactor |
|---|---|
| 视口外不需要查询 | 1.0 |
| 想为下一帧预先做准备 | 1.5 ~ 2.0 |
| 大批量背景计算（不抖动） | 2.0 ~ 3.0 |

MCP 参考：`vjcad/example/view/07screenbounds.js`。

## 三、按颜色 / 类型 / 图层分桶

```js
const ents = Engine.getScreenEntities();
const colorCounts = {};
ents.forEach(e => {
  const c = e.color || 7;
  colorCounts[c] = (colorCounts[c] || 0) + 1;
});

const layerEnts = ents.filter(e => e.layer === '墙体');
```

MCP 参考：`vjcad/example/view/07screenbounds.js`。

## 四、配合 `SpatialIndex`

如果还要做"在屏幕外，但即将进入"的范围查询，用 `SpatialIndex.search(bounds)` + 自己 `expand` bbox。详见 [geometry/spatial-index](../geometry/spatial-index.md)。

## 反例

- 想取**当前选中实体的范围**：直接 `Engine.getBoundsByEntities(Engine.ssGetFirst())`（返回 `BoundingBox`），不要先 `getScreenEntities` 再 filter（会漏掉 viewport 外但被选中的）。`e.boundingBox()` 返回的就是 `BoundingBox` 实例（含 `pt1/pt2/minX/maxX/minY/maxY` + `minPoint/maxPoint` 访问器），可直接喂给 `mergeBoundingBoxes`；只有 `GLine` 等几何计算内部的同名方法才返回 `{minX,minY,maxX,maxY}` 普通对象。
- `expandFactor` 设很大但不限制业务量：会拿到全图，性能没意义。

## 参考（官方文档 MCP）

- 文档：`vjcad/doc/view/index.md`
- 示例：`vjcad/example/view/07screenbounds.js`
