Strange coincidence, I just started working on something similar yesterday. I'm trying to see if there is a way to get the final volume and location of objects created in a corridor programmatically. For example, I need to get the begin/end station of a lane and it's final volume.
Not sure if I'll need to keep track of shapes areas at each frequency and use end area calculations or if I can get the final volume from the model.
Here's the code to go through the corridor and read SA areas:
public void CorridorShapes()
{
Document acadDocument = Application.DocumentManager.MdiActiveDocument;
Database database = acadDocument.Database;
Autodesk.Civil.ApplicationServices.CivilDocument civilDocument = Autodesk.Civil.ApplicationServices.CivilDocument.GetCivilDocument(database);
CorridorCollection corridorCollection = civilDocument.CorridorCollection;
using (Transaction transaction = database.TransactionManager.StartTransaction())
{
foreach (ObjectId corridorId in corridorCollection)
{
Corridor corridor = (Corridor)transaction.GetObject(corridorId, OpenMode.ForRead);
BaselineCollection baselines = corridor.Baselines;
foreach (Baseline baseline in baselines)
{
ObjectId algnId = baseline.AlignmentId;
BaselineRegionCollection baselineRegions = baseline.BaselineRegions;
foreach (BaselineRegion baselineRegion in baselineRegions)
{
AppliedAssemblyCollection appliedAssemblies = baselineRegion.AppliedAssemblies;
double[] appliedStations = appliedAssemblies.Stations();
List<double> stationList = appliedStations.ToList();
stationList.Sort();
foreach (double station in stationList)
{
AppliedAssembly appliedAssembly = appliedAssemblies.GetItemAt(station);
Assembly assembly = (Assembly)transaction.GetObject(appliedAssembly.AssemblyId, OpenMode.ForRead);
AppliedSubassemblyCollection appliedSubassemblies = appliedAssembly.GetAppliedSubassemblies();
foreach (AppliedSubassembly appliedSubassembly in appliedSubassemblies)
{
Subassembly subassembly = (Subassembly)transaction.GetObject(appliedSubassembly.SubassemblyId, OpenMode.ForRead);
CalculatedShapeCollection calculatedShapes = appliedAssembly.Shapes;
}
}
}
}
}
}
}
The code is from this post: Corridor Solids trough API - Autodesk Community - Civil 3D
Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer