Skip to content

Bonsai: preview drawing SVG in camera viewport - #9472

Open
franklincg wants to merge 2 commits into
IfcOpenShell:v0.9.0from
franklincg:money-agent-6422-svg-overlay
Open

franklincg wants to merge 2 commits into
IfcOpenShell:v0.9.0from
franklincg:money-agent-6422-svg-overlay

Conversation

@franklincg

@franklincg franklincg commented Sep 10, 2026

Copy link
Copy Markdown

Summary

This is a focused first slice for #6422. It adds an opt-in Generated SVG Overlay in the Drawings panel that reads the final combined drawing SVG and previews its straight-line publication styling directly in the active orthographic drawing camera viewport.

The overlay:

  • reuses the already-generated final SVG; it does not add a second renderer or change the SVG generation pipeline;
  • parses a bounded SVG/CSS subset for straight paths, lines, polylines/polygons, class/tag selectors, stroke color/width/opacity, and dash arrays;
  • maps paper SVG coordinates back to the drawing camera plane and draws through Blender's POST_VIEW GPU path;
  • caches parsed geometry and refreshes after Create Drawing;
  • is opt-in, camera-only, and degrades safely when the final SVG is missing or contains unsupported features.

This PR deliberately does not attempt the complete publication preview yet. Fills, text, curves, transforms, clipping, markers/patterns, and paint servers remain outside this first bounded slice. In particular, cut/fill-color fidelity still needs a follow-up slice if this direction is accepted.

Testing

  • Focused SVG parser/mapping tests: 17 passed + 11 subtests passed, including regression coverage for opacity="inherit".
  • Python compile checks passed for all 8 touched/new Python files.
  • Isolated Blender 4.5.4 handler/camera-gating/cache/refresh smoke checks passed.
  • Black, Ruff, and git diff --check passed.
  • Full Bonsai suite could not be collected locally because pytest-blender is unavailable.

Visual evidence

A local Windows visual harness used Blender 4.5.4 LTS with Bonsai 0.8.5-post1 and minimal integration adaptations for that older Bonsai API. The overlay/parser logic from this PR was used against a Bonsai-generated PLAN_VIEW.svg. These screenshots validate the stroke-overlay slice only, not fills/text/patterns or full print fidelity.

AI assistance

OpenAI Codex was used to investigate, implement, test, and review this change. I reviewed the resulting patch and take responsibility for the contribution. New AI-generated files contain the repository-required disclosure.

Refs #6422

Add an opt-in vector overlay for the final generated drawing SVG, with cached straight-line parsing and camera-plane mapping. Refresh the overlay after drawing generation and cover the pure SVG logic with focused tests.

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.

1 participant