Skip to content

Building Code for all standards - #486

Merged
IPedrax merged 15 commits into
mainfrom
feat/building-code
Nov 18, 2026
Merged

IPedrax merged 15 commits into
mainfrom
feat/building-code

Conversation

@dansity

@dansity dansity commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Draft, stacked on #386. The branch starts from #386's head, because the Building Code engine and the dialog started there. Merge #386 first; this PR then shows only its own work.

The new rule: no code values in code

A number that a standard, a utility, a fire brigade or a common practice gives is a rule of a building code. It lives in crates/core/data/codes/ with its source, and the project can change it. Rust holds the method, never the number. Physical constants and safety caps stay in Rust.

The rule is in CLAUDE.md. code_values_live_in_codes (codes/rule_tests.rs) fails on a numeric constant in a module that reads a code.

What is in

Merged into the branch:

Only the module map, the electrical area paragraphs and the translation catalogues conflicted, and both sides were kept. If any of them lands on main first, its merge here is a no-op.

The engine (codes.rs, codes/):

  • Codes. Five disciplines: architectural, structural, electrical, mechanical, plumbing. Each code is one file of sections of rules. Every rule has a source and a kind (requirement, recommendation, practice, assumption, historical, forgiving).
  • Layers. A project picks a base code, amendments over it, and its own changes. An amendment may amend another, so a utility group's member can sit over the group's standard. Amendments go in the order the project gives, and the last one wins. The rules in force are kept per revision, so reading them is a field access.
  • Editing an amendment. building_code {amend} saves rule changes and resets into that amendment, not into the project's own changes. Editing one of BIMCraft's amendments makes a project copy under the same name; resetting the whole copy brings back the library's. A rule set to null is removed from the amendment. create (with over) makes a new, empty amendment for the project.
  • The library. A section none of the project's layers has comes from BIMCraft's own codes, and says so. Any command works whatever the project chose. A section only amendments hold, and that isn't complete alone, has the library's under it.
  • From discussion Unified Codes #487:
    • a project pins the edition of each code it chooses; a newer edition in the library changes nothing until the code is chosen again, and editions_gone says so;
    • a code lists its documents once, and a rule's source cites one by id, with item and page.
  • Files. Model::codes replaces Stairs: an advanced stair tool #386's three fields, and a Stairs: an advanced stair tool #386 file is still read into it. No FORMAT bump: an older build leaves the field out and lists it.
  • Commands.
    • building_code works by discipline, and Stairs: an advanced stair tool #386's parameters still work.
    • building_code_export and _import use XML format 2, for one discipline or all five, and still read format 1.
    • New: code_rules (every rule in force, with layer, source and kind), site_climate (the project's map values) and code_check.

Rewired, numbers unchanged (the modules' existing tests pin them):

  • stairs;
  • a new ramp's slope and width;
  • plumbing: the fixture library, cold water, reservation, drainage and vents, storm drainage (the abacuses as data, the rain from Site & Climate), and hydrants (CBPMESP IT 22 as an amendment over NBR);
  • NBR 6118's concrete limits for reinforce {check};
  • electrical, from building_demand: a building's demand by a utility's or a country's method, as data #458, building_demand: a coefficient for each dwelling (Portugal, France, the NEC) #483 and demand: other utilities' service categories as data #484, with no number left in Rust:
    • NBR 5410 holds the RCD rules, bathroom volumes, dwelling load points, circuit sizing (Tabelas 36 to 48 and 58, the voltage drop), conduit fill (with the makers' catalogues) and surge protection;
    • CPFL's, Enel's and Celesc's unit demand and supply categories (demand) are each an amendment over NBR 5410;
    • each utility's building demand and service categories are its own amendment over NBR 5410: Celesc, Cemig, Fecoergs, Hidropan, Energisa, Equatorial and Copel;
    • Spain's, Portugal's, France's and the NEC's demand methods are base codes of their own;
    • circuit, conduit_fill, dps_check, load_points, dr_check, bath_volumes, building_demand and demand read the project's code, including what the project or an amendment changed. A standard or utility that is named still reads BIMCraft's.

New checks, fast and local, and timed on the 20-storey sample tower:

  • ramps: slope by a run's rise, run rise, width, landings;
  • doors: clear width and height, the widest leaf, exempt types;
  • rooms: area, narrower side, height and natural light (window area over floor area; the IBC's 8 %), by the kind the room's name says.

They show in code_check, in Properties, and in the Building Code Check window.

Manage > Building Codes:

  • Overview: region presets, a card for each discipline, Site & Climate.
  • Five tabs, each with its code picker and Import / Export / Save As / Delete / Reset for that discipline alone.
  • Amendments are a list:
    • ticked from Choose Amendments;
    • put in order by dragging, or with the arrows;
    • one marked as where changes are saved;
    • Create Amendment makes a new one.
  • The Electrical tab holds the Electrical Settings (voltages, distribution systems, wire types). Manage > Electrical Settings opens it there. They are sections of the electrical code: a code chosen brings its own (NBR 5410 Brazil's, the NEC North America's), and a change is saved into the amendment edited or the project's changes.
  • The kinds of room are rows: kind, room names, minimum area, width and height, and natural light.
  • The region preset shows the region picked.
  • The panel's wording is plain English.
  • Each tab has:
    • the sections, with a search;
    • the rules grid, with From and Source columns;
    • a rule that is more than a number shown as what it is: a form, a table with named columns (a utility's columns explained when pointed at), or cards for tables of tables, with copy and paste as tab-separated text;
    • a section's own words (standard, source, notes, what it leaves out) shown as text, not as rules;
    • a rule card.
  • Tested with egui_kittest and looked at in light and dark. BIMCRAFT_CODES_DUMP renders it.

Data:

  • the Brazilian codes that were already there;
  • the IBC's ramps, doors, rooms, egress and accessibility;
  • NBR 9050's ramps and doors;
  • the Eurocodes' loads;
  • ASHRAE 62.1's ventilation.

Every new number is marked unchecked, with the item it is from.

Translations: Portuguese and Spanish for the dialog's new words.

Not in this PR

  • Data still to come: the UK and Germany.
  • Checks still to come: windows and escape openings, guards on their own, and the working space in front of electrical panels.

Checks

At 3d4e4ca7: cargo fmt --check and cargo i18n check pass on the author's machine, and the app builds. Clippy and the test suite were not run locally (the machine ran short of memory); CI runs them. The previous commit, 68090934, passed all four locally.

ffishman and others added 6 commits November 14, 2026 16:08
…thod, as data

The demand of a building of dwellings, which sizes its entrance, by one shape the
methods share: D = factor * F(n) * d + common + special + commercial + premises.
data/building-demand.json holds Celesc N-321.0003, Cemig ND-5.2, Fecoergs REGD
035.01.06, Hidropan's RIC BT and Spain's ITC-BT-10; a utility or a country is a
new entry, never code. Tables are kept as printed, with errata where the same
table prints otherwise in the other standards (as_printed takes the printed
value). Tests hold the standards' own examples and the data: sources, order,
F(n) <= n, entrance rows without gaps, curves that meet their tables, and the
four Brazilian diversity tables as one table.
The branch's 25 commits as one on main (a0c57b7), its history in backup/advanced-stair-tool-premerge:

- Stairs: research on Revit's, Archicad's and Vectorworks' stair tools, and a plan for ours
- Stairs: the plan takes building codes apart from technical standards, and what was decided of them
- Stairs: building codes as data, winders, a location line and landings of their own length
- Building codes: a project's own, saved under a name and handed on as XML; a stair's findings in a window
- Stairs: landings and turns edited in Properties, and Flip
- Stairs: grips on the plan
- Stairs: winders balanced into the flights
- Stairs: the walk line round a winding turn, and the tool's landings by the code
- Stairs: turns by any angle, and the tool drawing run after run
- Stairs: spirals
- Stairs: stair types
- Stairs: the solver
- Stairs: multistorey, over storeys of different heights
- Stairs: the plan symbol
- Stairs: headroom, and the opening in the floor above
- Stairs: custom sketched stairs
- Stairs: the break mark through winders, the solver balancing them, IFC risers by storey
- Stairs: runs of their own widths
- Building codes: lengths in the project's units
- Stairs: the code check while drawing, and a spiral's centre grip
- Stairs: Properties say the location line a stair has, and plainer words in the check window
- Stairs: drawn along a line, flights and landings as they are drawn
- Stair plan: a handoff and the full to-do, with what the reference screenshots showed
- Stairs: types by construction, finishes and plan symbols, subcategories and headroom, IFC both ways, codes with sources
- Stairs: snapping to stairs and wall faces, winders unbroken, open stairs round turns, fast code checks

On main: the stair's IFC roles take 90 to 98, after main's; a 3D triangle has both main's form visibility (vis) and the
stair part (part), and every filter asks both; main's new prisms are whole elements (part 0); a stair edge is a reference
face main's dimension messages name; the catalogs are regenerated.
CPFL: the factors are unchanged; the tables are renumbered (Tabela 15 for
other buildings, 13 and 14 for motors, item 6.22.1). Tabela 1C's C9 goes to
52 kVA, B1 and B3 take a 32 mm conduit, C7 earths by 6 mm², the aluminium
entry cable is given beside the copper one, and three-phase motors go to
300 cv.

Enel: GRI-0017 version 02 (the former ET 1569) prints no power made
available and stretches each range up to it, so Anexo A's ranges overlap;
new 175 A rows in Anexos A (C8) and D (C5); Anexo A's earthing and C4's
entry, Anexo B's B4/C4 connection and B9/C9 earthing, Anexo C's limits as
printed. available_kw leaves the reply.
data/entrance-categories.json, read by entrance.rs, holds each utility's
tables of categories as printed (phases, installed load and demand
ranges, breaker, measurement and the other columns, each explained), and
demand picks a unit's category from it. Groups list their members, found
by their own names, and a member's own document on a category is cited.

First utilities: Fecoergs (RIC BT REGD 035.01.06, Anexo J; Coprel's OTD
006.01 and Cerfox's OT_NIC_019 on C18), Hidropan (RIC 2014, Tabela 11),
Energisa (NDU 001 v7.0, Tabelas 16 and 18), Equatorial (NT.00001 rev 09,
Tabelas 1 and 2) and Copel (NTC 901100, Tabela 2).
…ce and the NEC

Some methods print, by bands of the number of dwellings, a coefficient that
weighs the sum of their powers rather than an equivalent number of dwellings.
`diversity.kind: per_dwelling` takes such a table as data: F(n) = n * C(n), the
last row holding past it, and the reply gives the `coefficient`. Such a total
falls where a band begins (four dwellings at 1.00 ask more than five at 0.75),
as the method does, so the data test checks that C never grows and stays at
most 1 instead of F growing. Entries: Portugal's RTIEBT (801.5.2.2 and Quadro
803A), France's NF C 14-100 as SeQuelec's GP 16 works it (without electric
heating) and the US NEC's Table 220.84. The default stays the equivalent count,
so the existing entries read as before.
What is there now, what contributors proposed, the design (disciplines,
sections, layers, tables, sources), the dialog, a catalogue of every
parameter by tab, and the work in order. Nothing is built yet.
# Conflicts:
#	translations/ui/bimcraft-ui.pot
#	translations/ui/cs.po
#	translations/ui/de.po
#	translations/ui/es.po
#	translations/ui/fr.po
#	translations/ui/it.po
#	translations/ui/nl.po
#	translations/ui/pl.po
#	translations/ui/pt.po
#	translations/ui/vi.po
#	translations/ui/zh.po
#	translations/ui/zh_TW.po
# Conflicts:
#	translations/project/bimcraft-project.pot
#	translations/project/cs.po
#	translations/project/de.po
#	translations/project/es.po
#	translations/project/fr.po
#	translations/project/it.po
#	translations/project/nl.po
#	translations/project/pl.po
#	translations/project/pt.po
#	translations/project/sv.po
#	translations/project/vi.po
#	translations/ui/bimcraft-ui.pot
#	translations/ui/cs.po
#	translations/ui/de.po
#	translations/ui/es.po
#	translations/ui/fr.po
#	translations/ui/it.po
#	translations/ui/nl.po
#	translations/ui/pl.po
#	translations/ui/pt.po
#	translations/ui/vi.po
#	translations/ui/zh.po
#	translations/ui/zh_TW.po
# Conflicts:
#	CLAUDE.md
#	docs/areas/structure-and-mep.md
#	translations/project/bimcraft-project.pot
#	translations/project/cs.po
#	translations/project/de.po
#	translations/project/es.po
#	translations/project/fr.po
#	translations/project/it.po
#	translations/project/nl.po
#	translations/project/pl.po
#	translations/project/pt.po
#	translations/project/sv.po
#	translations/project/vi.po
#	translations/ui/bimcraft-ui.pot
#	translations/ui/cs.po
#	translations/ui/de.po
#	translations/ui/es.po
#	translations/ui/fr.po
#	translations/ui/it.po
#	translations/ui/nl.po
#	translations/ui/pl.po
#	translations/ui/pt.po
#	translations/ui/vi.po
#	translations/ui/zh.po
#	translations/ui/zh_TW.po
@ffishman

Copy link
Copy Markdown
Contributor

Thanks, @dansity. I replied in #487, with a few suggestions and a question for the maintainer about the order of the electrical PRs. I'll take E1 to E9.

# Conflicts:
#	CLAUDE.md
#	crates/core/src/commands.rs
#	docs/areas/structure-and-mep.md
#	translations/project/bimcraft-project.pot
#	translations/project/cs.po
#	translations/project/de.po
#	translations/project/es.po
#	translations/project/fr.po
#	translations/project/it.po
#	translations/project/nl.po
#	translations/project/pl.po
#	translations/project/pt.po
#	translations/project/sv.po
#	translations/project/vi.po
#	translations/ui/bimcraft-ui.pot
#	translations/ui/cs.po
#	translations/ui/de.po
#	translations/ui/es.po
#	translations/ui/fr.po
#	translations/ui/it.po
#	translations/ui/nl.po
#	translations/ui/pl.po
#	translations/ui/pt.po
#	translations/ui/vi.po
#	translations/ui/zh.po
#	translations/ui/zh_TW.po
…ned, plumbing and concrete rules as data

The engine of the plan in docs/building-code-plan.md, steps 1 and 3:

- codes.rs: a code is an entry of one discipline (architectural, structural,
  electrical, mechanical, plumbing) with sections of rules as data, each rule
  with its source and kind. A project picks a base for each discipline,
  amendments over it (an amendment may amend another: base, issuer, member),
  and changes any rule; the rules in force are resolved layer by layer, kept
  per revision of the codes, and a section none of the layers has comes from
  BIMCraft's library and says so.
- From discussion #487: a project pins the editions it chose, and a newer one
  in the library changes nothing until the code is chosen again
  (editions_gone says so); sources cite a document of the code's own list by
  id, with item and page.
- Data: data/codes/<discipline>/<code>.json, one file a code, listed in
  codes/data.rs; #386's building-codes.json split into the architectural
  codes. Region presets in data/codes/presets.json.
- Model::codes replaces #386's building_code, stair_rules and building_codes,
  which a file is still read with (migrate).
- Commands: building_code takes a discipline, amendments and rules by
  section (#386's params still work); building_code_export and _import write
  and read XML format 2, one discipline or all five, and still read format 1;
  new code_rules, site_climate and code_check.
- Plumbing rewired, numbers unchanged: the fixtures library, cold water,
  reservation, sanitary drainage and vents, storm drainage (the abacuses as
  data, the rain from the project's Site and Climate) and hydrants (CBPMESP
  IT 22 as an amendment). Structural: NBR 6118's bar limits as the Concrete
  section, which reinforce {check} reads.
- The electrical modules are left for their authors to move (E1 to E9,
  discussion #487).
…s, the rule enforced

- codes/checks.rs: the Ramps, Doors and Rooms sections and their checks
  (slope by a run's rise, run rise, widths, landings; clear width and
  height, widest leaf, exempt types; area, narrower side and height by the
  kind a room's name says), in code_check and the element's JSON, timed on
  the highrise. A new ramp starts with the code's slope and width.
- Data: NBR 9050's ramps and doors, the IBC's ramps, doors, rooms, egress
  and accessibility, the Eurocodes' loads and ASHRAE 62.1's ventilation,
  all unchecked and saying so; region presets.
- Manage > Building Codes: an Overview (region presets, a card for each
  discipline, Site and Climate) and a tab for each discipline: its code,
  amendment chips, Import, Export, Save As, Delete, Reset Tab, the sections
  with search, the rules grid with From and Source, a table editor with copy
  and paste, and the rule card. The code check window covers ramps, doors
  and rooms.
- The rule: "No code values in code" in CLAUDE.md, enforced by
  code_values_live_in_codes; the electrical modules are named as moving
  (E1 to E9, discussion #487).
- Docs: docs/areas/building-codes.md rewritten, the plan's status, README.
@ffishman

Copy link
Copy Markdown
Contributor

Two ui-egui tests of the Building Codes window fail on 3927ae3 itself, and both look like the window not yet following the engine:

  1. tests::codes::building_codes_choose_a_code_and_change_its_rules ("OK closes it"). The window sends the whole StairRules (ui-egui/src/codes.rs:110, sent at :606), so a field with #[serde(default)] that a code's file leaves out goes too: nosing_min (codes/stairs.rs:63) is not in ibc.json, comes back as 0, and building_code refuses it as no rule of the section (codes/command.rs:249), so the dialog stays open (codes.rs:620). Adding "nosing_min": 0 to ibc.json fixes this case; reading the code's rules through the section's type before checking the keys would fix it for any optional field.
  2. tests::codes::a_code_changed_is_custom_and_is_saved_under_a_name_and_deleted (no "Delete" button). Saving now writes to model.codes.own (codes/command.rs:279), but the list and the Delete button still read model.building_codes (codes.rs:523 and :541), which only the migration of older files uses now. The test's last check (tests/codes.rs:91, m.building_codes.is_empty()) holds before the delete as well, so it would want m.codes.own.

Happy to send either as a small commit if that helps.

ffishman added a commit to ffishman/BIMCraft that referenced this pull request Nov 17, 2026
The base is now b87e132, the head of IPedrax#486 with dansity's two new commits
(067a5ed, b87e132); E9's commits were rebased onto it. Squash the commits
above b87e132 into one, without this file, and compare values against
3927ae3 as before (b87e132 changes no electrical number).
…al codes, rooms' natural light

- Amendments go in the order chosen (dragged in the dialog), the last winning; each stands over the base or any other
  amendment chosen. `building_code {amend}` puts rule changes and resets into that amendment instead of the project's
  changes; one of BIMCraft's becomes the project's copy under its name. `create` (and `over`) makes an empty one.
- A section only amendments hold, and that is not whole alone, is the library's under what they change.
- Electrical: NBR 5410 holds `rcd`, `bath_volumes` and `load_points`; each utility's building demand and service
  categories are its amendment over it (Celesc, Cemig, Fecoergs, Hidropan, Energisa, Equatorial, Copel), and Spain's,
  Portugal's, France's and the NEC's methods are codes of their own. The commands read the project's, as changed.
  The old data files are gone; the Brasil and USA presets pick NBR 5410 and the NEC.
- Rooms: a kind's natural light (`light_min`, window area over floor area; the IBC's 8 %), checked from the windows in
  the walls round the room.
- Dialog: the kinds of room as rows (kind, room names, least area, width, height, natural light); amendments as a list
  ticked, dragged, made new, with the one changes go into; the region preset says the region picked; the Electrical
  tab holds the Electrical Settings, which the ribbon button opens; plain English throughout.
@dansity

dansity commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

@ffishman I would like you to clone this branch and commit any changes you wish to have. I put down the foundation and the basic idea on how i think it should work and look like but you know the structure of standards better than me. Let me know if you need anything

…de; rules shown as forms and tables

- NBR 5410's circuit sizing, conduit fill and surge protection are its `circuits`, `conduit_fill` and `surge` sections;
  CPFL's, Enel's and Celesc's unit demand and supply are `unit_demand`, each an amendment over NBR 5410. The numbers were
  copied from the Rust tables by script; the modules keep the methods, and the commands read the project's code.
- Voltages, distribution systems and wire types are sections of the electrical code: a code chosen brings its own, and
  what the project changes goes into the code, or into the amendment the dialog saves to.
- Manage > Building Codes shows a rule that is more than a number as a form, a table with named columns, or cards; a
  section's own words (standard, source, notes) are no longer rules, and long text wraps.
@ffishman

Copy link
Copy Markdown
Contributor

Thanks, @dansity, that works well for me. I'll check the copied electrical tables against the old Rust ones by running both side by side (every lookup, not by reading), then XML round trips and edits through an amendment, and send what I find as one small PR into feat/building-code, with the tests that prove the numbers.

Could you leave the electrical files (data/codes/electrical/, demand.rs, nbr5410*, conduit*, dps*, electrical.rs) as they are until then? We both moved the same tables in parallel over the last day, so one of us ended up redoing what the other had done; holding them for a bit keeps either of us from throwing work away. I expect to have it up in about two hours and will say here when it is.

@ffishman

Copy link
Copy Markdown
Contributor

A quick heads-up, @dansity: while checking 3d4e4ca I came across a few things in how amendments and the new Electrical Settings behave across save/import, removing an amendment and deleting entries. I'm reproducing them now, by running them rather than reading, and will post a short list with an example for each within the hour. The copied table values look right so far.

Would you mind holding off on the amendment and Electrical Settings code too (codes.rs, codes/command.rs, codes/xml.rs, electrical.rs), along with the electrical files, until then? That way we don't both end up fixing the same thing. Thanks!

@dansity

dansity commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @ffishman
Heads-up: I went ahead and moved the electrical part myself in #486 (sorry for stepping on E1–E9). There's no electrical number left in Rust now:

  • NBR 5410 holds circuit sizing (Tabelas 36–48, 58, voltage drop), conduit fill with the makers' catalogues, surge protection, RCD, bath volumes and load points;
  • CPFL, Enel and Celesc are amendments over NBR 5410 with their unit_demand, next to the demand: other utilities' service categories as data #484 utilities' entrance and building_demand;
  • voltages, distribution systems and wire types are code sections too.

This was done by the agent before your comment. My suggestion is just fix up this PR as good as possible and push it in one go.

The numbers were copied from the Rust tables by script and your tests still pin them. It would help a lot if you could review the data files in crates/core/data/codes/electrical/, since you know these documents better than anyone.

From your list, edition pins, amendment-on-amendment and sources cited by id with item and page are already in. adopts, change kind, region, copy_of and the municipality → utility picker aren't yet. They feel like the next PR on top of #486 rather than more scope in it. Would you be up for proposing the schema for those, starting with the RS and SC cooperatives, as a PR into feat/building-code or after it lands?

@ffishman

Copy link
Copy Markdown
Contributor

Thanks, @dansity, no worries, and thanks for the kind words. To be honest, it's been a long night: I redid this slice three times as the base moved under it, so one small ask going forward: a short note on #487 before an agent takes on a slice someone has claimed, and I'll do the same. That alone would have saved most of it.

Plan: one PR into feat/building-code with the fixes, each with a test, plus tests that prove the copied numbers (I ran old and new side by side: no number differs). Then I'll go through data/codes/electrical/ against the documents, and after that propose the schema for the RS/SC cooperatives as its own PR.

@ffishman

Copy link
Copy Markdown
Contributor

As promised, @dansity, here is what I found on 3d4e4ca, everything reproduced by running it.

The copied numbers are exact. I built 6809093 and 3d4e4ca side by side and compared 757k command calls (circuit, conduit_fill, dps_check, demand, building_demand, the settings listings) and 532k function lookups: no number differs. Only wording differs (CPFL's source text, error messages), plus two small behaviour changes: soil: 0 is now taken as 2.5 instead of refused, and a lowercase cpfl is now accepted.

What goes wrong is in using the data across operations. A property test (5,000 random sequences of building_code, amend, save/delete, export/import and the settings commands, each step checked) turned up these root causes:

  1. NBR 5410 can't be re-imported. circuits.default_method is the text "7"; xml.rs:92 writes it as value="7" and value_of reads it back as a number, so set nbr-5410 → export → import is refused ("invalid type: integer 7, expected a string").
  2. Import drops rules the section's first library code lacks (xml.rs known()). A user's own voltage, system or wire type, NEC's 277/480 V, ITC-BT-10's premises and so on come back in left_out and are lost.
  3. Two amendments holding the same section are merged rule by rule (codes.rs layered). With [cemig, fecoergs], building_demand {utility: FECOERGS} returns Cemig's 175 A entrance with no change made; [celesc, hidropan] gives Hidropan Celesc's 125 A. Same root for demand: with ["cpfl","enel"], a change in CPFL's amendment is ignored unless CPFL is last, and amend cpfl with method: null makes CPFL answer with Celesc's table.
  4. Deleting an own base the project uses (command.rs:335-357) lays the kept rules over the first library code of each section (Celesc), so Hidropan suddenly answers 77.3 with Celesc's common areas.
  5. set naming the default base already in force (command.rs:253) drops the amendments and their changes without saying so.
  6. Electrical Settings and the codes drift apart (electrical.rs from_codes): an entry set to null or dropped by a code stays in the model, deleted wire types come back on import, renaming a voltage updates the model's systems but not the code's, and a system naming a voltage nobody has is accepted but never reaches the model.

My PR into feat/building-code will fix 1 and 2 (done, with a test each), and 3 for demand, building_demand and entrance: a utility's section answers as that utility's own, whatever else is layered. 4 to 6 are in the engine and the settings you just built, so your call: I can send fixes for them too, with tests, or leave them to you. The property test comes with the PR either way, so the next change to the engine gets checked the same way.

@dansity

dansity commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

@ffishman i prefer if you fix everything up to your standard. later i will do my best to use the same values for other building codes (din, iso etc)

@ffishman

Copy link
Copy Markdown
Contributor

Quick update, @dansity: the first fixes (XML round trips, each utility answering by its own tables, a utility's tables changed in its amendment) are done and tested; the PR goes up within the hour. Causes 4–6 and the two ui-egui tests that already fail on 3d4e4ca follow in a second PR.

@ffishman

Copy link
Copy Markdown
Contributor

@dansity, the first PR is up: #502, into feat/building-code. It fixes 1 to 3 (XML round trips, each utility answering by its own tables, a utility's tables changed in its amendment), each with a test. Causes 4 to 6 and the two ui-egui tests that already fail on 3d4e4ca come next.

On "the same values for other codes": the same method, I'd say: each code's numbers from its own text, with table and page, pinned by a digest and checked against that standard's own examples, rather than carried over from another code. A property test over any code comes with the next PR.

@dansity
dansity marked this pull request as ready for review November 17, 2026 14:36
IPedrax pushed a commit that referenced this pull request Nov 18, 2026
…tables changed in its amendment

Fixes 1 to 3 of the list in #486.

- A rule that is text but reads like a number (circuits.default_method, "7")
  is written as JSON, so NBR 5410 and anything on it imports again. known()
  takes the rules of every library code holding a section, and the electrical
  settings are named by the user, so any name comes back. A utility's or a
  country's method is imported as the file has it, never completed from
  another utility's.
- unit_demand, building_demand and entrance are a utility's method whole
  (codes::WHOLE): an amendment holding one replaces the one under it instead
  of being merged rule by rule. demand, building_demand and entrance read each
  chosen amendment's own section (Model::held_wholes), so a change in CPFL's
  amendment counts wherever it stands and CPFL never answers by Celesc's table.
- A project-level change to one of those sections is refused, pointing at
  `amend`: it would belong to no utility once another is chosen.
- A collapsible `if` in the circuit's breaker, for clippy.

Tests: six new, each seen failing on 3d4e4ca and passing here.
IPedrax pushed a commit that referenced this pull request Nov 18, 2026
…lectrical settings in step with the codes

Fixes 4 to 6 of the list in #486, and the two ui-egui tests failing on 3d4e4ca.

- A code of the project's own holding a utility's or a country's method
  can't be deleted while the project is held to it; other codes keep
  their rules as before.
- `set` naming the base in force (the default included) keeps the
  amendments and their changes.
- from_codes follows the codes: null takes an entry away, one no longer
  named goes back to the starter's or away, unless an element names it.
  A starter entry taken away is written as null; renaming a voltage
  renames it in the code's systems; a system naming a voltage the
  project wouldn't have, or a null over a setting an element names, is
  refused. `amend` takes a setting away whoever had it.
- An amendment's few settings are laid over the library's others.
- The codes dialog flattens objects inside rows to any depth; a new
  voltage's band follows its nominal while still the default.
- The property test of #486 goes in as crates/core/tests/property.rs
  (200 sequences under cargo test).
IPedrax added a commit that referenced this pull request Nov 18, 2026
…its as its Tabela 4 prints it (ffishman)

The head of #511 carries the whole chain under it: dansity's five-discipline Building Codes engine (#486) and ffishman's #502, #506 and #509 on top of it, then the Hidropan rows. Joined onto main, the sections engine replaces main's building-codes.json and its electrical part, since a utility is now an amendment and a country a base code of the electrical discipline: main's `electrical`, `country` and `Model::electrical_methods` are gone, `building_code {electrical}` is refused with a message saying where the methods went, and `demand` takes the project's utility when none is named, as `building_demand` already did. Main's stair fixes (solve capped at 200 risers, the IBC numbers marked unchecked, the test module the hostile sweep reads) and #484's per-member tables (`members`, Energisa's Tabela 16, its test) are carried onto the new files. EN 1992-1-1 stays a second standard of `reinforce {check}` beside the structural code's Concrete section. FORMAT 21's note and the 20 to 21 comment in `migrate` describe `codes`. The catalogs are the union of both sides, for the round's one regeneration.
IPedrax added a commit that referenced this pull request Nov 18, 2026
…dards, Hidropan's diversity (dansity, ffishman)

Joins the codes-chain branch. #511's head holds #486's engine (five disciplines, layered codes and amendments, 29 code files under
data/codes/, the dialog's five tabs) and ffishman's fixes on top (XML round trips, a held code's method on the base in force, the electrical
numbers checked against their standards, Hidropan's diversity factor for 2 to 9 units). The engine replaces the electrical part of yesterday's
codes (electrical_methods, the Electrical Demand tab): the same methods now come through an amendment or a base code, and `demand` and
`building_demand` default to the code the project is held to. No conflict with the other joins of the round in code; the root CLAUDE.md is
trimmed under its 3,000 words, and the catalogs are regenerated on CI after this merge.
IPedrax added a commit that referenced this pull request Nov 18, 2026
cargo i18n update on CI over the whole third round, with #486's codes dialog and the engine's messages: the .pot files are what the extractor
makes, each .po keeps its translations, line references renewed.
@IPedrax
IPedrax merged commit 3d4e4ca into main Nov 18, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in BIMCraft Nov 18, 2026
rosaldo pushed a commit to rosaldo/BIMCraft that referenced this pull request Nov 18, 2026
The file-marking test reads a command's documented keys, and IPedrax#486's building_code lists save?: name (the name its rules in force are kept
under, as an own code of the project's). Like a stair's path, it is not a file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants