.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

civil 3d corridor

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
418 Views, 1 Reply

civil 3d corridor

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  

Tags (1)
1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Anonymous

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

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report