soficad
README.md
# SOFiCAD MCP
MCP server and Claude Code skills for producing **SOFiCAD 2027 reinforcement drawings** in a running
**AutoCAD 2027** from a text description. For example: "L-shaped slab 25 cm, bottom mesh Ø16/150 + Ø8/200,
bars ≤ 14 m with 15 cm laps, U-bars Ø12 at every edge", turned into a finished drawing with sections,
a centred 1:50 sheet, a monochrome PDF and a bar schedule.
It builds on the [autocad-mcp](https://github.com/SweetBubalehj/autocad-mcp) repo: its `autocad` server, its session guard (dialogs, crash recovery,
AutoCAD started through SOFiCAD's launcher) and its Python venv. The `soficad` server here imports that guard.
| Folder | What |
|---|---|
| `soficad_server/` | `soficad` MCP server. It creates and reads real SOFiCAD rebar (bars, layings, views, cut layings, welded mats) through SOFiCAD's in-process API, lays out the sheet and exports the PDF and schedule. `server.py` registers the tools, which live in `acad_com` (COM link; finds autocad-mcp's guard), `lisp_bridge` (the in-process LISP), `rebar_tools`, `build_tools`, `slab_tools`, `sheet_tools`, `schedule_tools` and `survey_tools`. The pure-Python modules, each with an offline test, are `slab_mesh.py` (a slab's reinforcement), `track_geom.py` (a track alignment: clothoid / arc, cant), `track_slab.py` (a variable-height track slab), `design_rules.py` (EC2 / NA.DE), `mesh_field.py` (welded mats), `geometry.py` (plain items as entmake data) and `sheet_check.py`. |
| `skills/` | Claude Code skills: `soficad-drawing` (workflow and drawing standards, worked examples) and `soficad-ops` (SOFiCAD's API, units, dialogs, schedule). They rely on autocad-mcp's skill `autocad-ops`. |
| `tools/` | Unattended schedule export, SOFiCAD's LOG counter, type-library signature and enum lookup, surveys of big drawings (`dwg_survey.py`, `dwg_window_dump.py`, `dwg_entget.py`), sheets from a spec, the regression run, skill sync. |
## What `soficad_slab` does in one call
You give it an outline (any simple polygon, slanted edges included, or a polyline handle), openings, the
thickness, the cover, the bottom and optional top mesh layers, Lmax, the lap length and the U-bars. It then:
- splits the outline into zones and lays out rows that keep the cover from every edge (perpendicular on
slanted edges);
- groups the rows along a slanted edge into layings whose bar ends differ by at most `step_m`;
- splits long bars into pieces with laps (`max_first` or `equal`); `stagger` alternates the laps between
rows. By default every layer gets the tension lap l0 of EN 1992-1-1 with the German NA (diameter, bond
condition, lapped share);
- checks the detailing (`design_rules.py`, also alone as `soficad_design_check`): cover for bond and
exposure class, lap lengths, clear and maximum spacing, minimum and transverse reinforcement, free-edge
U-bar legs. Findings are reported, they never stop the drawing;
- adds U-bars at every bar end (openings included), set between the main bars, with the height derived
from the layer order;
- unifies bar lengths that are within SOFiCAD's 5 cm similarity tolerance, so no "use similar mark?"
question comes up;
- draws longitudinal and transverse sections at 1:50 (bar views, cut layings, section marks);
- lays out the sheet: slab centred, 1:50, or 1:100 if it does not fit at 1:50. The top mesh gets its own
sheet. Titles carry the real scale.
- saves the drawing, exports the PDF(s) and the schedule (.docx / .rdb), and checks that every mark's bar
count in the drawing equals the computed one.
For example, a 26 × 14 m slab with a chamfer, an opening, a top mesh and staggered laps comes out as
43 marks and 1194 bars in about 30 s.
With `mats={"bottom": "Q335(A)", "top": "Q188(A)"}` instead of `mesh`, the slab is reinforced with welded
mats (see below): the bottom mats in one plan, the U-bars and their edge bars at every free edge in a plan of
their own, and the top mats on their own sheet. Bars and mats are checked mark by mark against the schedule.
`examples/slab_mats_from_description.py` does this for the Drawing1 L-slab on one A0 sheet at 1:50.
## Other drawings: `soficad_build` and `soficad_sheet_compose`
For anything that is not a plain slab, a script computes the item list (bars, layings, bar views, cut
layings, polylines, texts, bubbles, section marks, hatches, dimensions) and draws it with one
`soficad_build` call. `soficad_sheet_compose` then lays out a sheet with several viewports at different
scales, paper-space notes and tables, and fills the title block. Plain geometry reaches AutoCAD as entmake
data that one in-process LISP loop reads from a file (about 1 ms per object instead of 20-50 ms over COM),
and every SOFiCAD object is one command.
The worked example `skills/soficad-drawing/examples/track_curve_r1500.py` draws a slab track (Feste
Fahrbahn) in an 800 m curve: R = 1500 m with 2 × 160 m clothoids and 120 mm cant, 64 identical 12.5 m
blocks. One A0 sheet holds the site plan at 1:1000 with curvature and cant bands, the typical block top
and bottom at 1:50, three canted cross-sections at 1:25, a longitudinal section, notes and a steel table;
labels are in German. It runs in about 19 s.
`track_curve_r1500_var.py` is the same curve with blocks of **variable height**: the slab bottom stays
horizontal and the top follows the cant (`track_slab.py`). It adds dowels at the joints, stirrups at the
dowels and S-hooks between the meshes. The bars that span the depth become SOFiCAD **variable marks**
(sub-marks N.1, N.2 ... with SOFiCAD's own table): `soficad_build` bars take `vary` (values and counts per
sub-mark) and `hooks: "S"`. Three A0 sheets (plans, sections 1:20, joint detail 1:10; 13 transition
blocks; bending shapes and steel list), 72 marks, 30 056 bars, about 60 s. Every mark and sub-mark count
is checked against the schedule.
**Welded meshes** (Betonstahlmatten, Q/R mats) are the `soficad_build` item `mesh_field` (or the tool
`soficad_create_mesh_field`). SOFiCAD fills a rectangle with whole mats and fitting mats from its catalogue,
laps included. The result lists every mat mark with count, size and weight, and checks that the mats
cover the whole field. The field is repaired right after creation: one laid through SOFiCAD's API is
otherwise reported defective on the next open. `soficad_rdb_read` and the schedule export report the mats
(`fabric`). In `examples/mesh_slab.py` a slab gets its bottom and top layer as two plans on one sheet:
16 mats, 8 marks, 827.66 kg, matched mark by mark with the schedule, in about 16 s.
An L-, T- or U-shaped slab with openings is the item `mesh_polygon` (or `soficad_create_mesh_polygon`). The
outline, moved in by the cover and with the openings moved out by it, is cut into rectangles along the mats.
Each rectangle is a field, and where two meet the narrower one reaches into the other by the lap. The mats of
all fields are checked together: they must cover the whole area and stay inside the cover. An edge that runs
neither along nor across the mats is refused. SOFiCAD's own polygonal layout command is interactive only, so it is not
used. SOFiCAD cannot lay a fitting mat narrower than 1.5 × the lap (the field comes out broken), so the lap of
such a field is raised, or the field is laid as two halves.
The free edges of a mesh slab get U-bars (Steckbügel, EC2 9.3.1.4) from the item `edge_u_bars`. It becomes A3
marks and one laying per edge, with legs 2h by default. The U-bars sit between the bottom and top mats, and
those of crossing edges are nested at the corners. Each edge also gets two straight bars in the U's corners
(figure 9.8), lapped when the edge is longer than a bar. `examples/mesh_polygon_slab.py` lays both mat layers
of a 14 × 10 m L slab with a stair opening, plus its U-bars and edge bars in a plan of their own: 34 mats
(1080.79 kg) and 322 bars (167.02 kg), all matched with the schedule.
## Requirements
- Windows; AutoCAD 2027 with SOFiCAD 2027, licensed and started through SOFiCAD's launcher.
- [autocad-mcp](https://github.com/SweetBubalehj/autocad-mcp), installed as its README says (`C:\autocad-mcp`, with its venv). This repo finds it as
`AUTOCAD_MCP_HOME`, else as the folder `autocad-mcp` next to this repo, else in `C:\autocad-mcp`.
- Python 3.15 (64-bit) and Claude Code.
## Install
The skills refer to `C:\soficad-mcp` and `C:\autocad-mcp`; the server locates its own files relative to itself.
```powershell
git clone https://github.com/SweetBubalehj/soficad-mcp.git C:\soficad-mcp
C:\autocad-mcp\Scripts\pip install -r C:\soficad-mcp\requirements.txt # pypdfium2, python-docx into autocad-mcp's venv
```
Register both servers in your Claude Code project. Copy `mcp.example.json` to `<project>\.mcp.json`, or add
them with `claude mcp add`. Then install the skills of both repos into that project:
```powershell
C:\autocad-mcp\Scripts\python.exe C:\autocad-mcp\tools\sync_skills.py install <project folder>
C:\autocad-mcp\Scripts\python.exe C:\soficad-mcp\tools\sync_skills.py install <project folder>
```
Check the installation:
```powershell
cd C:\soficad-mcp
C:\autocad-mcp\Scripts\python.exe tools\regress.py --offline # the 7 offline tests (geometry, EC2 rules, sheet check, mats, entmake data), seconds
C:\autocad-mcp\Scripts\python.exe tools\regress.py # + the reference drawings built in AutoCAD, ~3 min
```
The full regression run builds eight reference drawings in `%TEMP%\soficad_regress`: Drawing1 as items and by
`soficad_slab`, a slab with every feature, the curve and its variable-height variant, and the three mesh slabs
(one of them by `soficad_slab` with mats). It compares their
schedules with `tools/regress_golden.json` and runs `soficad_sheet_check` on every sheet, so overlapping
annotation or text cut by a viewport edge fails the run. It also writes PDF previews and overlays. Run it
after changing server or geometry code.
GitHub Actions (`.github/workflows/offline-tests.yml`) runs the offline tests on every push and pull request,
on Windows and Linux with Python 3.15. They need only the standard library. Where SOFiCAD is not installed,
the mat test reads a few standard mats from `soficad_server/testdata/mesh_catalogue.ini` instead of SOFiCAD's
`din.ini`. The reference drawings need AutoCAD and SOFiCAD, so they run only on a workstation.
## Looking at the result
- `soficad_pdf_preview` renders a plotted sheet, or a region of it in paper mm, to PNG (pypdfium2).
- `soficad_sheet_check` finds texts, bubbles and SOFiCAD labels that overlap on a sheet, and items cut by
a viewport edge, and draws them onto the rendered PDF. TEXT boxes are exact, rotated ones included. SOFiCAD's
laying labels are estimated from their position, angle and text, because SOFiCAD does not expose their
extents.
- SOFiCAD draws a variable mark's table into a plot only once the drawing has been opened, so
`soficad_export_pdf` saves, closes and reopens a drawing once if this session created variable marks in it.
In Claude Code, `soficad_status` shows the connection.
## Working on it
- Server code changes need `/mcp` → Reconnect in Claude Code. `sheet_config.json` and autocad-mcp's
`acad_guard/guard_config.json` are re-read on every call.
- The skills are loaded from the project's `.claude\skills`. After editing them there, copy them back
before committing: `C:\autocad-mcp\Scripts\python.exe tools\sync_skills.py export <project folder>`.
- `tools/sofbole_api.txt` (a dump of SOFiSTiK's type library) is local only. To regenerate it:
`C:\autocad-mcp\Scripts\python.exe tools\tlb_dump.py "<SOFiCAD 2027 dir>\sofbole.tlb" > tools\sofbole_api.txt`.
`tools\tlb_sig.py` and `tools\tlb_enum.py` read method signatures and enum members straight from
`sofbole.tlb`.
## License
MIT, see [LICENSE](LICENSE). AutoCAD and SOFiCAD are products of Autodesk and SOFiSTiK; they are not part of
this repo and need their own licences.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues