CorridorCollectionAdd(String, String, ObjectId, String, ObjectId) Method

Creates a new Corridor object with given corridor name, baseline name, feature line, baseline region name and assembly.

Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.292
Syntax
public ObjectId Add(
	string corridorName,
	string baselineName,
	ObjectId featureLineId,
	string baselineRegionName,
	ObjectId assemblyId
)

Parameters

corridorName  String
Name of the Corridor to be created.
baselineName  String
Name of the Baseline to be created.
featureLineId  ObjectId
ObjectId of the FeatureLine used to create the Baseline.
baselineRegionName  String
Name of the BaselineRegion to be created.
assemblyId  ObjectId
ObjectId of the Assembly used to create the region.

Return Value

ObjectId
Exceptions
ExceptionCondition
ArgumentException

This exception is thrown if corridorName is empty or becomes empty after it is trimmed or a Corridor with the same name already exists. The Corridor name is case-sensitive; therefore, "Corridor - 1" will not match "corridor - 1". This practice is not recommended.

This exception is also thrown if the baselineName is empty or becomes empty after it is trimmed

This exception is also thrown if the specified featureLineId does not reference an FeatureLine object, or the FeatureLine instance belongs to a different drawing.

This exception is also thrown if the specified baselineRegionName is empty or becomes empty after trimming.

This exception is also thrown if the specified assemblyId does not reference an instance of an Assembly object, or the Assembly instance belongs to a different drawing.

Remarks

This method creates a new Corridor object. It allows you to specify the Corridor object name, the new Baseline name, the FeatureLine's object id used to create the Baseline, a region name for a new BaselineRegion to be created, and the Assembly id to be used within the region.

Example
C#
 1[CommandMethod(ReferenceGuideSample.GoupId, "CreateCorridorHavingBaselines", CommandFlags.Modal)]
 2public void CreateCorridorHavingMultiBaselines()
 3{
 4    using (Transaction tr = startTransaction())
 5    {
 6        ObjectId alignmentId = promptForEntity("\nSelect an alignment: ", typeof(Alignment));
 7        Alignment alignment = alignmentId.GetObject(OpenMode.ForRead) as Alignment;
 8        ObjectId profileId = alignment.GetProfileIds()[0];
 9        ObjectId assemblyId = promptForEntity("\nSelect an assembly: ", typeof(Assembly));
10        ObjectId featurelineId = promptForEntity("\nSelect a feature line: ", typeof(FeatureLine));
11
12        // Create a corridor having 1 alignment-based baseline
13        {
14            string corridorName = "New Corridor 1";
15            ObjectId corridorId = _civildoc.CorridorCollection.Add(corridorName, "Baseline Name 1", alignmentId, profileId);
16            Corridor corridor = corridorId.GetObject(OpenMode.ForWrite) as Corridor;
17            corridor.Baselines[0].BaselineRegions.Add("Region Name 1", assemblyId);
18            corridor.Rebuild();
19
20            corridorName = "New Corridor 2";
21            corridorId = _civildoc.CorridorCollection.Add(corridorName, "Baseline Name 1", alignmentId, profileId, "Region Name 1", assemblyId);
22            corridor = corridorId.GetObject(OpenMode.ForWrite) as Corridor;
23            corridor.Rebuild();
24        }
25
26        // Create a corridor having 1 featureline-based baseline
27        {
28            string corridorName = "New Corridor 3";
29            ObjectId corridorId = _civildoc.CorridorCollection.Add(corridorName, "Baseline Name 1", featurelineId);
30            Corridor corridor = corridorId.GetObject(OpenMode.ForWrite) as Corridor;
31            corridor.Baselines[0].BaselineRegions.Add("Region Name 1", assemblyId);
32            corridor.Rebuild();
33
34            corridorName = "New Corridor 4";
35            corridorId = _civildoc.CorridorCollection.Add(corridorName, "Baseline Name 1", featurelineId, "Region Name 1", assemblyId);
36            corridor = corridorId.GetObject(OpenMode.ForWrite) as Corridor;
37            corridor.Rebuild();
38        }
39
40        // Create a corridor having 3 baselines;
41        {
42            string corridorName = "New Corridor 5";
43            ObjectId corridorId = _civildoc.CorridorCollection.Add(corridorName);
44            Corridor corridor = corridorId.GetObject(OpenMode.ForWrite) as Corridor;
45
46            // Add baseline 1: alignment-based baseline.
47            Baseline baseline = corridor.Baselines.Add("Baseline Name 1", alignmentId, profileId);
48            baseline.BaselineRegions.Add("Region Name 1", assemblyId);
49
50            // Add baseline 2: alignment-based baseline.
51            // Here alignmentId, profileId and assemblyId can be replaced with another alingmentId, profileId and assemblyId.
52            baseline = corridor.Baselines.Add("Baseline Name 2", alignmentId, profileId);
53            baseline.BaselineRegions.Add("Region Name 1", assemblyId);
54
55            // Add baseline 3: featureline-based baseline.
56            baseline = corridor.Baselines.Add("Baseline Name 3", featurelineId);
57            baseline.BaselineRegions.Add("Region Name 1", assemblyId);
58
59            // Last rebuild corridor
60            corridor.Rebuild();
61        }
62        tr.Commit();
63    }
64}
See Also