Home > PCB_Document > navigateToRegion
PCB_Document.navigateToRegion() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Locate to canvas region
Signature
function navigateToRegion(
left: number,
right: number,
top: number,
bottom: number,
): Promise<boolean>;2
3
4
5
6
Parameters
Parameter | Type | Description |
|---|---|---|
left | number | First X coordinate of the rectangle |
right | number | Second X coordinate of the rectangle |
top | number | First Y coordinate of the rectangle |
bottom | number | Second Y coordinate of the rectangle |
Returns
Promise<boolean>
Whether the operation is successful
Remarks
This API positions on the front-end canvas to the specified region. The region data is an offset relative to the data origin;
For example: the passed-in data is {left: 0, right: 60, top: 100, bottom: -20} => navigateToRegion(0, 60, 100, -20), then the canvas will be positioned to a rectangular range centered at [30, 40] with a length of 60 in the x-axis direction and 120 in the y-axis direction;
This API does not perform zooming, but it will generate a rectangle frame indicating the positioning center and the region range;
The units here are data-level units, which are equivalent to mil on the canvas level in span
Example
// 1. 创建测试 PCB 并打开(视口操作作用于当前激活的 PCB)
const pcbUuid = await eda.dmt_Pcb.createPcb();
await new Promise(r => setTimeout(r, 1500));
await eda.dmt_EditorControl.openDocument(pcbUuid);
await new Promise(r => setTimeout(r, 1000));
// 2. 定位到矩形区域:X 从 0 到 2000,Y 从 2000 到 0(视口将以中心 (1000,1000) 呈现)
const navigated = await eda.pcb_Document.navigateToRegion(0, 2000, 2000, 0);
console.log('navigated:', navigated);
// 3. 清理测试 PCB
await eda.dmt_Pcb.deletePcb(pcbUuid);2
3
4
5
6
7
8
9
10
11
12