-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAudit GetCADLinkswithFileSize.py
More file actions
60 lines (47 loc) · 1.92 KB
/
Audit GetCADLinkswithFileSize.py
File metadata and controls
60 lines (47 loc) · 1.92 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
import os
#-------------------------------------------------------------------------
def extRefToPath(link):
extref = transData.GetLastSavedReferenceData(aLink)
path = ModelPathUtils.ConvertModelPathToUserVisiblePath(extref.GetPath())
return path
#-------------------------------------------------------------------------
# Get the Model Path of the Current Document
mp = doc.GetWorksharingCentralModelPath()
# Then convert that Model Path to a Human Readable format
path = ModelPathUtils.ConvertModelPathToUserVisiblePath(mp)
# Get the TransmissionData from the current Document
transData = TransmissionData.ReadTransmissionData(mp)
# Grab all of the External File References from the
# current Documents Transmission Data
linkIDs = transData.GetAllExternalFileReferenceIds()
separator = '+-----+----------------------------------------------------+----------+'
totalsize = 0.0
count = 0
CADLinks = []
#Loop through all of the CAD Links and get the information
for aLink in linkIDs:
theName = Element.Name.GetValue(doc.GetElement(aLink))
if theName.EndsWith('.dwg'):
thePath = extRefToPath(aLink)
if os.path.exists(thePath):
theSize = os.path.getsize(thePath) / (1024.0 * 1024.0)
# Add the dwg link to the new list
CADLinks.Add([thePath,theName,theSize])
# Add the size to the total
totalsize += theSize
print len(CADLinks)
# Now loop through the derived list of CAD Links and print them out
for aLink in CADLinks:
count += 1
strCount = "{:03d}".format(count)
strSize = "{:.3f}".format(aLink[2])
# Then output it tabulated
print separator
print '| ' + strCount + ' | ' + aLink[1].ljust(50) + ' | ' + strSize.rjust(8) + ' | ' + aLink[0]
#print theName
#print thePath
#print "{:.3f}".format(float(theSize))
#print 75 * '-'
print separator
print '| ' + 'Total'.rjust(50) + ' | ' + "{:.3f}".format(totalsize).rjust(8) + ' | '
print separator