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.
Solved! Go to Solution.
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.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Solved by hippe013. Go to Solution.
Try iterating the vertices of a temporary GetPolyline()
"How we think determines what we do, and what we do determines what we get."
Try iterating the vertices of a temporary GetPolyline()
"How we think determines what we do, and what we do determines what we get."
Thank you for your reply. GetPolyline() converts splines to breaklines. So polyline includes many vertex points. I need only polylines.
Thank you for your reply. GetPolyline() converts splines to breaklines. So polyline includes many vertex points. I need only polylines.
I know this is a bit messy, but maybe you can add labels and get the values from there with the AlignmentIndexedPILabel Class?
I know this is a bit messy, but maybe you can add labels and get the values from there with the AlignmentIndexedPILabel Class?
Good idea. First add PI lables then get label informations lastly delete labels. Thank you for this trick 😊
Good idea. First add PI lables then get label informations lastly delete labels. Thank you for this trick 😊
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.
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.
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."
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."
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);
}
}
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);
}
}
Thank you for reply. I ll try on tomorrow. I wish it works. Thanks for your interest 😊
Thank you for reply. I ll try on tomorrow. I wish it works. Thanks for your interest 😊
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.
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.
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.
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.
Ah, okay, understood. Back to the drawing board...
Ah, okay, understood. Back to the drawing board...
@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
@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
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?
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?
@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.
@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 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
@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
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
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
Can't find what you're looking for? Ask the community or share your knowledge.