Option Explicit 'program to reverse the direction of a pline 'modified from malcolm's codes Private Sub reverse_pline(plineObj As Variant) Dim pts() As Double Dim bulge() As Double Dim legs As Integer Dim retcoord As Variant Dim i As Integer Dim i2 As Integer retcoord = plineObj.Coordinates ReDim Preserve pts(UBound(retcoord)) legs = (UBound(retcoord) / 2) - 1 ReDim Preserve bulge(legs) For i = legs - 1 To 0 Step -1 bulge(i) = plineObj.GetBulge(legs - 1 - i) * -1 Next i For i = UBound(retcoord) To 0 Step -2 i2 = UBound(retcoord) - i pts(i2 + 1) = retcoord(i) pts(i2) = retcoord(i - 1) Next i plineObj.Coordinates = pts For i = 0 To legs - 1 plineObj.SetBulge i, bulge(i) Next i End Sub Public Sub Test() Dim polyObj As AcadLWPolyline Dim ptPicked As Variant ThisDrawing.Utility.GetEntity polyObj, ptPicked, "Select a LWpolyline: " reverse_pline polyObj End Sub |