Skip to content

Bonsai: draw element Axis reference lines in drawings - #8802

Open
BIMvoice wants to merge 1 commit into
v0.8.0from
bonsai-6423-axis-linework
Open

BIMvoice wants to merge 1 commit into
v0.8.0from
bonsai-6423-axis-linework

Conversation

@BIMvoice

Copy link
Copy Markdown
Contributor

Part of the OSArch-funded Drawings & Documentation Phase 1 programme. Fixes #6423 (D&D Phase 1 Item 02).

The issue asks for "an option to add custom lines to elements", with "centerlines for beams" as the headline example, and notes that today "I'm manually adding lines to get the centerlines etc to show up for every element. I think this should be automatic!"

It turns out most of this already exists. Bonsai writes an Axis representation for walls (Plan/Axis/GRAPH_VIEW) and for every profile-based member such as beams and columns (Model/Axis/GRAPH_VIEW), and the Representations panel already lets a user add and edit an Axis representation on any element. The gap was purely on the output side: CreateDrawing.get_linework_contexts only collected Body, Facetation and Annotation subcontexts, so that centreline geometry could never reach a drawing.

This collects the Axis subcontexts into a third linework bucket and, when the drawing opts in via EPset_Drawing.HasAxisLinework, projects them into the linework SVG as their own groups classed axis alongside the element's usual classes. Styling goes through the existing CSS channel, with a centreline dash pattern added to default.css. A checkbox sits next to Underlay / Linework / Annotation. The pass runs after merge_linework_and_add_metadata, which would otherwise reclassify the groups as cut/projection.

Off by default, so existing drawings are unchanged.

Test plan

Verified in headless Blender through the real operators:

  • Off by default: new drawing has no HasAxisLinework, SVG contains only projection and cut groups.
  • Toggling the property writes EPset_Drawing.HasAxisLinework = True into the IFC and round-trips through write and reopen.
  • Wall with a Plan/Axis Curve2D (authored via the real geometry.add_axis_representation API): bim.create_drawing emits <g class="IfcWall material-null axis"> with the wall's GlobalId; a 4 m axis at 1:100 came out as M230.0,250.0 L270.0,250.0, i.e. 40 mm long and centred on the 500 mm sheet.
  • Beam with a bent 3-point Model/Axis Curve3D: two correctly projected segments — the "centerlines for beams" case, confirming multi-segment and 3D axes.
  • .axis CSS rule present in the composited sheet SVG.
  • test/core/test_drawing.py 41 passed, test/tool/test_drawing.py 87 passed; black+ruff clean.

Not covered here

FREESTYLE linework mode (different SVG path), and synthesising centrelines for element classes that carry no Axis representation (slabs, doors, windows) — Bonsai never authors one for those, and deriving one is a separate design question.

The issue's "a line on an other arbitrary position" could mean per-element reference lines, per-element-type lines propagating to occurrences, or rule-driven generated lines. This adds the output channel that serves all three, and the first already works today through the Representations panel plus this change; the other two need UX decisions worth confirming with @jes-r before building.

This PR contains AI-generated code, generated with the assistance of an AI coding tool.

Bonsai already writes an Axis representation for walls (Plan/Axis/GRAPH_VIEW)
and for every profile based member such as beams and columns
(Model/Axis/GRAPH_VIEW), but CreateDrawing.get_linework_contexts only ever
collected Body, Facetation and Annotation subcontexts, so that centreline
geometry could never reach a drawing. Users were tracing centrelines by hand
as separate annotations for every element.

Collect the Axis subcontexts into a third linework bucket and, when the
drawing opts in via EPset_Drawing.HasAxisLinework, project them into the
linework SVG as their own groups classed "axis" alongside the element's usual
classes. Styling then goes through the existing CSS channel, with a
centreline dash pattern added to default.css.

The pass is off by default, so existing drawings are unchanged.

Generated with the assistance of an AI coding tool.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D&D Phase 1 Item 02 - Option to add extra lines to an (parametric) element

1 participant