-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetLoadedFamilyPaths.py
More file actions
144 lines (126 loc) · 4.18 KB
/
getLoadedFamilyPaths.py
File metadata and controls
144 lines (126 loc) · 4.18 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'''
Next stages to add the ability to move families across to the project library and re-path the familes loaded.
#
#1. Find a family that is loaded from another project
#2. Edit the family
#3. Save the family to the current/local project library
#3.01 - Check if the directory exists for the Family Category
#3.02 - If not create the directory
#4. Capture the path and close the file
#5. Reload from the captured Path into project and close
'''
#---------------------------------------------#
def getProjectPath():
s = ''
if not(doc.IsDetached):
mp = doc.GetWorksharingCentralModelPath()
s = ModelPathUtils.ConvertModelPathToUserVisiblePath(mp)
s.Substring(0,18)
return s
#---------------------------------------------#
def getProjectFromPath(thePath):
if ':' == thePath[1]:
result = thePath.Substring((thePath.IndexOf('\\',(thePath.IndexOf('\\')+1))+1),12)
else:
if '\\' == thePath.Substring(0,1):
result = thePath.Substring(1,(thePath.IndexOf('\\',1)-1))
else:
result = ''
return result
#---------------------------------------------#
def getFamilyPath(f):
global FamiliesBadNews
if isinstance(f,Family):
fam = f
#print 'Family'
else:
if isinstance(f,FamilySymbol):
fam = f.Family
#print 'Symbol'
else:
if isinstance(f,FamilyInstance):
fam = f.Symbol.Family
#print 'FamilyInstance'
else:
fam = None
if None != fam:
try:
famdoc = f.Document.EditFamily(fam)
thePath = famdoc.PathName
famdoc.Close(False)
except:
thePath = ''
try:
FamiliesBadNews.append(f.Category.Name + '|' + f.Name)
except AttributeError:
FamiliesBadNews.append(f.Name)
pass
pass
else:
thePath = '...'
return thePath
#---------------------------------------------#
FamiliesInPlace = []
FamiliesLoadedOK = []
FamiliesOrphaned = []
FamiliesWrongProject = []
FamiliesNotEditable = []
FamiliesBadNews = []
FamiliesCentral = []
MasterContent = '\\dc2-file001\\practice\\InfoTech\\BIM\\Revit\\RevitStandardsMasterBVN\\02_BVN_Library\\Master Content'
ProjectPath = getProjectPath()
proj = getProjectFromPath(ProjectPath)
fec = FilteredElementCollector(doc).OfClass(Family)
counter = 0
for f in fec:
#print '-' * 75
s = ''
thePath = ''
counter = counter + 1
s = f.FamilyCategory.Name + '\t' + f.Name + '\t' + thePath
if f.IsInPlace:
FamiliesInPlace.append(s)
else:
if f.IsEditable:
thePath = getFamilyPath(f)
print thePath
if '' == thePath:
FamiliesOrphaned.append(s)
else:
if proj == getProjectFromPath(thePath):
FamiliesLoadedOK.append(s)
else:
print 'Current Family: ' + thePath
print getProjectFromPath(thePath)
s = f.FamilyCategory.Name + '\t' + f.Name + '\t' + getProjectFromPath(thePath) + '\t' + thePath
if MasterContent.ToLower() in thePath.ToLower():
FamiliesCentral.append(s)
else:
FamiliesWrongProject.append(s)
else:
FamiliesNotEditable.append(f.Name)
print '-_' * 50
print 'There are ' + str(FamiliesNotEditable.Count) + 'None Editable Families in the project'
for f in FamiliesNotEditable: print f
print '-' * 40
print 'There are ' + str(FamiliesInPlace.Count) + ' In Place Families in the project'
for f in FamiliesInPlace: print f
print '-' * 40
print 'There are ' + str(FamiliesCentral.Count) + ' Families Loaded from Master Content'
print '-' * 40
print 'There are ' + str(FamiliesLoadedOK.Count) + ' Families Loaded from within the project number: ' + getProjectFromPath(ProjectPath)
print '-' * 40
print 'There are ' + str(FamiliesOrphaned.Count) + ' Orphaned Families in the Model.'
for f in FamiliesOrphaned: print f
print '-!_' * 50
print 'There are ' + str(FamiliesWrongProject.Count) + ' Families Loaded from other Projects as follows:'
print 'Category\tFamilyName\tProjectNumber\tFilePath'
for f in FamiliesWrongProject: print f
print '-' * 40
print 'The following Families need looking at for potential corruption'
for f in FamiliesBadNews: print f
print '-!_' * 50
#print str(counter)
#print f.FamilyCategory.Name
#print f.Name
#print thePath