Adding / Removing Baseline using .NET API

By Partha Sarkar

AutoCAD Civil
3D UI tools allows us to add or remove Baseline in a Corridor object as shown
in the screenshot below –

C3D_BaseLineAddRemove01

 

In Civil 3D
2014 .NET API, BaselineCollection class has new functionality to add and remove
Baseline object as shown in the screenshot below and the relevant C# code
snippets –

 
C3D_BaseLineAddRemove02

 

// BaselineCollection.Add() 
// Adds a baseline with the given baseline name, alignment Id and profile Id.
 
// Get the first alignment of this drawing
ObjectId alignmentId = civilDoc.GetAlignmentIds()[0];
Alignment alignment = trans.GetObject(alignmentId, OpenMode.ForRead) as Alignment;
 
// Get the first profile of this alignment
ObjectId profileId = alignment.GetProfileIds()[0];
 
// Add the baseline
Baseline baseline = corridor.Baselines.Add("My Added BaseLine", alignmentId, profileId);
 
// Remove baseline with a given Name        
corridor.Baselines.Remove("Baseline (1)");

 

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