The .NET API does not expose all the functionality of AutoCAD Civil 3D, and it exposes less than the COM
API. The following areas are not yet exposed in .NET:
■ Survey
■ Points
■ Surfaces
■ Sites and Parcels
■ Sections
■ Data Bands
■ Labels (except Alignment, Profile and Profile View labels)
When making modifications, you have to go through each surface and change the styles indivually from 'No Display' to 'Something that Displays'. So my thought was design a menu that lists the surface styles in the drawing and lists all the surfaces. Then pick what style you want and which surfaces to apply it to.
Dim oSurfaceStyle As AeccSurfaceStyle
oSurfaceStyle = oDocument.SurfaceStyles.Add("New Style")
' The surface is displayed according to the
' oSurfaceStyle style we have just created.
oSurface.Style = oSurfaceStyle.Name
Imports System
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.Civil.ApplicationServices
Imports Autodesk.Civil.DatabaseServices
Imports Autodesk.Civil.Land.DatabaseServices
Imports Autodesk.Civil.Land.DatabaseServices.Styles
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AECC.Interop.Land
<CommandMethod("TestSurfStyle")> _
Public Sub TestSurfStyle()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim CivilDoc As CivilDocument = CivilApplication.ActiveDocument
Using tr As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Dim surf As TinSurface = TryCast(CivilDoc.GetSurfaceIds(0).GetObject(OpenMode.ForRead), TinSurface)
Dim style As SurfaceStyle = TryCast(CivilDoc.Styles.SurfaceStyles(1).GetObject(OpenMode.ForRead), SurfaceStyle)
Dim comSurf As AeccTinSurface = TryCast(surf.AcadObject, AeccTinSurface)
Dim comStyle As AeccSurfaceStyle = TryCast(style.AcadObject, AeccSurfaceStyle)
comSurf.Style = comStyle
tr.Commit()
End Using
End Sub
<CommandMethod("TestSurfStyle")> _
Public Sub TestSurfStyle()
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim CivilDoc As CivilDocument = CivilApplication.ActiveDocument
Using tr As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Dim prmpt = New PromptEntityOptions("Select Surface")
prmpt.SetRejectMessage("Not a surface, try again...")
prmpt.AddAllowedClass(GetType(ACLB.Surface), False)
Dim res As PromptEntityResult = doc.Editor.GetEntity(prmpt)
If res.Status <> PromptStatus.OK Then Return
Dim SelSurfID As ObjectId = res.ObjectId
Dim styles As SurfaceStyleCollection = CivilDoc.Styles.SurfaceStyles
For Each StyleID As ObjectId In styles
Dim style As SurfaceStyle = TryCast(StyleID.GetObject(OpenMode.ForRead), SurfaceStyle)
If "Border Only" = style.Name Then
MsgBox(style.Name)
Dim comStyle As AeccLandLib.AeccSurfaceStyle = TryCast(style.AcadObject, AeccLandLib.AeccSurfaceStyle)
MsgBox(comStyle.Name)
Dim Surface As ACLB.Surface = TryCast(SelSurfID.GetObject(OpenMode.ForRead), ACLB.Surface)
MsgBox(Surface.Name)
Dim comsurf As AeccLandLib.AeccSurface = TryCast(Surface.AcadObject, AeccLandLib.AeccSurface)
MsgBox(comsurf.Name)
comsurf.Style = comStyle
End If
Next
tr.Commit()
End Using
End Sub