Metadata-Version: 2.4
Name: ezceq
Version: 0.1.0
Requires-Dist: cad2d-ir>=0.19.2,<0.20 ; extra == 'dxf'
Provides-Extra: dxf
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.txt
Summary: BE-Bridge Ver.7.0 CEQ record reader with a Rust core
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/monozukuri-ai/ezceq

# ezceq

Read BE-Bridge 7.0 CEQ files from building-services CAD software. The Rust parser exposes pipe and duct dimensions, system names, port coordinates, and connections through a Python API and a JSON command-line tool. A companion DXF can link a selected drawing entity back to its CEQ component. [日本語ガイド](https://github.com/monozukuri-ai/ezceq/blob/main/docs/usage-ja.md)

## Install from source

Use Python 3.10 or later and a Rust toolchain. From the repository root, install the package in a virtual environment.

```sh
python -m pip install .
ezceq samples/synthetic/mixed-v7.ceq --encoding cp932
```

The CLI writes UTF-8 JSON. The input encoding is explicit and accepts `cp932` or `utf-8`. The example has two pipes, two ducts, and one resolved connection between port 2 of pipe `P00001` and port 1 of reducer `P00009`. [Sample drawing and expected values](https://github.com/monozukuri-ai/ezceq/tree/main/samples/synthetic/)

## Python

```python
import ezceq

doc = ezceq.readfile("samples/synthetic/mixed-v7.ceq", encoding="cp932")
data = doc.to_dict()
reducer = next(p for p in data["parts"] if p["id"] == "P00009")
print(reducer["system"], reducer["nominal_by_port"])  # 冷水送り [50.0, 25.0]
print(data["connections"])  # [{'a': ['P00001', 2], 'b': ['P00009', 1]}]
raw = doc.raw_record(reducer["line"])
```

Use `ezceq.read_ceq(data, encoding=...)` for a byte buffer and `doc.to_json()` for serialized output. Rust callers can use `ezceq_core::read_ceq` with `ReadOptions` and `TextEncoding`. [Rust API](https://github.com/monozukuri-ai/ezceq/blob/main/crates/ezceq-core/src/lib.rs)

| Output | Meaning |
|---|---|
| `parts` | Records in file order. Supported pipe and duct families include straight sections, elbows, tees and reducers. Each parsed port distinguishes an unused slot, an open end and a reference to another part. |
| `connections` | Undirected pairs of ports. Resolution requires unique part IDs, reciprocal references and equal XYZ coordinates as decimal values. Unresolved references retain their source locations in `diagnostics`. |
| `actual_counts`, `unsupported_counts` | Observed counts by component type and unsupported counts by reason. Each record retains its identifier, starting line and original byte range. |
| `diagnostics`, `unparsed_range` | Problems found during reading and any remaining bytes after a record boundary was lost. Lines start at 1. Byte ranges are zero-based with an exclusive end. |

The CLI exits with `0` on success (including warnings), `1` on a fatal input or file error, and `2` when it writes a partial result with CEQ data errors. Python raises `InvalidHeaderError` or `UnsupportedVersionError` for invalid headers and unsupported versions. For a parsed document, check `doc.has_errors`.

## Select a component in a DXF

```sh
python -m pip install '.[dxf]'
ezceq samples/synthetic/mixed-v7.ceq --encoding cp932 --dxf
```

`--dxf` discovers a same-name companion. Use `--dxf PATH` to select a specific file. The added `dxf` object records which INSERT instances match each complete CEQ block name. It distinguishes multiple placements, unplaced definitions, missing definitions, ambiguous records and a missing companion.

```python
from ezceq.dxf import link_dxf, part_indices_for_entity

links = link_dxf(data, "samples/synthetic/mixed-v7.dxf")
indices = part_indices_for_entity(links, "E49/E45")  # outline of the rectangular duct
print([data["parts"][i]["id"] for i in indices])  # ['D00025']
```

If a viewer already holds the DXF-derived cad2d-ir document, pass it to `link_ir(data, ir_document)`. Keep the parent INSERT IDs when expanding blocks. The placement path identifies a particular instance of a shared definition.

## Format reference

The reader implements the BE-Bridge 7.0 exchange specification by C-CADEC. The examples in this repository are hand-authored. [BE-Bridge 7.0 specification, archived C-CADEC publication (Japanese PDF)](https://web.archive.org/web/20240326020558id_/https://www.kensetsu-kikin.or.jp/archive/c-cadec/hyogikai/data/be_bridge7.pdf)

## License

ezceq and its hand-authored samples are available under the MIT License. Copyright © 2026 monozukuri-ai. [License](https://github.com/monozukuri-ai/ezceq/blob/main/LICENSE) · [Third-party notices](https://github.com/monozukuri-ai/ezceq/blob/main/THIRD_PARTY_NOTICES.txt)

