Skip to content

Commit d41fbd4

Browse files
committed
added all attributes, simplified using gettattr
1 parent c02c729 commit d41fbd4

File tree

1 file changed

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

1 file changed

+46
-41
lines changed

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

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -83,53 +83,58 @@ def compare_view_filters(view1, view2):
8383
differences = []
8484

8585
# Compare properties of OverrideGraphicSettings
86-
# Colors
87-
c1 = ov1.ProjectionLineColor
88-
c2 = ov2.ProjectionLineColor
89-
if c1.IsValid and c2.IsValid:
90-
if c1.Red != c2.Red or c1.Green != c2.Green or c1.Blue != c2.Blue:
91-
differences.append("ProjectionLineColor")
92-
elif c1.IsValid != c2.IsValid:
93-
differences.append("ProjectionLineColor")
94-
95-
c1 = ov1.SurfaceForegroundPatternColor
96-
c2 = ov2.SurfaceForegroundPatternColor
97-
if c1.IsValid and c2.IsValid:
98-
if c1.Red != c2.Red or c1.Green != c2.Green or c1.Blue != c2.Blue:
99-
differences.append("SurfaceColor")
100-
elif c1.IsValid != c2.IsValid:
101-
differences.append("SurfaceColor")
102-
103-
c1 = ov1.CutLineColor
104-
c2 = ov2.CutLineColor
105-
if c1.IsValid and c2.IsValid:
106-
if c1.Red != c2.Red or c1.Green != c2.Green or c1.Blue != c2.Blue:
107-
differences.append("CutLineColor")
108-
elif c1.IsValid != c2.IsValid:
109-
differences.append("CutLineColor")
110-
111-
c1 = ov1.CutBackgroundPatternColor
112-
c2 = ov2.CutBackgroundPatternColor
113-
if c1.IsValid and c2.IsValid:
114-
if c1.Red != c2.Red or c1.Green != c2.Green or c1.Blue != c2.Blue:
115-
differences.append("CutBackgroundPatternColor")
116-
elif c1.IsValid != c2.IsValid:
117-
differences.append("CutBackgroundPatternColor")
118-
119-
# Not checking pattern or linestyle overrides because I'm lazy
120-
121-
# Other appearance stuff
122-
if ov1.Transparency != ov2.Transparency:
123-
differences.append("Transparency")
124-
if ov1.Halftone != ov2.Halftone:
125-
differences.append("Halftone")
86+
ov_attrs = [
87+
# Colors
88+
"ProjectionLineColor",
89+
"SurfaceForegroundPatternColor",
90+
"SurfaceBackgroundPatternColor",
91+
"CutLineColor",
92+
"CutForegroundPatternColor",
93+
"CutBackgroundPatternColor",
94+
95+
# Pattern IDs
96+
"SurfaceForegroundPatternId",
97+
"SurfaceBackgroundPatternId",
98+
"CutForegroundPatternId",
99+
"CutBackgroundPatternId",
100+
"ProjectionLinePatternId",
101+
"CutLinePatternId",
102+
103+
# Line weights
104+
"ProjectionLineWeight",
105+
"CutLineWeight",
106+
107+
# Visibility flags
108+
"IsSurfaceForegroundPatternVisible",
109+
"IsSurfaceBackgroundPatternVisible",
110+
"IsCutForegroundPatternVisible",
111+
"IsCutBackgroundPatternVisible",
112+
113+
# Other
114+
"Transparency",
115+
"Halftone",
116+
]
117+
118+
for attr in ov_attrs:
119+
val1 = getattr(ov1, attr)
120+
val2 = getattr(ov2, attr)
121+
122+
if isinstance(val1, DB.Color):
123+
if val1.IsValid and val2.IsValid:
124+
if val1.Red != val2.Red or val1.Green != val2.Green or val1.Blue != val2.Blue:
125+
differences.append(attr)
126+
elif val1.IsValid != val2.IsValid:
127+
differences.append(attr)
128+
else:
129+
if val1 != val2:
130+
differences.append(attr)
126131

127132
# More general stuff
128133
if view1.GetIsFilterEnabled(fid1) != view2.GetIsFilterEnabled(fid2):
129134
differences.append("Enabled Status")
130135

131136
if view1.GetFilterVisibility(fid1) != view2.GetFilterVisibility(fid2):
132-
differences.append("Vsibility Status")
137+
differences.append("Visibility Status")
133138

134139
if differences:
135140
output.print_md(

0 commit comments

Comments
 (0)