Tin surface Edit

Hello everyone,
I can’t edit a surface imported with LandXML. For example, I’m creating Python code to set the maximum side length of a triangle to 10 m, but nothing changes on the Civil 3D screen. How do I create the Python script? Can you help me?

import clr

clr.AddReference(‘AeccDbMgd’)
clr.AddReference(‘AutoCADMgd’)

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

doc = Application.DocumentManager.MdiActiveDocument
db = doc.Database

input_surface = IN[0]
max_length = 10.0 # 10 meters

with doc.LockDocument():
with db.TransactionManager.StartTransaction() as trans:

    surface = trans.GetObject(input_surface.Id, OpenMode.ForWrite)        
   
    build_properties = surface.BuildProperties        
    
    build_properties.UseMaximumTriangleLength = True        
    
    build_properties.MaximumTriangleLength = max_length        
    
    surface.Rebuild()
    
    trans.Commit()

doc.Editor.Regen()

Hi @tugrul.koksalPUUYK ,

try this:

import clr

#AutoCAD assemblies

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')

#AutoCAD namespaces

fromAutodesk.AutoCAD.ApplicationServicesimport *
fromAutodesk.AutoCAD.DatabaseServicesimport *

#Civil 3D namespaces

fromAutodesk.Civil.DatabaseServicesimport *
fromAutodesk.Civil.ApplicationServicesimport *

#Get active AutoCAD document

adoc = Application.DocumentManager.MdiActiveDocument

def update_surface_length(c3d_surface, length):

global adoc

# Check input values
ifc3d_surfaceisNoneorlengthis None:
return c3d_surface

# Lock the active document
with adoc.LockDocument():

# Start database transaction
with adoc.Databaseas db:
with db.TransactionManager.StartTransaction() as trans:

# Get ObjectId from the Civil 3D surface element
surface_id = c3d_surface.InternalObjectId

# Open the surface for writing
civil_surface = trans.GetObject(surface_id,OpenMode.ForWrite)

# Check that the object is a Civil 3D Surface
if isinstance(civil_surface, Surface):

# Get surface build options
build_options = civil_surface.BuildOptions

# Enable maximum triangle length
build_options.UseMaximumTriangleLength = True

# Set maximum triangle length
build_options.MaximumTriangleLength =float(length)

# Rebuild the surface
civil_surface.Rebuild()

# Commit changes
trans.Commit()

return c3d_surface

#Inputs:

Civil_3D_Surface = IN[0]
Triangle_Length = IN[1]

OUT = update_surface_length(Civil_3D_Surface, Triangle_Length)

Hello. I’m unsure which components to use for my Dynamo monitor. Can you help me?