Skip to content

Commit c75d8f3

Browse files
committed
fix status message behaviour and reset
1 parent 783dbbc commit c75d8f3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ def update_info(self):
252252

253253
if is_2d_view(self.current_view):
254254
self.btnAlignToView.Content = "Align with 3D View"
255-
self.clear_status_message()
255+
if last_view != self.current_view.Id:
256+
self.clear_status_message()
257+
256258
elif isinstance(self.current_view, DB.View3D):
257259
self.btnAlignToView.Content = "Align with 2D View"
258260
if last_view != self.current_view.Id:
@@ -320,7 +322,7 @@ def show_status_message(self, column, message, message_type="info"):
320322
Args:
321323
column: 1 (Vertical), 2 (Grid), 3 (Expand/Actions)
322324
message: Text to display
323-
message_type: "info", "error", "warning" (for color coding)
325+
message_type: "info", "error", "warning", "success" (for color coding)
324326
"""
325327
try:
326328
# Define color mapping
@@ -852,7 +854,7 @@ def do_align_to_2d_view(self, params):
852854
if is_section:
853855
if not crop_box:
854856
self.show_status_message(
855-
1, "Could not get crop box from section.", "error"
857+
3, "Could not get crop box from section.", "error"
856858
)
857859
return
858860
new_box = to_world_identity(crop_box)
@@ -869,7 +871,7 @@ def do_align_to_2d_view(self, params):
869871
elements = revit.query.get_all_elements_in_view(source_view)
870872
if not elements:
871873
self.show_status_message(
872-
1, "No cropbox or elements found to extend scopebox to", "error"
874+
3, "No cropbox or elements found to extend scopebox to", "error"
873875
)
874876
return
875877
boxes = [b for b in [el.get_BoundingBox(source_view) for el in elements] if b]
@@ -899,7 +901,7 @@ def do_align_to_2d_view(self, params):
899901
with revit.Transaction("Align to View"):
900902
self.current_view.SetSectionBox(new_box)
901903
self.show_status_message(
902-
1,
904+
3,
903905
"Section box aligned to view '{}'".format(view_data["view"].Name),
904906
"success",
905907
)
@@ -955,9 +957,14 @@ def do_align_to_3d_view(self, params):
955957
)
956958
DB.ElementTransformUtils.RotateElement(doc, crop_el.Id, axis, angle)
957959
apply_plan_viewrange_from_sectionbox(doc, self.current_view, section_box)
960+
self.show_status_message(
961+
3,
962+
"Crop box aligned to view '{}'".format(view_data["view"].Name),
963+
"success",
964+
)
958965

959966
else:
960-
self.show_status_message(1, "Unsupported view type.", "warning")
967+
self.show_status_message(3, "Unsupported view type.", "warning")
961968
return
962969

963970
def do_toggle(self):
@@ -979,7 +986,7 @@ def do_hide(self):
979986
state = "hidden" if not was_hidden else "unhidden"
980987
self.show_status_message(3, "Section box {}".format(state), "success")
981988
except Exception:
982-
self.show_status_message(3, "Error in Section box visibility", "info")
989+
self.show_status_message(3, "Error in Section box visibility", "error")
983990

984991
def do_align_to_face(self):
985992
"""Align to face"""
@@ -1279,12 +1286,13 @@ def btn_align_box_to_view_click(self, sender, e):
12791286
info = get_section_box_info(selected_view, DATAFILENAME)
12801287
section_box = info.get("box")
12811288
if not section_box:
1282-
self.show_status_message(1, "3D view has no section box.", "error")
1289+
self.show_status_message(3, "3D view has no section box.", "error")
12831290
return
12841291

12851292
view_data = {
12861293
"view_type": self.current_view.ViewType,
12871294
"section_box": section_box,
1295+
"view": self.current_view,
12881296
}
12891297
self.pending_action = {
12901298
"action": "align_to_3d_view",
@@ -1295,7 +1303,7 @@ def btn_align_box_to_view_click(self, sender, e):
12951303
return
12961304

12971305
if not view_data:
1298-
self.show_status_message(1, "Could not extract view information.", "error")
1306+
self.show_status_message(3, "Could not extract view information.", "error")
12991307
return
13001308

13011309
self.event_handler.parameters = self.pending_action
@@ -1467,14 +1475,6 @@ def chkIncludeLinks_checked(self, sender, e):
14671475
self.all_levels = get_all_levels(doc, self.chkIncludeLinks.IsChecked)
14681476
self.all_grids = get_all_grids(doc, self.chkIncludeLinks.IsChecked)
14691477
self.update_info()
1470-
# Only update status if there's no current message (i.e., status is "Ready" or empty)
1471-
if self.txtGridStatus.Text == "..." or self.txtGridStatus.Text == "-":
1472-
self.update_grid_status()
1473-
if (
1474-
self.txtExpandActionsStatus.Text == "..."
1475-
or self.txtExpandActionsStatus.Text == "-"
1476-
):
1477-
self.update_expand_actions_status()
14781478

14791479
# Grid Navigation Button Handlers
14801480

0 commit comments

Comments
 (0)