Share

CorridorCollection.Add(String, String, ObjectId, ObjectId) Method

Creates a new Corridor corridor object.



Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.280

Syntax

C#

public ObjectId Add(
	string corridorName,
	string baselineName,
	ObjectId alignmentId,
	ObjectId profileId
)

VB

Public Function Add ( 
	corridorName As String,
	baselineName As String,
	alignmentId As ObjectId,
	profileId As ObjectId
) As ObjectId

C++

public:
ObjectId Add(
	String^ corridorName, 
	String^ baselineName, 
	ObjectId alignmentId, 
	ObjectId profileId
)

Parameters

corridorName  String
Name of the Corridor to be created.
baselineName  String
Name of the Baseline to be created.
alignmentId  ObjectId
ObjectId of the Alignment used to create the Baseline.
profileId  ObjectId
ObjectId of the Profile used to create the Baseline.

Return Value

ObjectId

Exceptions

ExceptionCondition
ArgumentException

This exception is thrown if corridorName is empty or becomes empty after it is trimmed (removing all leading and trailing blank spaces) 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 it is trimmed (removing all leading and trailing blank spaces).

This exception is also thrown if the specified alignmentId does not reference an Alignment object, the Alignment instance belongs to a different drawing, or it is ObjectId.Null.

This exception will also be thrown if the specified profileId does not reference a Profile object, the Profile object instance is not owned by the specified Alignment, or the Profile object belongs to a different drawing.

ArgumentNullExceptionThis exception is thrown if the corridorName or the baselineName specified are null.
ArgumentException

This exception is thrown if corridorName is empty or becomes empty after it is trimmed (removing all leading and trailing blank spaces) 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 it is trimmed (removing all leading and trailing blank spaces).

This exception is also thrown if the specified alignmentId does not reference an Alignment object, the Alignment instance belongs to a different drawing, or it is ObjectId.Null.

This exception will also be thrown if the specified profileId does not reference a Profile object, the Profile object instance is not owned by the specified Alignment, or the Profile object belongs to a different drawing.

ArgumentNullExceptionThis exception is thrown if the corridorName or the baselineName specified are null.

Remarks

This method creates a new Corridor object. The Corridor has the specified name, and a new Baseline is created referencing the specified alignmentId and profileId. The new Baseline has the specified baselineName.

Example

 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

Reference

Corridor class
Corridor object

Was this information helpful?