-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStructuralAnalyticsOFF.py
More file actions
101 lines (90 loc) · 3.25 KB
/
StructuralAnalyticsOFF.py
File metadata and controls
101 lines (90 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#================================================================================#
# _____ __
# \_ \__ _ _ __ \ \ __ _ _ __ ___ ___ ___
# / /\/ _` | '_ \ \ \/ _` | '_ ` _ \ / _ \/ __|
# /\/ /_| (_| | | | | /\_/ / (_| | | | | | | __/\__ \
# \____/ \__,_|_| |_| \___/ \__,_|_| |_| |_|\___||___/
#
# Title: StructureAnalyticsOFF.py
#
# Description: Turns off the Boolean parameter 'Enable Analytical Model'
# for Structural Categories: Columns, Foundations & Framing
#
#
# Date: 20th January 2020
#
#================================================================================#
import time
#------------------------------------------------------------------------------------#
def processThings(theThings, thingName):
thingsSuccess = []
thingsNoParam = []
thingsFailed = []
thingsNoChange = []
i = 0
count = theThings.Count.ToString()
start = time.time()
for aThing in theThings:
i += 1
#print i.ToString() + ' of ' + count + ' ' + thingName
id = aThing.Id.ToString()
p = aThing.LookupParameter('Enable Analytical Model')
if p:
if p.AsValueString().Equals('Yes'):
#print 'Element Id [' + id + '] Changing From: ' + p.AsValueString() + ' to No/False'
tranny = Transaction(doc)
try:
tranny.Start('Switching Off analytics')
p.Set(False)
tranny.Commit()
tranny.Dispose()
thingsSuccess.append(id)
except Exception as e:
if tranny.HasStarted:
tranny.RollBack()
tranny.Dispose()
print 'Something Went Wrong'
print e.message
thingsFailed.Add(id)
else:
thingsNoChange.Add(id)
else:
thingsNoParam.Add(id)
#print "Column [" + id + "] Doesn't have the parameter"
end = time.time()
duration = end - start
print 'Results for type: ' + thingName + ' Processed in ' + duration.ToString() + ' seconds'
print '------------------------------------------'
print 'Parameters Changed : ' + thingsSuccess.Count.ToString()
print 'Failed Changes : ' + thingsFailed.Count.ToString()
print 'No Change Required : ' + thingsNoChange.Count.ToString()
print 'Parameter Not Found : ' + thingsNoParam.Count.ToString()
print '=========================================='
#------------------------------------------------------------------------------------#
def main():
#Get the Structural Columns
theColumns = (
FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_StructuralColumns)
.ToList()
)
processThings(theColumns, 'Column')
#---------------------
#Get the Structural Framing
theStructuralFraming = (
FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_StructuralFraming)
.ToList()
)
processThings(theStructuralFraming, 'Framing')
#---------------------
#Get the Structural Foundations
theStructuralFoundations = (
FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_StructuralFoundation)
.ToList()
)
processThings(theStructuralFoundations, 'Foundation')
#---------------------
#------------------------------------------------------------------------------------#
if __name__ == '__main__': main()