Plant: Cable Takeoff
cable_takeoffProduce a per-load cable takeoff from P&ID and layout drawings: kW, phases, panels, lengths and sections, exported as XLSX and CSV with open items flagged.
Instructions
A cable takeoff: one row per electrical load, the shop's cable method made repeatable.
Power, phases, voltage, neutral and VFD come from the P&ID's electrical
texts near each tag (Russian, Turkish and English spellings). Power is
never invented: a load with no stated kW keeps an empty cell and an open
item. The panel comes from the layout's wiring callouts ('Wiring to CP1'
and its variants, normalised to CP-1), else from the P&ID ('к CP1'); a load
neither places takes the nearest panel on the layout, flagged
panel_inferred (panel_rule='stated' leaves it open). The length is the
Manhattan distance on the layout from the load's tag to its panel's tag,
and the cable is ROUNDUP(length x (1 + allowance)) to the metre. Room and
panel totals count known power once: a load wired to a panel that states
its own power is part of that package, and the package's power is counted
instead of its children's - the rule is written on the method sheet.
Sections only from section_rules; no standard table is applied. Open
items: missing power, missing panel, a tag or panel not on the layout, no
layout at all, a load no section rule covers.
Read-only on both drawings. With output it writes one workbook - Metraj,
Özet, Kontrol, Metodoloji - as XLSX and, always, as CSV beside it.
Refused before a drawing is read: lang outside tr / en / ru, an allowance
outside 0-1 and a malformed section rule (named by its path,
section_rules[0].section: ...). A missing, unreadable or oversize drawing
is refused by the reader, which names MAX_DXF_BYTES. Without openpyxl the
XLSX is not written and files.refused carries capability: "xlsx_write"
naming the office extra; the CSV files are written all the same.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Headers and method text: tr | en | ru. | en |
| output | No | Workbook to write (.xlsx); the four sheets are also written as CSV beside it. Omit to return the rows only. | |
| pid_path | No | The P&ID carrying the electrical texts (kW, phases, voltage, VFD). Omit to read the current drawing. | |
| allowance | No | Allowance before rounding up to the metre (0.20 = 20 %). | |
| panel_rule | No | A load no wiring callout places: 'nearest' takes the nearest panel on the layout and flags the row panel_inferred; 'stated' leaves it open. | nearest |
| layout_path | No | The layout with the tags, the panels and the 'Wiring to CPn' callouts. Omitted, every length stays empty with an open item. | |
| section_rules | No | Your own section table: [{max_kw, section, phases (1|3, optional)}], e.g. [{'max_kw': 5.5, 'section': '5x2.5'}]. Omitted, no section is proposed. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||