Public Class my commands
Dim Borders As objectid collection = Nothing
Public Sub MyCommand()'此方法可以有任何名称
Dim doc As Document = Application。document manager . MdiActiveDocument
Dim db As Database = doc。数据库
显示为Editor = doc。editor
Dim civ doc As civil document = Autodesk。civil . application services . civil application . active document。transaction manager . start transaction()
Dim oBlockTable As block table。GetObject(db。BlockTableId,OpenMode。for read)
Dim oBTR As block table record
oBTR = trans。GetObject(oBlockTable(block table record。ModelSpace)、OpenMode。ForWrite)
尝试
Dim obids As objectid collection = civ doc。GetSurfaceIds()
For Each ob As ObjectId In obids
Dim surface As TinSurface = try cast(trans。GetObject(ob,OpenMode。ForRead),tin surface)
Dim entity ids As objectid collection
entity ids = surface。ExtractBorder(Autodesk。civil . surface extractionsettingstype . model)
For I As Integer = 0 To entity ids。count-1
Dim entityId As ObjectId = entityIds(I)
If entityId。ObjectClass = RXClass。GetClass(GetType(Polyline3d))然后
Dim border As polyline 3d = try cast(entityId。GetObject(OpenMode。ForWrite)、Polyline3d)
oBTR。append entity(border)trans。AddNewlyCreatedDBObject(border,True)
End If
Next
Next
trans。commit()
Catch
End Try
trans。dispose()
End Sub
End Class