ConstructCraft

Parametric steel building (sub-project 2b)

Part of the Structure tab redesign. 2a (the Structure tab by material and the grid frame) comes before it. 2b adds a parametric steel shed: portal frames, purlins and girts, generated as real columns and beams that a host element keeps in step with its parameters.

The user approved approach A (a host element owning real members) and asked me to make the remaining design decisions alone. Those decisions are recorded here.

Goals

Out of scope:

Model (cc_core::steel_building)

ElementKind::SteelBuilding(SteelBuilding):

The struct’s fields:

field meaning default bounds
origin: DVec2 plan point of the first frame’s left column   finite
rotation_deg: f64 turn of the local x axis (across the span) 0 finite
span: f64 column axis to column axis, m 20 2..=100
eave_height: f64 column top above the level, m 6 1..=50
slope_percent: f64 roof slope 10 0..=100
roof: RoofShape Gable (ridge at mid-span) or Mono (rising toward x = span) Gable  
bays: u32 frames = bays + 1 5 1..=100
bay_spacing: f64 frame to frame, m 6 1..=30
column_type, rafter_type: ElementTypeId     must be column and beam types
purlins: Option<Secondary> Secondary { type_id, spacing }, spacing along the rafter’s plan run Some, 1.5 spacing 0.3..=10
girts: Option<Secondary> on both long sides, spacing up the wall Some, 1.5 same
members: Vec<FrameMember> FrameMember { role: MemberRole, id: ElementId } empty  
detached: Vec<MemberRole> roles the user took over empty  

MemberRole is a small Copy + Ord serde struct: { kind: RoleKind, frame: u16, index: u16 }, where RoleKind is Column, Rafter, Purlin or Girt.

Layout

SteelBuilding::layout(&self, project) -> Vec<(MemberRole, ElementTypeId, ElementKind)> is deterministic. Positions are in local coordinates, x across the span and y along the building, then mapped to plan through origin and rotation. Frame k is at y = k * bay_spacing.

Section depths and widths come from Project::type_section boxes. A missing section reads as 0.2 m.

Sync (EditCtx::finish, first step)

sync_steel_buildings runs first, before the other syncs. It sees which elements the edit itself changed:

  1. Members changed or deleted in this transaction whose host did not change: their roles move to the host’s detached list, and the members entry is dropped. The element stays as the user left it.
  2. Hosts changed or added in this transaction, every role of the layout not in detached:
    • An existing member is rewritten in place, keeping its id: kind, type and level.
    • Otherwise a new element is added and recorded.
    • Members whose role is no longer in the layout are deleted.
  3. A host added in this transaction whose members ids already belong to another host (a copy) has its members cleared before step 2, so it gets its own.

Other rules:

Drawing

Engine

steel_building_create:

element_get shows the building’s parameters in params. element_set merges a patch over them. The repair check refuses out-of-range values, and the sync regenerates the members in the same step. element_get’s derived lists the member ids by role kind.

App

Testing

Decisions made while planning