Plant coordinates in drawing units
64-bitThe position and size of each P&ID symbol and line placed in the drawing.
k = 1 ÷ perUnit(doc, 'mm'); x′ = x × k
The factor is 1 when the host gives no per-unit function. The reciprocal is formed once and then multiplied in, which can differ from a division in the last binary digit; nothing is rounded.
applyBuild: async (b) => {
const doc = needDoc(); ensureLayers(doc);
const k = 1 / (perUnit ? perUnit(doc, 'mm') : 1), made = { pidItems: 0, equipment: b.plant.equipment.length, runs: b.plant.runs.length };
doc.change('Assistant: plant', () => {
for (const it of b.pid.items) {
if (it.kind === 'pidsym') { const d = cleanSymbol({ ...it.data, l: it.data.l * k }); if (d) { doc.add({ ...api.objects.create('pidsym', d, { layer: layerOf('pidsym', d) }), x: it.e.x * k, y: it.e.y * k, rot: it.e.rot || 0 }); made.pidItems++; } }
else { const d = cleanLine({ ...it.data, pts: it.data.pts.map((p) => [p[0] * k, p[1] * k]), k: it.data.k * k, th: it.data.th * k }); if (d) { doc.add({ ...api.objects.create('pidline', d, { layer: layerOf('pidline', d) }), x: 0, y: 0 }); made.pidItems++; } }
}
});
return made;
},