I want to loop through all the alignments. Now it doing only for first alignment only.
can anyone help?
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
i
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Since your question is C3D specific, posting it in C3D forum here might get you better chance of help.
With that said, it seems to me that the answer is quite obvious:
CivilDocument.GetAlignmentIds() returns an ObjectIdCollection, while your code specifically ONLY used the first ObjectId in that collection:
Dim alignmentId As ObjectId = _civildoc.GetAlignmentIds()(0)
Thus, you got what you wished: only first Alignment. If you need to do something with all of them, you simply loop through the collection:
For Each id As ObjectId in _civildoc.GetAlignmentIds()
Dim align = Alignment=TryCast(ts.GetObject(id, OpenMode.ForRead)....
....
'' Same thing here, if you need to do something with all Profiles of an Alignment with
Dim profileIds As ObjectIdCollection = align.GetProfileIds()
For Each profId As ObjectId in profileIds
....
Next
Next
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.