Skip to content

Commit 2bc9c2a

Browse files
committed
add view templates for comparison, warningbar for target, black format
1 parent ecedec8 commit 2bc9c2a

File tree

1 file changed

+24
-9
lines changed
  • extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit1.stack/Match.splitpushbutton/Compare Properties.pushbutton

1 file changed

+24
-9
lines changed

extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit1.stack/Match.splitpushbutton/Compare Properties.pushbutton/script.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Compare instance and type properties between two elements."""
2-
#pylint: disable=import-error,invalid-name,broad-except
2+
# pylint: disable=import-error,invalid-name,broad-except
33
from pyrevit import revit, DB
44
from pyrevit import forms
55
from pyrevit import script
@@ -106,12 +106,16 @@ def compare_props(src_element, tgt_element):
106106
title='Unique Type Properties'
107107
)
108108

109+
109110
# main
110111
# try use selected elements
111112
selected_elements = revit.get_selection().elements
112-
if len(selected_elements) == 1 and forms.alert("Use selected %s?" % ("view"
113-
if isinstance(selected_elements[0], DB.View) else "element"),
114-
yes=True, no=True):
113+
if len(selected_elements) == 1 and forms.alert(
114+
"Use selected %s?"
115+
% ("view" if isinstance(selected_elements[0], DB.View) else "element"),
116+
yes=True,
117+
no=True,
118+
):
115119
source_element = selected_elements[0]
116120
target_type = "Views" if isinstance(source_element, DB.View)\
117121
else "Elements"
@@ -121,24 +125,35 @@ def compare_props(src_element, tgt_element):
121125
# some are not selectable in graphical views
122126
target_type = \
123127
forms.CommandSwitchWindow.show(
124-
["Elements", "Views"],
128+
["Elements", "Views", "View Templates"],
125129
message="Pick type of targets:")
126130

127131
# determine source element
128132
if target_type == "Elements":
129-
with forms.WarningBar(title="Pick source object:"):
130-
source_element = revit.pick_element()
133+
with forms.WarningBar(title="Pick source element:"):
134+
source_element = revit.pick_element(message="Pick source element:")
131135
elif target_type == "Views":
132136
source_element = \
133137
forms.select_views(title="Select Source View", multiple=False)
138+
elif target_type == "View Templates":
139+
source_element = \
140+
forms.select_viewtemplates(title="Select Source View Template", multiple=False)
134141

135142
# grab parameters from source element
136143
if source_element:
137144
target_element = None
145+
146+
def exclude_source(el):
147+
return el.Id != source_element.Id
148+
138149
if target_type == "Elements":
139-
target_element = revit.pick_element(message="Pick target element:")
150+
with forms.WarningBar(title="Pick target object:"):
151+
target_element = revit.pick_element(message="Pick target element:")
140152
elif target_type == "Views":
141153
target_element = \
142-
forms.select_views(title="Select Target View", multiple=False)
154+
forms.select_views(title="Select Target View", multiple=False, filterfunc=exclude_source)
155+
elif target_type == "View Templates":
156+
target_element = \
157+
forms.select_viewtemplates(title="Select Target View Template", multiple=False, filterfunc=exclude_source)
143158
if target_element:
144159
compare_props(source_element, target_element)

0 commit comments

Comments
 (0)