Home > PCB_Document > navigateToCoordinates
PCB_Document.navigateToCoordinates() method
Locate to canvas coordinate
Signature
typescript
function navigateToCoordinates(x: number, y: number): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
Returns
Promise<boolean>
Whether the operation is successful
Remarks
This API positions on the front-end canvas to the specified data-level coordinate;
If you want the front-end canvas coordinate to be consistent with the passed-in data during this operation, it is recommended to call the PCB_Document.setCanvasOrigin() method and set the offset to zero;
The units here are data-level units, which are equivalent to mil on the canvas level in span
Example
javascript
// 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. 定位到数据坐标 (1000, 800)
const navigated = await eda.pcb_Document.navigateToCoordinates(1000, 800);
console.log('navigated:', navigated);
// 3. 清理测试 PCB
await eda.dmt_Pcb.deletePcb(pcbUuid);1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12