Skip to content

Commit 9d43e7c

Browse files
committed
implement new functions available in lib
1 parent 0adabeb commit 9d43e7c

File tree

1 file changed

+2
-24
lines changed
  • extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/3D.pulldown/Measure.pushbutton

1 file changed

+2
-24
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/3D.pulldown/Measure.pushbutton/script.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from math import pi, atan, sqrt
44
from pyrevit import HOST_APP, revit, forms, script
55
from pyrevit import UI, DB
6-
from pyrevit.framework import System
76
from Autodesk.Revit.Exceptions import InvalidOperationException
87

98
logger = script.get_logger()
@@ -42,8 +41,6 @@
4241
LINE_COLOR_DIAG = DB.ColorWithTransparency(200, 200, 0, 0) # Dark Yellow
4342
CUBE_COLOR = DB.ColorWithTransparency(255, 165, 0, 50) # Orange
4443

45-
WINDOW_POSITION = "measure_window_pos"
46-
4744

4845
def calculate_distances(point1, point2):
4946
"""Calculate dx, dy, dz, diagonal distance, and slope angle between two points.
@@ -306,24 +303,7 @@ def __init__(self, xaml_file_name):
306303

307304
# Handle window close event
308305
self.Closed += self.window_closed
309-
310-
try:
311-
pos = script.load_data(WINDOW_POSITION, this_project=False)
312-
all_bounds = [s.WorkingArea for s in System.Windows.Forms.Screen.AllScreens]
313-
x, y = pos["Left"], pos["Top"]
314-
visible = any(
315-
(b.Left <= x <= b.Right and b.Top <= y <= b.Bottom) for b in all_bounds
316-
)
317-
if not visible:
318-
raise Exception
319-
self.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual
320-
self.Left = pos.get("Left", 200)
321-
self.Top = pos.get("Top", 150)
322-
except Exception:
323-
self.WindowStartupLocation = (
324-
System.Windows.WindowStartupLocation.CenterScreen
325-
)
326-
306+
script.restore_window_position(self)
327307
self.Show()
328308

329309
# Automatically start the first measurement
@@ -332,9 +312,7 @@ def __init__(self, xaml_file_name):
332312
def window_closed(self, sender, args):
333313
"""Handle window close event - copy history to clipboard, cleanup DC3D server and visual aids."""
334314
global dc3d_server
335-
new_pos = {"Left": self.Left, "Top": self.Top}
336-
script.store_data(WINDOW_POSITION, new_pos, this_project=False)
337-
315+
script.save_window_position(self)
338316
# Copy measurement history to clipboard before cleanup
339317
try:
340318
if measurement_history:

0 commit comments

Comments
 (0)