Skip to content

Commit 783dbbc

Browse files
committed
- fix missing transform for section view
- implement unused clear_status messages
1 parent aa3cb5c commit 783dbbc

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/3D.pulldown/Section Box Navigator.pushbutton/script.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
get_crop_element,
2323
compute_rotation_angle,
2424
apply_plan_viewrange_from_sectionbox,
25+
to_world_identity,
2526
)
2627
from sectionbox_actions import toggle, hide, align_to_face
2728
from sectionbox_geometry import (
@@ -246,12 +247,16 @@ def __init__(self, xaml_file_name):
246247
def update_info(self):
247248
"""Update the information display."""
248249
try:
250+
last_view = self.current_view.Id
249251
self.current_view = doc.ActiveView
250252

251253
if is_2d_view(self.current_view):
252254
self.btnAlignToView.Content = "Align with 3D View"
255+
self.clear_status_message()
253256
elif isinstance(self.current_view, DB.View3D):
254257
self.btnAlignToView.Content = "Align with 2D View"
258+
if last_view != self.current_view.Id:
259+
self.clear_status_message()
255260

256261
if (
257262
not isinstance(self.current_view, DB.View3D)
@@ -285,7 +290,7 @@ def update_info(self):
285290

286291
# Update top info
287292
if top_level:
288-
self.txtTopLevel.Text = "Top: Next level up: {} @ {}".format(
293+
self.txtTopLevel.Text = "Top: Above: {} @ {}".format(
289294
top_level.Name, top_level_elevation
290295
)
291296
else:
@@ -296,7 +301,7 @@ def update_info(self):
296301

297302
# Update bottom info
298303
if bottom_level:
299-
self.txtBottomLevel.Text = "Bottom: Next level down: {} @ {}".format(
304+
self.txtBottomLevel.Text = "Bottom: Below: {} @ {}".format(
300305
bottom_level.Name, bottom_level_elevation
301306
)
302307
else:
@@ -343,7 +348,7 @@ def update_ui():
343348
except Exception as ex:
344349
logger.error("Error showing status message: {}".format(ex))
345350

346-
def clear_status_message(self, column):
351+
def clear_status_message(self, column=None):
347352
"""Clear the status message for the specified column."""
348353
try:
349354

@@ -354,6 +359,10 @@ def update_ui():
354359
self.txtGridStatus.Text = ""
355360
elif column == 3:
356361
self.txtExpandActionsStatus.Text = ""
362+
elif column is None:
363+
self.txtVerticalStatus.Text = ""
364+
self.txtGridStatus.Text = ""
365+
self.txtExpandActionsStatus.Text = ""
357366

358367
self.Dispatcher.Invoke(System.Action(update_ui))
359368
except Exception as ex:
@@ -846,7 +855,7 @@ def do_align_to_2d_view(self, params):
846855
1, "Could not get crop box from section.", "error"
847856
)
848857
return
849-
new_box = crop_box
858+
new_box = to_world_identity(crop_box)
850859

851860
elif crop_box:
852861
# For floor plans, use the existing logic

extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/3D.pulldown/Section Box Navigator.pushbutton/sectionbox_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,16 @@ def lvl_z(plane):
138138
vr.SetOffset(DB.PlanViewPlane.ViewDepthPlane, depth_offset)
139139

140140
view.SetViewRange(vr)
141+
142+
143+
def to_world_identity(bbox):
144+
t = bbox.Transform
145+
146+
p1 = t.OfPoint(bbox.Min)
147+
p2 = t.OfPoint(bbox.Max)
148+
149+
new_box = DB.BoundingBoxXYZ()
150+
new_box.Transform = DB.Transform.Identity
151+
new_box.Min = DB.XYZ(min(p1.X, p2.X), min(p1.Y, p2.Y), min(p1.Z, p2.Z))
152+
new_box.Max = DB.XYZ(max(p1.X, p2.X), max(p1.Y, p2.Y), max(p1.Z, p2.Z))
153+
return new_box

0 commit comments

Comments
 (0)