Adding multiple Section Views using AutoCAD Civil 3D .NET API

By Partha Sarkar

In AutoCAD Civil 3D Toolspace, under the 'Sample Line Groups' collection, for a particular Sample Line Group (SLG), you will see 'Section View Groups' collection.

 

  Civil3D_Toolspace_Section_View_Groups

 

 

Once you expand this collection, you will see 'Individual section views'. When we add a single Section View using SectionView.Create() API, it will be added to this collection. In Civil 3D .NET API, we can access this through the following API –

SampleLineGroup.IndividualSectionViewGroup Property // Gets the individual SectionViewGroup.

  Civil3D_Toolspace_Individual_section_Views

 

If you want to create multiple section views for a group of sample lines along an Alignment, in Civil UI tools we use 'CreateMultipleSectionView' as shown below –

 

  Civil3D_Create_Multiple_UI 

 

If you want to programmatically create multiple section views, use SectionViewGroupCollection.Add() API. First to access the SectionViewGroup collection use the following Civil 3D .NET API - 

SampleLineGroup.SectionViewGroups Property  // Gets the collection of SectionViewGroup.

 

Here is a C# .NET code snippet using one of the overloaded versions of SectionViewGroupCollection.Add() API : 

SampleLineGroup sampleLineGrp = SampleLineGrpId.GetObject(OpenMode.ForWrite) asSampleLineGroup;
 
//SampleLineGroup.SectionViewGroups Property
// Gets the collection of SectionViewGroup.
SectionViewGroupCollection sectionViewGrpColl = sampleLineGrp.SectionViewGroups;
 
// get the location to insert the Section views
Point3d insertPosition;
PromptPointResult ppr = ed.GetPoint("nSelect a Location for the SectionViews:");
if (ppr.Status != PromptStatus.OK)
  return;
insertPosition = ppr.Value;
 
// now call the Add()
// Add a SectionViewGroup which will create multiple SectionViews for each SampleLine in SampleLineGroup.
sectionViewGrpColl.Add(insertPosition);

 

And result in AutoCAD Civil 3D –

Civil3D_Create_Multiple_Section_View_API


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading