Plant: Pipe Takeoff
pipe_takeoffGenerate a pipe takeoff from P&ID and layout drawings: build run topology, measure lengths, group rows by room, service, and diameter, then export XLSX/CSV.
Instructions
A pipe takeoff: topology from the P&ID, lengths from the layout, rows by room x service x diameter.
The P&ID gives the runs (junctions merged, tees split, a line drawn twice
counted once, valves and reducers bridged), each run's service (the layer,
overridden by a supply / return word near the line), its diameters exactly
as labelled (direct, carried by continuity - never across a reducer - or
unassigned) and the equipment tags at its ends. The length comes from the
layout unless the scale check calls the P&ID to scale: the rectilinear
minimum spanning tree of the run's tag positions on the layout, each
connection along x first then y, plus vertical_allowance per connection.
The P&ID's drawn length stays beside it as schematic_m, never as the
answer. Lengths are metres from the unit the geometry implies; an INSUNITS
that disagrees is a warning, never a factor. Status A / B / C per run: a C
run (an end on no equipment, a tag missing from or written twice on the
layout) is on the Kontrol sheet with its schematic length, counted in the
total and flagged.
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 unknown
service or length source, an allowance outside 0-1, a negative vertical
allowance, a non-positive tolerance, and length_source='layout' without
a layout. A missing, unreadable or oversize drawing is refused by the
reader, which names MAX_DXF_BYTES. Refused after the scale check:
length_source='pid' on a P&ID it calls schematic, unless force=True
(the refusal quotes the statistics). 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 |
|---|---|---|---|
| tol | No | Line ends closer than this (P&ID drawing units) are one junction; default 1 mm in the unit the P&ID's geometry implies (1.0 on a millimetre drawing, 0.001 on a metre one). | |
| lang | No | Headers and method text: tr | en | ru. | en |
| force | No | With length_source='pid', measure on a P&ID the scale check calls schematic anyway. | |
| layers | No | P&ID layers holding the lines; default every layer the vocabulary files under piping or electrical with confidence >= 0.9. | |
| 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 (DXF headlessly; DXF or DWG on a live seat). Omit to read the current drawing as the P&ID. | |
| services | No | Services to take off; default product, cip_supply, cip_return. Also: glycol_supply, glycol_return, steam, condensate, cold_water, hot_water, ice_water, compressed_air, drain, electrical, unknown. | |
| allowance | No | Allowance as a share of the net length (0.20 = 20 %); its own column. | |
| layout_path | No | The layout of the same plant. Omitted, every length is the P&ID's drawn length and is marked scale_verified: false. | |
| length_source | No | auto | pid | layout. auto measures on the P&ID only when the scale check calls it to scale, else on the layout. | auto |
| exclude_regions | No | Ids of reported detail copies (detail_copies: D1, D2 ...) whose runs repeat pipes drawn elsewhere and are left out. Omitted, every copy is counted. | |
| vertical_allowance | No | Metres added per connection for rises and drops (layout lengths). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||