Home > IPCB_PrimitiveObject > getState_BinaryData
IPCB_PrimitiveObject.getState_BinaryData() method
Get the property state: binary data
Signature
typescript
function getState_BinaryData(): string;1
Returns
string
Binary data
Remarks
The binaryData retrieved from the canvas may be a hashId, because our backend stores binary embedded object data in object storage,
The object storage uses hashId as the index. Fully retrieving the data will cause additional requests and consume performance
Example
javascript
// 1. 生成本次运行专用的坐标,在顶层丝印层放置一个 400 x 300 的内嵌图片
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 4x4 纯色 PNG 的 data URI(binaryData 必须是 data URI 格式,裸 base64 会创建失败)
const imageData = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAEElEQVR4nGP4z8AARwzEcQCukw/x0F8jngAAAABJRU5ErkJggg==';
const obj = await eda.pcb_PrimitiveObject.create(3, x, y, imageData, 400, 300, 0, false, 'demo.png', false);
// 2. 读取内嵌的二进制数据
const binaryData = obj.getState_BinaryData();
// 3. 清理测试图元(查询类案例不留测试对象)
await eda.pcb_PrimitiveObject.delete([obj.getState_PrimitiveId()]);
console.log('binaryData 长度:', binaryData.length);
console.log('binaryData 前缀:', binaryData.substring(0, 30));1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15