-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeleteCheckForCollateralDamage.py
More file actions
46 lines (40 loc) · 1.4 KB
/
DeleteCheckForCollateralDamage.py
File metadata and controls
46 lines (40 loc) · 1.4 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
'''
Check Element Dependancies.
Delete an element,
capture the list of element Ids removed from the model,
RollBack the tansaction
Check to see if the list contains more than just the element selected.
Report the elements also deleted
'''
theElements = {}
key = ''
if len(selection) > 0:
for s in selection:
print s.Id
try:
tranny = Transaction(doc)
tranny.Start('Blah!')
print 'Element:', s.Id, type(s)
key = s.Id.IntegerValue
collateraldamage = doc.Delete(s.Id)
theElements.Add(key,collateraldamage)
tranny.RollBack()
except Exception as e:
if tranny.HasStarted():
print 'Error...!!!'
print e.message
tranny.RollBack()
tranny.Dispose()
for k in theElements.Keys:
print '=' * 75
#Check to see if the list if collateral damage is
#more than just the elements itself
if len(theElements[k]) > 1:
print 'If you delete Element \n[' + str(k) + '] ' + doc.GetElement(ElementId(k)).Category.Name + ' - ' + str(type(doc.GetElement(ElementId(k))))
print 'The following Elements will also be deleted:-'
print
for theId in theElements[k]:
print str(theId) + ' - ' + doc.GetElement(ElementId(k)).Category.Name + ' - ' + str(type(doc.GetElement(theId)))
else:
print str(k) + ' - ' + doc.GetElement(ElementId(k)).Category.Name + ' - Clean Delete'
print '=' * 75, 'FIN...'