Skip to content

Fix: SVG Depth Ordering for Projections and Material Fills (Fix #7902)#7923

Draft
dipayansardar73-decode wants to merge 1 commit intoIfcOpenShell:v0.8.0from
dipayansardar73-decode:fix-7902-projection-depth
Draft

Fix: SVG Depth Ordering for Projections and Material Fills (Fix #7902)#7923
dipayansardar73-decode wants to merge 1 commit intoIfcOpenShell:v0.8.0from
dipayansardar73-decode:fix-7902-projection-depth

Conversation

@dipayansardar73-decode
Copy link
Copy Markdown

Fixes #7902

This PR addresses two critical Z-depth sorting bugs in the Bonsai drawing pipeline that caused projection lines to disappear behind material fills or background objects.

Changes:

  1. Preserved Inter-Projection Depth Sorting: move_projection_to_bottom previously pushed all projections to absolute index 0 sequentially, which effectively reversed the background-to-foreground sorting order originally established by IfcConvert. By using enumerate(projections) and inserting at i, the intended depth sorting is perfectly maintained.
    1. Fixed Fill vs. Outline Occlusion: generate_material_layers previously appended the solid grey cut fills to the absolute end of the SVG group. In standard SVG drawing order, this forced fills to render on top of both the projection lines AND the thick foreground cut outlines. The logic now leverages el.addprevious(g) to strictly insert the material fill intimately beneath its corresponding cut outline group.
      These changes ensure all deck joists, low walls, and overlapping elements render correctly without losing their visual boundaries to hatch occlusion.

 IfcOpenShell#7902)

Two critical fixes for SVG depth ordering in the drawing pipeline:

1. `move_projection_to_bottom` previously reversed the depth order of all background projections by repeatedly inserting at index 0. Replaced with `enumerate` to preserve the proper Z-depth sorting intended by the C++ engine.
2. `generate_material_layers` previously appended cut hatch fills to the absolute end of the SVG group, forcing them to render on top of both projections and cut outlines. Replaced with `el.addprevious(g)` to place the fill properly beneath its respective cut outline.
@theoryshaw theoryshaw marked this pull request as draft April 9, 2026 14:48
@theoryshaw
Copy link
Copy Markdown
Member

Got the following error when trying bim.create_drawing,
test file: https://hub.openingdesign.com/OpeningDesign/3_Season_Porch_URGC/src/commit/7f27c30c5d32e821d442a33898132c22babe11e7/Open/Models/Bonsai

Converting this to a 'draft' so it doesn't get pushed to the BleedingEdge build.

Python: Traceback (most recent call last):
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\operator.py", line 397, in execute
    annotation_svg = self.generate_annotation(context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\operator.py", line 1694, in generate_annotation
    self.svg_writer.create_blank_svg(svg_path).draw_annotations(annotations, precision, decimal_places).save()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\svgwriter.py", line 375, in draw_annotations
    self.draw_section_annotation(obj)
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\svgwriter.py", line 849, in draw_section_annotation
    reference_id, sheet_id = self.get_reference_and_sheet_id_from_annotation(tool.Ifc.get_entity(obj))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\bim\module\drawing\svgwriter.py", line 898, in get_reference_and_sheet_id_from_annotation
    reference = tool.Drawing.get_drawing_reference(drawing)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ryan Schultz\AppData\Roaming\Blender Foundation\Blender\4.5\extensions\.local\lib\python3.11\site-packages\bonsai\tool\drawing.py", line 2358, in get_drawing_reference
    for rel in drawing.HasAssociations:
               ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'HasAssociations'

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.

Projection line doesn't show

2 participants