-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDetailItemInventory.py
More file actions
55 lines (48 loc) · 1.93 KB
/
DetailItemInventory.py
File metadata and controls
55 lines (48 loc) · 1.93 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
#========================================================================#
# _____ __
# \_ \__ _ _ __ \ \ __ _ _ __ ___ ___ ___
# / /\/ _` | '_ \ \ \/ _` | '_ ` _ \ / _ \/ __|
# /\/ /_| (_| | | | | /\_/ / (_| | | | | | | __/\__ \
# \____/ \__,_|_| |_| \___/ \__,_|_| |_| |_|\___||___/
#
#
# The Script identifies Detail Items and lists
# - Families
# - Types
# - Instance counts of each type
#
#
# Nov 2020
#
#========================================================================#
PrintToExcel = False
def PrintResultsToExcel(families):
pass
#Function to be written here to parse results out to Excel.
theDetailItemFamilies = (
FilteredElementCollector(doc)
.WherePasses(ElementClassFilter(FamilySymbol))
.WherePasses(ElementCategoryFilter(BuiltInCategory.OST_DetailComponents))
.GroupBy(lambda e: e.Family.Name)
#.OrderBy(lambda e: e.Family.Name)
.ToDictionary(lambda e: e.Key, lambda e: e.ToList())
)
for aDetailItemFamily in sorted(theDetailItemFamilies):
#Grab The Family Name
FamName = aDetailItemFamily.Key
print '+---' + '-'*50 + '-+-' + '-' *6 + '-+'
print '| ' + FamName.ljust(56+5) + ' |'
print '+---' + '-'*50 + '-+-' + '-' *6 + '-+'
#The Grab each Family Type Name
for adi in theDetailItemFamilies[aDetailItemFamily.Key]:
FamTypeName = Element.Name.GetValue(adi)
#Then check to see how many instances of each type are placed in the model.
theFamilyInstances = (
FilteredElementCollector(doc)
.WherePasses(ElementClassFilter(FamilyInstance))
.WherePasses(ElementCategoryFilter(BuiltInCategory.OST_DetailComponents))
.Where(lambda f: Element.Name.GetValue(f.Symbol) == Element.Name.GetValue(adi))
)
FamTypeCount = theFamilyInstances.Count().ToString()
print '| - ' + FamTypeName.ljust(50) + ' | ' + FamTypeCount.rjust(6) + ' |'
print '+---' + '-'*50 + '-+-' + '-' *6 + '-+'