Hi,
I'm trying to offset an alignment but by segment. I'm able to offset all the alignment but not by segment. I found this method:
public static ObjectId CreateOffsetAlignment( Database database, string alignmentName, string parentAlignmentName, double offset, string styleName, double startStation, double endStation )
But I didn't find any example of how to use that. I don't know how to get startStation and endStation of each segment of an alignment.
Thank you for your help,
Regards,
André
Solved! Go to Solution.
Solved by adcdao. Go to Solution.
I think I found the solution myself. I was inspired by this link:
So here's my solution using an array of existing lines:
ObjectId AlignmentID = Alignment.Create(C3Ddoc, AlignmentName, "", AlignmentLayer, AlignmentStyleName,
AlignmentLabelSetStyleName);
Alignment align = acTrans.GetObject(AlignmentID, OpenMode.ForWrite) as Alignment;
foreach (Line aLine in acLinesList)
{
align.Entities.AddFixedLine(aLine.StartPoint, aLine.EndPoint);
}
Station[] sta = align.GetStationSet(StationTypes.All);
long staCounter = 0;
while (staCounter < sta.Count()-1)
{
//Offset creation by segment
Alignment.CreateOffsetAlignment(acCurDb, AlignmentName + " - Right (" + (staCounter + 1).ToString() + ")",
AlignmentName, AlignmentOffset, AlignmentStyleName, sta[staCounter].RawStation, sta[staCounter+1].RawStation);
Alignment.CreateOffsetAlignment(acCurDb, AlignmentName + " - Left (" + (staCounter + 1).ToString() + ")",
AlignmentName, AlignmentOffset * -1, AlignmentStyleName, sta[staCounter].RawStation, sta[staCounter+1].RawStation);
staCounter += 1;
}
It seems to do the job like I want.
Hope this code snippet can help someone else.
Regards,
André
This will give you all the start/end stations of the segments. The variable aln has been set already as teh ALignment object.
List<double[]> stationsList = new List<double[]>(); foreach (Autodesk.Civil.DatabaseServices.AlignmentEntity aEnt in aln.Entities) { for(int i = 0; i< aEnt.SubEntityCount;i++) { var startSta = aEnt[i].StartStation; var endSta = aEnt[i].EndStation; stationsList.Add(new double[] { startSta, endSta }); } }
Can't find what you're looking for? Ask the community or share your knowledge.