-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorksetConfigExperimentation.py
More file actions
125 lines (107 loc) · 3.75 KB
/
WorksetConfigExperimentation.py
File metadata and controls
125 lines (107 loc) · 3.75 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
#------------------------------------------------------------------------#
def GetAllLinks():
theLinks = (
FilteredElementCollector(doc)
.OfCategory(BuiltInCategory.OST_RvtLinks)
#Only Link Types, NOT a Nested Link
.Where(lambda link: (RevitLinkType == type(link)) and not(link.IsNestedLink))
)
return theLinks.ToList()
#------------------------------------------------------------------------#
def GetLinkName(aLink):
#return [x.strip() for x in Element.Name.GetValue(aLink).split(':')]
return Element.Name.GetValue(aLink)
#------------------------------------------------------------------------#
def GetLinkPath(aLink):
er = aLink.GetExternalFileReference()
mp = er.GetPath()
thePath = ModelPathUtils.ConvertModelPathToUserVisiblePath(mp)
return thePath
#------------------------------------------------------------------------#
def GetLinkModelPath(aLink):
er = aLink.GetExternalFileReference()
mp = er.GetPath()
return mp
#------------------------------------------------------------------------#
def GetOpenWorksetIds(linkdoc):
#Get the Worksets
theWorksets = (
FilteredWorksetCollector(linkdoc)
.Where(lambda ws: ws.Kind == WorksetKind.UserWorkset)
)
OpenWorksets = []
for aWorkset in theWorksets:
if aWorkset.IsOpen:
OpenWorksets.Add(aWorkset.Id)
#Return the list of Ids
return OpenWorksets
#------------------------------------------------------------------------#
def GetClosedWorksetIds(linkdoc):
#Get the Worksets
theWorksets = (
FilteredWorksetCollector(linkdoc)
.Where(lambda ws: ws.Kind == WorksetKind.UserWorkset)
)
ClosedWorksets = []
for aWorkset in theWorksets:
if not(aWorkset.IsOpen):
ClosedWorksets.Add(aWorkset.Id)
#Return the list of Ids
return ClosedWorksets
#------------------------------------------------------------------------#
def worksetinfo(linkdoc):
#linkdoc = aLink.Document
#Get the Worksets
theWorksets = (
FilteredWorksetCollector(linkdoc)
.Where(lambda ws: ws.Kind == WorksetKind.UserWorkset)
)
closedWorksets = []
print linkdoc.Title
for aWorkset in theWorksets:
if aWorkset.IsOpen:
print ' [o] - ' + aWorkset.Name
else:
closedWorksets.Add(aWorkset)
print ' [-] - ' + aWorkset.Name
#------------------------------------------------------------------------#
def GetLinkedDocuments():
theDocuments = {}
for aDoc in doc.Application.Documents:
theDocuments.update({aDoc.Title: aDoc})
return theDocuments
#------------------------------------------------------------------------#
def GetLinkedWorksetStatus():
#Get the Links - Document
ldoc = aLink.Document
#Get it's Workset Table
lwst = ldoc.GetWorksetTable()
#Just as a test Get the Links Active Workset
laws = lwst.GetWorkset(lwst.GetActiveWorksetId())
#Test to see if that Workset is open
laws.IsOpen
#Read this - https://forums.autodesk.com/t5/revit-api-forum/manage-worksets-of-a-link/td-p/6412881
theWorksets = FilteredWorksetCollector(ldoc)
for aWorkset in theWorksets:
if aWorkset.Kind == WorksetKind.UserWorkset:
print aWorkset.Name
#------------------------------------------------------------------------#
theLinks = GetAllLinks()
#aLink = theLinks[0]
#mp = GetLinkModelPath(aLink)
#wsp = WorksharingUtils.GetUserWorksetInfo(mp)
#for w in wsp: print w.Name
NotWorkshared = []
theDocuments = GetLinkedDocuments()
for aLink in theLinks:
linkname = GetLinkName(aLink)
if linkname in theDocuments.Keys:
linkdoc = theDocuments[linkname]
if linkdoc.IsWorkshared:
worksetinfo(linkdoc)
else:
NotWorkshared.Add(linkdoc.Title)
if NotWorkshared.Count > 0:
print '\nThe Following Links are not workshared...!!\n'
for nws in NotWorkshared:
print nws