Home > PCB_Document > navigateToCoordinates
PCB_Document.navigateToCoordinates() method
定位到画布坐标
签名
typescript
function navigateToCoordinates(x: number, y: number): Promise<boolean>;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
x | number | 坐标 X |
y | number | 坐标 Y |
返回值
Promise<boolean>
操作是否成功
备注
本接口在前端画布上定位到指定的数据层面坐标;
如果希望在进行本操作时前端画布坐标能与传入数据一致, 建议调用 PCB_Document.setCanvasOrigin() 方法并设置偏移量为零;
此处的单位为数据层面单位,在跨度上等同于画布层面的 mil
示例
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