Skip to content

Commit f368bbd

Browse files
committed
Fix typos, enhance grid handling, and improve checkbox functionality in Section Box Navigator. Added error handling for grid types and updated UI to refresh levels and grids based on checkbox state.
1 parent d4e5f2f commit f368bbd

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@
237237
<CheckBox x:Name="chkAutoupdate" Content="Autoupdate UI on Events"
238238
Margin="5" IsChecked="True"/>
239239
<CheckBox x:Name="chkIncludeLinks" Content="Include Linked Levels and Grids"
240-
Margin="5" IsChecked="False"/>
240+
Margin="5" IsChecked="False"
241+
Checked="chkIncludeLinks_checked" Unchecked="chkIncludeLinks_checked"/>
241242
</StackPanel>
242243
</GroupBox>
243244

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def create_adjusted_box(
114114
max_point.Z + max_z,
115115
)
116116

117-
# Validate dimesions
117+
# Validate dimensions
118118
if new_max.X <= new_min.X or new_max.Y <= new_min.Y or new_max.Z <= new_min.Z:
119119
return None
120120

@@ -1120,6 +1120,12 @@ def btn_refresh_click(self, sender, e):
11201120
self.all_grids = get_all_grids(doc, self.chkIncludeLinks.IsChecked)
11211121
self.update_info()
11221122

1123+
def chkIncludeLinks_checked(self, sender, e):
1124+
"""Refresh levels and grids when checkbox is toggled."""
1125+
self.all_levels = get_all_levels(doc, self.chkIncludeLinks.IsChecked)
1126+
self.all_grids = get_all_grids(doc, self.chkIncludeLinks.IsChecked)
1127+
self.update_info()
1128+
11231129
# Grid Navigation Button Handlers
11241130

11251131
def btn_grid_west_out_click(self, sender, e):
@@ -1242,7 +1248,10 @@ def form_closed(self, sender, args):
12421248
if not isinstance(active_view, DB.View3D) or not active_view.IsSectionBoxActive:
12431249
try:
12441250
view_boxes = script.load_data(DATAFILENAME)
1245-
bbox_data = view_boxes[get_elementid_value(active_view.Id)]
1251+
view_id_value = get_elementid_value(active_view.Id)
1252+
if view_id_value not in view_boxes:
1253+
raise KeyError("View not found in stored boxes")
1254+
bbox_data = view_boxes[view_id_value]
12461255
restored_bbox = revit.deserialize(bbox_data)
12471256

12481257
# Ask user if they want to restore

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,18 @@ def find_next_grid_in_direction(start_point, direction_vector, grids, tolerance)
143143
ray = DB.Line.CreateUnbound(start_point_flat, direction_vector)
144144

145145
for grid in grids:
146-
curve = grid.Curve
147-
if not isinstance(curve, DB.Line):
146+
try:
147+
# Handle both regular Grid and LinkedGrid objects / Exception on multi segment grids
148+
if hasattr(grid, 'Curve'):
149+
curve = grid.Curve
150+
elif hasattr(grid, 'Element'):
151+
curve = grid.Element.Curve
152+
else:
153+
curve = grid.Curve # Regular DB.Grid
154+
155+
if not curve or not isinstance(curve, DB.Line):
156+
continue
157+
except (AttributeError, Exception):
148158
continue
149159

150160
# Flatten grid line to XY

0 commit comments

Comments
 (0)