Metadata-Version: 2.5
Name: cadbuildr-piping
Version: 0.1.0
Summary: Process piping as real hollow geometry: ASME/EN/copper/PVC pipe, B16.9 butt-weld fittings, B16.5 flanges with gaskets and stud bolts, B16.11 forged fittings with NPT, B16.10 valve envelopes, and polyline pipe routing with cut list and checks
Author: CADbuildr Team
License: MIT
License-File: LICENSE
Requires-Python: <4.0.0,>=3.10.0
Requires-Dist: cadbuildr-foundation<0.4.0,>=0.3.0
Description-Content-Type: text/markdown

# cadbuildr-piping

## Summary

Process piping library: ASME/EN/ASTM pipe, B16.9 fittings, B16.5 flanges with gaskets and studs, B16.11 forged fittings, B16.10 valve envelopes and polyline routing, all hollow and joined by `connect`.

## Contents

`pip install cadbuildr-piping`, `import cadbuildr.piping`, library id
`piping`. Every part is real hollow geometry with the wall of its schedule,
built from cited dimension tables, and every end carries a `PipeEnd`
interface so `assembly.connect` puts pipe, fittings, flanges and valves
together and refuses ends that do not join.

- **Pipe and tube** (`pipe.py`): `Pipe` (ASME B36.10M / B36.19M, NPS 1/8-24,
  schedules 5S, 10S, 10, 40, 80, 160, XXS, STD, XS, 40S, 80S), `ENPipe`
  (EN 10220 / ISO 4200 series 1, DN 10-600, preferred walls), `CopperTube`
  (ASTM B88 K / L / M), `PVCPipe` (ASTM D1785 sch 40 / 80). Ends: `BW`
  (ASME B16.25 37.5 deg bevel, 1.6 mm land, compound bevel over 22 mm),
  `PE` (plain) or `THD` (ASME B1.20.1 NPT, cosmetic taper at the major
  diameter).
- **ASME B16.9 butt-weld fittings** (`fittings_bw.py`): `Elbow` LR / SR 90
  and LR 45 (B16.9 has no SR 45: `NonStandardFitting`), `Tee` equal and
  reducing (B16.9 outlet table), `Reducer` concentric and eccentric, `Cap`
  (2:1 head), `StubEnd` (lap joint). Schedule wall and bevels on every
  weld end.
- **ASME B16.5 flanges** (`flanges.py`), classes 150 / 300 / 600:
  `WeldNeckFlange`, `SlipOnFlange`, `BlindFlange`, `LapJointFlange`;
  raised face, hub, bolt circle and holes; `FlatRingGasket` (B16.21),
  `SpiralWoundGasket` (B16.20); `StudBolt` + `HeavyHexNut` (ASME B18.2.2,
  UNC / 8UN); `bolt_up()` and `FlangedJoint` (studs close loops, so
  `check()` proves the grip).
- **ASME B16.11 forged fittings** (`forged.py`), class 3000:
  socket-weld and threaded elbows (90 / 45), tees, couplings; MSS SP-83
  `ThreadedUnion`; NPT bores at the correct diameters and 1:16 taper.
- **Valve envelopes** (`valves.py`): `GateValveEnvelope`,
  `GlobeValveEnvelope`, `BallValveEnvelope`, `CheckValveEnvelope`;
  face-to-face per ASME B16.10, real B16.5 flanged ends, keep-out body
  and handwheel / lever clearance (Estimated, listed on each part).
- **Routing** (`routing.py`): `PipeRun(points, nps, schedule)` pipes a
  polyline, picks elbows at 90 / 45 corners (`NonStandardAngle` otherwise),
  clocks them with `connect(..., roll=)`, terminates with flanges or caps,
  gives `cut_list()` and `bom()`, and checks weld spacing and support
  spans (ASME B31.1 Table 121.5 / MSS SP-58).
- **Demos** (`demos.py`): `WaterLoop` (a closed loop with a bolted-in valve:
  three loop closures `check()` verifies) and `PumpSkidManifold`.

```python
from cadbuildr.foundation import show
from cadbuildr.piping import PipeRun

run = PipeRun([(0, 0, 0), (1000, 0, 0), (1000, 800, 0)], nps="2", schedule="40",
              start="flange", end="cap", supports=[1200])
print(run.cut_list())
assert [i for i in run.check() if i["severity"] == "error"] == []
show(run)
```

```bash
python -m cadbuildr.foundation.library manifest cadbuildr.piping
echo '{"item": "piping:Elbow", "inputs": {"nps": "4", "radius": "SR"}}' | python -m cadbuildr.foundation.library eval
```

Agent recipes: [`SKILL.md`](SKILL.md) (mirror:
`threepointo/skills/libraries/cadbuildr_piping.md`). Content plan:
`docs/specs/plan_library-content_00003/packages/piping.md`.

### Remaining simplifications

| What | Why | What would fix it |
|---|---|---|
| NPT threads are cosmetic tapers (no helix) | foundation's `Thread` op is cylindrical only | a tapered-thread kernel op |
| B16.9 tee crotch = intersecting cylinders | B16.9 fixes C, M, walls only; the contour is the maker's | a fillet on the intersection edge (edge finder on the crotch) |
| Weld-neck hub is a straight taper; no hub fillet | B16.5 fixes X, A, Y and a max slope | same as above |
| Reducer straight ends 0.15 H (Estimated) | B16.9 fixes only H | maker data |
| B16.11 bodies keep the band / socket-wall OD to the centre | forging shape is the maker's | maker data |
| Valve bodies and operators are envelopes | maker-specific | vendor STEP (not redistributed) |
| Butt welds have zero root gap by default | the gap is a WPS choice | `connect(..., gap=1.6)` already takes it |

## Tags

cad, python, library, piping, asme, b16-5, b16-9, b16-11, flanges, fittings, valves, routing

## Status

yellow

## Guidelines

- Every dimension comes from a `tables/` module that cites its standard and source.
- Values a standard does not fix go in the part's `estimated` list and its BOM.
- Place parts with `ground` / `connect` on their interfaces, never by transforms.
- Fail loudly with named errors (`UnknownSize`, `NonStandardFitting`, `RoutingError`...).
- Keep a closed-form volume on every part so mass and tests need no kernel.
- Depend on `cadbuildr-foundation` only, so the folder can move to its own repo.

## Dependencies

### Upstream

- (none)

### Downstream

- (none)
