I am working on a command to change the surface style programmatically with vb.NET and am having issues. I work with a lot of surfaces in my drawings at times and they are pasted into one compiled surface. 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. Seems simple... but it's not working.
Under Autodesk.Civil.Land.DatabaseServices, Surface, TinSurface, & GridSurface are all exposed. They all list the StyleID as ObjectID and the StyleName as String that says it is a Public Overridable Property. However when trying to change their current values I receive an Unhandled Exception stating "need to override property StyleID()/StyleName". I would think that this would work.
I have done some research and saw that there is another option down the COM route with Surface.Style. However, I am unfamiliar with programming in COM and I was under the impression most of Civil3D has been ported to vb.NET.
Anyone know what I'm doing wrong?? Here is a little snippet of my code.
For Each Style As ObjectId In Styles
Dim oStyle As SurfaceStyle = TryCast(Style.GetObject(OpenMode.ForRead), SurfaceStyle)
If cbxSurfStyles.Text = oStyle.Name Then
Dim oStyleId As ObjectId = oStyle.ObjectId
'Dim oStyleNm As String = oStyle.Name
For Each SelSurfName In clbSurfaces.CheckedItems
Dim surfaces As ObjectIdCollection = m_CivilDoc.GetSurfaceIds
For Each surfaceId As ObjectId In surfaces
Dim oSurface As ACLB.TinSurface = TryCast(SelSurfID.GetObject(OpenMode.ForWrite), ACLB.TinSurface)
If oSurface.Name = SelSurfName Then
oSurface.StyleId = oStyleId
'oSurface.StyleName = oStyleNm
tr.Commit()
End If
Next
Next
End If
Next
Thanks!!
Steve
Windows 7
Civil3D 2011