Adding boundaries to Civil 3D Surface object using .NET API

By Partha Sarkar

We can add
boundaries to Civil 3D Surface object using the SurfaceDefinitionBoundaries
class; this class encapsulates the boundary operation list for a surface. Note
that, operations are stored in the order they are performed on the surface.
SurfaceDefinitionBoundaries class has overloaded function AddBoundaries(). In
the following example we will see how to add boundaries to a surface from a
collection of entity ObjectIds using SurfaceOperationAddBoundary
AddBoundaries(ObjectIdCollection boundaryEntities , double midOrdinateDistance, SurfaceBoundaryType boundaryType, bool
useNonDestructiveBreakline ) 

There are few
important notes on this API mentioned in Civil 3D .NET API Reference document
which I am highlighting below - 

  1. The parameter
    useNonDestructiveBreakline is ignored for a GridVolumeSurface or TinSurface
    with a DataClip boundary type.
  2. When creating
    the DataClip/Outer boundary, the first ObjectId in boundaryEntities is used,
    and any other ObjectIds in the collection are ignored.
  3. The first
    boundary in the boundaryEntities should be closed when creating a DataClip
    boundary.

 

And here is a
C# .NET code snippet on usage of this API - 

 

try
{
  TinSurface surface = trans.GetObject(surfaceId, OpenMode.ForWrite) as TinSurface;
 
  // Add the selected polyline's ObjectId to a collection
  ObjectIdCollection boundaryEntities = new ObjectIdCollection();
  boundaryEntities.Add(plineId);
 
  // Access the BoundariesDefinition object from the surface object
  SurfaceDefinitionBoundaries surfaceBoundaries = surface.BoundariesDefinition;
 
  // now add the boundary to the surface
  surfaceBoundaries.AddBoundaries(boundaryEntities, 1.0, SurfaceBoundaryType.Outer, true);
 
  trans.Commit();
}

 

Hope this is useful to you!


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading