I had to adjust to topography a my project. All the points had to be lowered by 200.
Getting the points, adjusting the z-values was no problem. Putting those new point values back to the original topo was though … I ended up with creating a new topo based upon the new point values.
Downside:
I have to remove the old topograhpy and therefor all my buildingpads are deleted as well.
Question:
Is there a way to adjust the points of a topography?
May have to read the building pads and recreate those as well. I’d consider storing their points in a CSV so you don’t have to chase your tail too much.
# Created By Karam Baki : karam@aecedx.com
# Enable Python support and load DesignScript library
# IMPORTANT : ALL DYNAMO DESIGN SCRIPT NODES ARE AS (dg)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as dg
# EXTENSION Enable ToDSType
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
# Enable Revit Elements
from Revit.Elements import *
# EXTENSION Enable Geometry Conversion Methods
clr.ImportExtensions(Revit.GeometryConversion)
# Enable Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB
# Enable DocumentManager and TransactionManager
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Enable ICollection List Translate
clr.AddReference("System")
import System.Collections.Generic
from System.Collections.Generic import List
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
class WarnSwallow(IFailuresPreprocessor):
def PreprocessFailures(self, failuresAccessor):
failuresAccessor.DeleteAllWarnings()
return FailureProcessingResult.Continue
dataEnteringNode = IN
# Use UnwrapElement(IN[0]) When Translating From Dynamo to Revit
points = UnwrapElement(IN[0])
topo = UnwrapElement(IN[1])
minp = UnwrapElement(IN[2])
maxp = UnwrapElement(IN[3])
range = IN[4]
goodpts = UnwrapElement(IN[5])
if range > 0:
count = 0
bboxes = []
for each in minp:
bboxes.append(dg.BoundingBox.ByCorners(each, maxp[count]))
count = count + 1
allpts = topo.GetPoints()
convpts = []
for each in allpts:
convpts.append(each.ToPoint())
todelpts = []
for eachbox in bboxes:
for e in convpts:
if dg.BoundingBox.Contains(eachbox,e):
todelpts.append(e)
uniquetodelpts = set(todelpts)
todelpts = list(uniquetodelpts)
todelxyz = []
for e in todelpts:
todelxyz.append(e.ToXyz())
#Disposing Stuff
for e in convpts:
e.Dispose()
xyzconvgood = []
for each in goodpts:
try:
xyzconvgood.append(each.ToXyz())
except:
pass
failproc = WarnSwallow()
ilistofidsgood = List[Autodesk.Revit.DB.XYZ](xyzconvgood)
if range > 0:
if len(todelxyz) > 0:
ilistofids = List[Autodesk.Revit.DB.XYZ](todelxyz)
editsession = Architecture.TopographyEditScope(doc,"Topo K-Align")
editsessioncl = Architecture.TopographyEditScope(doc,"Topo Clean Up")
if range > 0:
try:
if len(todelxyz) > 0:
Revit.Transaction.Transaction.End(doc)
editsessioncl.Start(topo.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
topo.DeletePoints(ilistofids)
TransactionManager.Instance.ForceCloseTransaction()
editsessioncl.Commit(failproc)
except:
pass
Revit.Transaction.Transaction.End(doc)
editsession.Start(topo.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
topo.AddPoints(ilistofidsgood)
TransactionManager.Instance.ForceCloseTransaction()
editsession.Commit(failproc)
else:
Revit.Transaction.Transaction.End(doc)
editsession.Start(topo.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
topo.AddPoints(ilistofidsgood)
TransactionManager.Instance.ForceCloseTransaction()
editsession.Commit(failproc)
OUT = topo