Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create offset alignment using start and end station

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
adcdao
607 Views, 3 Replies

Create offset alignment using start and end station

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é

3 REPLIES 3
Message 2 of 4
adcdao
in reply to: adcdao

I think I found the solution myself. I was inspired by this link:

https://forums.autodesk.com/t5/civil-3d-customization/alignment-pi-and-or-tangent-intersections/td-p...

 

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é

 

Message 3 of 4
Jeff_M
in reply to: adcdao

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 });
                                    }
                                }
Jeff_M, also a frequent Swamper
EESignature
Message 4 of 4
adcdao
in reply to: Jeff_M

Thank you Jeff for this clarification, I think your solution is better than mine.

 

Regards,

André

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

Post to forums  

Rail Community


Autodesk Design & Make Report