Home > IPCB_PrimitivePad > setState_Layer
IPCB_PrimitivePad.setState_Layer() 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.
Set the property state: Layer
Signature
function setState_Layer(layer: TPCB_LayersOfPad): IPCB_PrimitivePad;Parameters
Parameter | Type | Description |
|---|---|---|
layer | Layer |
Returns
Pad primitive object
Remarks
When setting the layer, some other property states will be set in conjunction:
When switching between the top and bottom layers: the solder mask/paste mask expansion properties will switch accordingly, and the data values remain unchanged
When switching from multi-layer to single layer: it determines whether to switch to the top or bottom layer, and the solder mask/paste mask expansion properties will only keep the data corresponding to the specified layer. If a special pad exists, it will be converted to a normal pad property, and only the data corresponding to the specified layer will be kept. Hole-related properties will be reset to their default values
When switching from single layer to multi-layer: the solder mask/paste mask expansion properties will only keep the solder mask expansion, and the original data will be copied and applied to the top and bottom layers. The pad drilling property will be assigned a specified value: a rounded rectangle whose length and width are 60% of the pad diameter (for rounded or regular polygon pads) or the pad width (for rectangular pads). Data-wise it is a rounded rectangle, but actually it is a circle. If the pad is a polyline complex polygon, the data is calculated through a dedicated algorithm (usually abstract; it is recommended to modify it later)
Example
// 1. 生成本次运行专用的坐标,在顶层创建一个贴片焊盘
const x = 3000 + Math.floor(Math.random() * 100000);
const pad = await eda.pcb_PrimitivePad.create(1, '1', x, 3000, 0, ['ELLIPSE', 60, 60], '', null, 0, 0, 0, false, 0);
const before = pad.getState_Layer();
// 2. 异步模式下切换到底层并提交
const a = pad.toAsync();
a.setState_Layer(2);
await a.done();
// 3. 从画布重新读取,确认层已切换(保留现场供观察)
const ref = await eda.pcb_PrimitivePad.get(pad.getState_PrimitiveId());
console.log('layer:', before, '→', ref.getState_Layer());2
3
4
5
6
7
8
9
10
11
12
13
14