In this post, let's see how to create SampleLineGroup and SampleLine using new .NET API in Civil 3D 2014 release.
Samplelines are used to cut sections across an alignment. Samplelines are lines placed along an alignment at a specified station interval (or at defined stations of interest, such as at assemblies of a corridor object), using a specified left and right swath width. SampleLine objects are contained in SampleLineGroup objects, which organize multiple related sample lines. A SampleLine is used to create a SectionView object, which displays some or all of the sections sampled at that sample line.
We can create a new SampleLineGroup object using SampleLineGroup.Create(string groupName, ObjectId alignmentId )
And we can create new SampleLine using the SampleLine.Create() static method which has two different variants -
public static ObjectId Create(string sampleLineName, ObjectId sampleLineGroupId, double station);
public static ObjectId Create(string sampleLineName, ObjectId sampleLineGroupId, Point2dCollection points);
C# code snippet below, shows how to add a SampleLineGroup and a SampleLine using Create(string sampleLineName, ObjectId sampleLineGroupId, Point2dCollection points) –
Alignment alignment = trans.GetObject(alignmentId, OpenMode.ForWrite) as Alignment;
ObjectId slgId = SampleLineGroup.Create("My SampleLineGroup", alignment.ObjectId);
SampleLineGroup sampleLineGroup = trans.GetObject(slgId, OpenMode.ForWrite) as SampleLineGroup;
// Creating Sample line from a selected set of Points
Point2dCollection points = new Point2dCollection();
Point2d samplelineVertexPoint1 = new Point2d(4528.7808,3884.1900);
points.Add(samplelineVertexPoint1);
Point2d samplelineVertexPoint2 = new Point2d(4545.6858,3859.4065);
points.Add(samplelineVertexPoint2);
ObjectId slatStationId = SampleLine.Create("SampleLineByPoints", slgId, points);
SampleLine sampleLine = trans.GetObject(slatStationId, OpenMode.ForWrite) as SampleLine;
sampleLine.StyleId = civilDoc.Styles.SampleLineStyles[0];
Here is the result -