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: 

Getting PI Points Coordinates of an Alignment

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
ekoneo
1796 Views, 19 Replies

Getting PI Points Coordinates of an Alignment

Hi,

I try to get PI point coordinates list of an alignment. Although I get PI point station, I cant get PI points coordinates.

A part of my sample is here:

 

 

switch (sampleAlignment.EntityType)
{
  case AlignmentEntityType.Arc:
       AlignmentArc sampleArc = sampleAlignment as AlignmentArc;
       ed.WriteMessage("\n" + "PI Point Station: " + sampleArc.PIStation +"\n");

 

 

 Is there any way to get PI point coordinates of an alignment?

Thanks.

19 REPLIES 19
Message 2 of 20
BlackBox_
in reply to: ekoneo

Try iterating the vertices of a temporary GetPolyline()



"How we think determines what we do, and what we do determines what we get."

Message 3 of 20
ekoneo
in reply to: BlackBox_

Thank you for your reply. GetPolyline() converts splines to breaklines. So polyline includes many vertex points. I need only polylines. 

Message 4 of 20
kovacsv1
in reply to: ekoneo

I know this is a bit messy, but maybe you can add labels and get the values from there with the AlignmentIndexedPILabel Class?

Message 5 of 20
ekoneo
in reply to: kovacsv1

Good idea. First add PI lables then get label informations lastly delete labels. Thank you for this trick 😊

Message 6 of 20
ekoneo
in reply to: kovacsv1

If i can get copy of an alignment, after deleting all entities (not lines) it is possible work with GetPolyline method. However i couldnt get copy of alignment. When i try to delete entities the original alignment's entities become errased. I need to leanr that the way of preparing an undependent copy of an alignment.

Message 7 of 20
BlackBox_
in reply to: ekoneo

Just backing up for a sec; why does iterating Alignment.Entities & testing for AlignmentEntityType.Line (if not others as desired), and simply storing (as example) AlignmentLine.PassThroughPoint1 & AlignmentLine.PassThroughPoint2 to Point2dCollection (if !Contains) not work? 



"How we think determines what we do, and what we do determines what we get."

Message 8 of 20
Jeff_M
in reply to: ekoneo

Just calculate the PIPoint of the AlignmentArc entity:

 

                foreach(AlignmentEntity e in align.Entities)
                {
                    if (e.EntityType == AlignmentEntityType.Arc)
                    {
                        var a = e as AlignmentArc;
                        var chordMid = new Point2d((a.StartPoint.X + a.EndPoint.X)/ 2.0, (a.StartPoint.Y + a.EndPoint.Y)/ 2.0);
                        var ang = a.CenterPoint.GetVectorTo(chordMid);
                        var pi = Autodesk.Civil.Utility.PolarPoint(a.CenterPoint.To3D().ToArray(), ang.Angle, a.Radius + a.MidOrdinate);
                    }
                }

 

Jeff_M, also a frequent Swamper
EESignature
Message 9 of 20
ekoneo
in reply to: BlackBox_

Thank you for reply. I ll try on tomorrow. I wish it works. Thanks for your interest 😊

Message 10 of 20
ekoneo
in reply to: Jeff_M

Thank you so much Jeff_M.. You helped me many times. This code calculating PI points coordinates. If SCS, SS or CS etc exist in an alignment, various PI points coordinates calculation formulas are requared. If there isn't another way I try your method. I try to list selected alignment's subentities in a dataGridView. Also I wanted to put PI points coordinates in the data gridview. However I couldnt achieve this yet. Thank you so much for your help. Also I wanna ask you one more thing please. Is there any way to get an independent copy of an alignment? Independent, because I ll delete all entities of ones. Other copy ll be used. Sory for my bad English. Tank you so much.

Message 11 of 20
Jeff_M
in reply to: ekoneo

@ekoneo All the other entity types with arcs/spirals include the PIPoint or SPIPoint property in the SubEntity objects.

Jeff_M, also a frequent Swamper
EESignature
Message 12 of 20
ekoneo
in reply to: Jeff_M

Thank you for reply Jeff_M. I try that code with a simple alignment including SCS type entity (SpiralCurveSpiral). The alignment tangent extensions are visible. I get PI point's coordinate with "entitiySCS.Arc.PIPoint" . I compare them with tangent extension points's coordinate. Unfotunatelly they are different. Because entitiySCS.Arc.PIPoint providing only arc's own PI point (In the blue circle on photo). I try to define difference on atached photo. I need PI point of total of SCS entitiy (In the red circle on photo). Thank you Jeff_M.

 

PI_and_pi.jpg

Message 13 of 20
Jeff_M
in reply to: ekoneo

Ah, okay, understood. Back to the drawing board...

Jeff_M, also a frequent Swamper
EESignature
Message 14 of 20
hippe013
in reply to: Jeff_M

@Jeff_M Couldn't you just compute the overall PI by intersecting the incoming and outgoing lines? In my tinkering I found that I shouldn't iterate through the AlignmentEntityCollection but rather use the GetEntityByOrder function.

 

 Dim index As Integer = 0
                For Each ent As AlignmentEntity In align.Entities
                    ed.WriteMessage(vbCrLf & "Index: " & index.ToString & " Entity Type: " + ent.EntityType.ToString)
                    If ent.SubEntityCount > 1 Then
                        For i As Integer = 1 To ent.SubEntityCount
                            Dim subEnt As AlignmentSubEntity = ent(i - 1)
                            ed.WriteMessage(vbCrLf & "Index: " & index.ToString & "." & i.ToString & " Sub Entity Type: " & subEnt.SubEntityType.ToString)
                        Next
                    End If

                    index += 1
                Next





 

'Index: 0 Entity Type: Line
'Index: 1 Entity Type: Line
'Index: 2 Entity Type: SpiralCurveSpiral
'Index: 2.1 Sub Entity Type: Spiral
'Index: 2.2 Sub Entity Type: Arc
'Index: 2.3 Sub Entity Type: Spiral

 

The above entities are out of order.

 

 

For order As Integer = 0 To align.Entities.Count - 1
                    Dim ent As AlignmentEntity = align.Entities.GetEntityByOrder(order)
                    ed.WriteMessage(vbCrLf & "Index: " & order.ToString & " Entity Type: " + ent.EntityType.ToString)

                    If ent.SubEntityCount > 1 Then
                        For i As Integer = 1 To ent.SubEntityCount
                            Dim subEnt As AlignmentSubEntity = ent(i - 1)
                            ed.WriteMessage(vbCrLf & "Index: " & order.ToString & "." & i.ToString & " Sub Entity Type: " & subEnt.SubEntityType.ToString)
                        Next
                    End If
                Next

 

These Entities are in order.


'Index: 0 Entity Type: Line
'Index: 1 Entity Type: SpiralCurveSpiral
'Index: 1.1 Sub Entity Type: Spiral
'Index: 1.2 Sub Entity Type: Arc
'Index: 1.3 Sub Entity Type: Spiral
'Index: 2 Entity Type: Line

 

Message 15 of 20
ekoneo
in reply to: hippe013

Thank you for your interest. If we delete all subentities (except lines), we get purified alignment having only tangents. Then easly we can use start end end points to get PI points. How ever when I try to remove subentities, the alignment becomes erased. In the backround, if we produce a copy of the alignment and keep the original alignment, it is possible to remove copy alignment's entities. We can get PI points from the copy alignment with making operations on it. At the end we can delete operated, purified copy alignment. Is it possble?

 

Message 16 of 20
Jeff_M
in reply to: hippe013

@hippe013 yes, that works as long as the IS a tangent segment. I've never had a need to use spirals so don't know if there is ever a case to have an arc on either side of the spiral.

 

@ekoneo rather than muddle around with an alignment, or copy of it, by removing the non-line entities just loop through the entities as @hippe013 showed in the second example (which is the correct way) and for each AlignmentLine create a linesegment2d object from the endpoints, then use the IntersectWith() between two successive lines. 

Jeff_M, also a frequent Swamper
EESignature
Message 17 of 20
ekoneo
in reply to: Jeff_M

@hippe013 and @Jeff_M I try the method that you adviced. Tank you so much.

Message 18 of 20
hippe013
in reply to: Jeff_M

@Jeff_M You bring up a good point. I also can't think of a reason where you wouldn't have a tangent before and after the SCS, but if a user is able to create an SCS using the UI without the tangents before and after then we should account for that. Using just the SCS, the overall PI can be computed at the intersection of two vectors. 

 

vec1 = SpiralIn.SPIPoint - SpiralIn.StartPoint

vec2 = SpiralOut.SPIPoint - SpiralOut.EndPoint

 

 

 

Message 19 of 20
hippe013
in reply to: ekoneo

Here is a function I came up with to return the overall PI of the AlignmentSCS

 

Private Function GetSCSPI(scs As AlignmentSCS) As Point2d
            Using line1 As New Line2d(scs.SpiralIn.StartPoint, scs.SpiralIn.SPIPoint)
                Using line2 As New Line2d(scs.SpiralOut.EndPoint, scs.SpiralOut.SPIPoint)
                    Dim intersection() As Point2d = line1.IntersectWith(line2)
                    Return intersection(0)
                End Using
            End Using
End Function
Message 20 of 20
hosneyalaa
in reply to: kovacsv1

Hi @kovacsv1 

great idea

Did you try it with dynamo script?

Thanks

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report