FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rectangle mode for the polyline slab, wall and profile tools (closes #9326) by theoryshaw · Pull Request #9327 · IfcOpenShell/IfcOpenShell · GitHub

Rectangle mode for the polyline slab, wall and profile tools (closes #9326) - #9327

Open
theoryshaw wants to merge 2 commits into
IfcOpenShell:v0.8.0from
theoryshaw:polyline_rectangle_mode_9326
Open

Rectangle mode for the polyline slab, wall and profile tools (closes #9326)#9327
theoryshaw wants to merge 2 commits into
IfcOpenShell:v0.8.0from
theoryshaw:polyline_rectangle_mode_9326

Conversation

Copy link
Copy Markdown
Member

Closes #9326.

Adds a rectangle mode to the three polyline insertion tools. Press R while the tool is running to toggle it, then pick two opposite corners — the second pick completes the shape, so a rectangular slab is two clicks instead of four plus a confirmation.

Tool Result
bim.draw_polyline_slab one slab with a rectangular footprint
bim.draw_polyline_wall 4 walls, joined into a loop
bim.draw_polyline_profile 4 members, joined into a closed frame

The status bar shows Rectangle: ON/OFF, the mode is remembered between invocations so a series of rectangles doesn't need R every time, Backspace restarts the rectangle and Esc cancels the tool. Typed input still works: the distance/angle and X/Y inputs place the opposite corner, so an exact rectangle can be typed rather than drawn.

Implementation notes

The provisional corners are written into insertion_polyline itself, with the first corner repeated at the end so the shape reads as closed. That is what lets the existing ProductDecorator preview, the per-side dimension labels and the total length keep working without any decorator changes, and it means walls and profiles are generated and joined by the same code path as closing a polyline by hand.

Because the polyline then holds more than one point while the second corner is still being picked, calculate_distance_and_angle and calculate_x_y_and_z skip their "second to last point" reference when rectangle_mode is set, so typed distance and angle stay relative to the first corner.

Two details worth a look during review:

  • The rectangle spans the two axes of the tool's active plane, defaulting to a plane parallel to XY. The profile tool can draw on XZ and YZ and can pick points anywhere in space, so the coordinate of the axis the rectangle doesn't span always comes from the first corner, keeping the shape planar. It also follows the active custom transform orientation, so rectangles can be drawn square to a rotated grid.
  • Increment snapping rounds the two sides of the rectangle rather than the diagonal running to the cursor. Rounding the diagonal produces sizes like 3.13 x 4.79, which defeats the purpose.

The shared modal flow lives in PolylineOperator.handle_rectangle_drawing, which finishes the shape through a finish method each of the three operators implements. Each modal gained three lines: the toggle, the instruction and status entries, and the handler call.

Testing

  • 7 new cases in test/tool/test_polyline.py covering the corner math, the XZ/YZ planes, the planarity rule, snapping the sides, and rebuilding the preview in place (12 pass in the file).
  • Three tests in the event-simulating modal harness, make test-modal MODULE=rectangle, driving each of the three tools through real events: slab footprint rectangular, 4 walls at 4 corners, 4 coplanar beams.

theoryshaw and others added 2 commits August 18, 2026 07:47
Press R while drawing a slab to switch between the free form polyline and
a rectangle defined by two opposite corners. Picking the second corner
creates the slab, so a rectangular slab takes two clicks.

The provisional corners are written to the insertion polyline itself (with
the first corner repeated to close the shape), so the slab preview, the
side dimensions and the total length keep working as they are, and the
distance/angle/coordinate inputs stay relative to the first corner.

The rectangle is aligned to the custom transform orientation when there is
one, and increment snapping rounds the sides of the rectangle instead of
the diagonal that goes to the mouse, so rectangles drawn with the mouse
get round dimensions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The modal handling is now shared by `PolylineOperator.handle_rectangle_drawing`,
which finishes the shape through a `finish` method that each of the three
operators implements.

Walls and profiles are generated from the 4 segments of the rectangle and, as
the shape is closed, they are joined into a loop, the same as closing a polyline
by hand.

The rectangle is now built on the plane the tool is working on, since the
profile tool can draw on XZ and YZ as well, and it always takes the coordinate
of the axis it doesn't span from the first corner, so a rectangle stays planar
even when the profile tool picks two corners that aren't.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL