Remove existing DEM and add new

Hi,

I am looking for a way to remove an existing DEM file from a grid surface and add an updated file, I only see ImportFromDEM method to create a new grid surface with a DEM file. can someone help me with this, I am using the Civil 3D 2023 version, python or code block are my preferred approaches.

Thanks for the reply.
This is really important for me. Can you please give me an idea of how this can be done either with code block or python? I tried with the below code, but it’s not working. Please help me.

Load the Python Standard and DesignScript Libraries

import sys
import clr

Add Assemblies for AutoCAD and Civil3D

clr.AddReference(‘AcMgd’)
clr.AddReference(‘AcCoreMgd’)
clr.AddReference(‘AcDbMgd’)
clr.AddReference(‘AecBaseMgd’)
clr.AddReference(‘AecPropDataMgd’)
clr.AddReference(‘AeccDbMgd’)

Import references from AutoCAD

from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

Import references from Civil3D

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

The inputs to this node will be stored as a list in the IN variables.

dataEnteringNode = IN

aeccSurf = IN[0]
FilaPath = IN[1]

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

civilDoc = CivilDocument.GetCivilDocument(adoc.Database)

aeccSurf = surf.InternalDBObject

Remove the current DEM file

aeccSurf.DEMFilesDefinition.RemoveAll()

Add the new DEM file

crs = civilDoc.Settings.DrawingSettings.UnitZoneSettings.CoordinateSystemCode
aeccSurf.DEMFilesDefinition.ADDDEMFile(filePath, crs, False, 0)

Save changes to the surface object

aeccSurf.DowngradeOpen()
aeccSurf.UpgradeOpen()

with aeccSurf.Database.TransactionManager.StartTransaction() as trans:
trans.Commit()

Assign your output to the OUT variable.

OUT = 0

aeccSurf.DEMFilesDefinition.RemoveAt( i )