all alignments to baseline

aruntr
Advocate
Advocate

all alignments to baseline

aruntr
Advocate
Advocate

i want to add all alignments to baseline, it is works for one alignment as per below code;

but i want to loop through all the alignments.

Using ts As Transaction = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()
            Dim _civildoc = CivilApplication.ActiveDocument()
            Dim corridorName As String = "Corridor - (1)"
            Dim corridor As Corridor = TryCast(ts.GetObject(_civildoc.CorridorCollection(corridorName), OpenMode.ForWrite), Corridor)
            Dim alignmentId As ObjectId = _civildoc.GetAlignmentIds()(0)
            Dim Alignment As Alignment = TryCast(ts.GetObject(alignmentId, OpenMode.ForRead), Alignment)
            Dim alignmentname As String = Alignment.Name.ToString
            Dim profileId As ObjectId = Alignment.GetProfileIds()(0)
            Dim Baseline As Baseline = corridor.Baselines.Add("New Baseline" & alignmentname, alignmentId, profileId)
            ts.Commit()
        End Using

 

 

 

but when i try this for all alignments it getting error; "duplicate baseline"

can any one help me in the below code..?

For Each alignmentId As ObjectId In alignColl
                Dim Alignment As Alignment = TryCast(ts.GetObject(alignmentId, OpenMode.ForRead), Alignment)
                Dim alignmentname As String = Alignment.Name.ToString

                Dim profileIds As ObjectIdCollection = Alignment.GetProfileIds()
                For Each profileId In profileIds
                    Dim Baseline As Baseline = corridor.Baselines.Add("New Baseline" & alignmentname, alignmentId, profileId)
                Next
            Next

 

 

 

0 Likes
Reply
Accepted solutions (1)
455 Views
2 Replies
Replies (2)

Jeff_M
Consultant
Consultant
Accepted solution
You are looping through all Profiles, so if the alignment has more than 1 you are attempting to create a duplicate baseline. Instead, find a FinishGrade profile, use that and exist the loop.
Jeff_M, also a frequent Swamper
EESignature
0 Likes

aruntr
Advocate
Advocate

thanks Jeff.

0 Likes