-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path000BellaFixTopo.py
More file actions
62 lines (50 loc) · 1.6 KB
/
000BellaFixTopo.py
File metadata and controls
62 lines (50 loc) · 1.6 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
class MyFailureProcessor(IFailuresPreprocessor):
def __init__(self):
pass
def PreprocessFailures(self,failuresAccessor):
return FailureProcessingResult.Continue
aFoot =304.8
topo = selection[0]
#topo = doc.GetElement(ElementId(2540544))
#Get The Internal Points
intPoints = topo.GetInteriorPoints()
extPoints = topo.GetBoundaryPoints()
#Merge the lists of points
thePoints = intPoints.Concat(extPoints)
tranny = Transaction(doc)
failProc = MyFailureProcessor()
try:
#Create a TopographyEditScope which encapsulates the inner
#Transactions like a Transaction Group.
scope = TopographyEditScope(doc, 'MovingPoints')
print 'starting edit scope'
#Start the TopographyEditScope
scope.Start(topo.Id)
print 'started'
tranny.Start('Moving Point')
#Check and Fix each point
for aPoint in thePoints:
#Convert the points from feet to meters
z = aPoint.Z * aFoot
print 'Old Zed = ' + z.ToString()
#If the point hasn't already been corrected
if z < 1000:
newz = z * 1000 / aFoot
print 'New Zed = ' + newz.ToString()
#Calculate the new Elevation
movedPoint = XYZ(aPoint.X, aPoint.Y, aPoint.Z)
targetPoint = XYZ(aPoint.X, aPoint.Y, newz)
topo.ChangePointElevation(movedPoint, newz)
tranny.Commit()
scope.Commit(failProc)
except Exception as e:
#Roll Back the Transaction if it is still open.
if tranny.HasStarted():
tranny.RollBack()
tranny.Dispose()
#Close the TopographyEditScope if it is still open.
if scope.IsActive:
scope.Commit(failProc)
print 'Oooops'
print e.message
print aPoint