我从Malcom Fernandez那里得到了这些。他是一个很大的帮助,喜欢分享。
一个用于打开,一个用于关闭。
-
- Private Sub reverse_pline(polyEnt As AcadLWPolyline)
- 'this does a closed polyline
- Dim idx As Integer
- Dim numPts As Integer
- Dim numBulge As Integer
- Dim bulge As Double
- 'set an array to store the coordinates of the pline
- Dim newcoord() As Double
- numPts = UBound(polyEnt.Coordinates) - 1 'was -1
- ReDim newcoord(numPts + 1) 'was 1
- 'set an array to store the bludge factor for each segment
- Dim newbulge() As Double
- numBulge = (((numPts)) / 2) 'was -3)/2
- ReDim newbulge(numBulge)
- 'loop through the vertices of the pline and save x,y in reverse order
- For idx = 0 To numPts Step 2
- newcoord(numPts - idx) = polyEnt.Coordinates(idx)
- newcoord(numPts - idx + 1) = polyEnt.Coordinates(idx + 1) 'was +1 in 2 places
- Next idx
- 'loop through the bulge factors and save in reverse order
- For idx = 0 To numBulge
- If idx numBulge Then
- newbulge(numBulge - idx) = polyEnt.GetBulge(idx) * -1
-
- Else
-
- newbulge(0) = polyEnt.GetBulge(idx) * -1
-
- End If
- Next idx
-
- 'reverse the original pline
- polyEnt.Coordinates = newcoord
-
- For idx = 0 To numBulge
-
- If idx = 0 Then
- polyEnt.SetBulge (numBulge), newbulge(idx)
- Else
- polyEnt.SetBulge (idx - 1), newbulge(idx)
- End If
-
- Next idx
-
- polyEnt.Update
- End Sub
- Private Sub revPline(polyEnt As AcadLWPolyline)
- 'this does an open polyline
- Dim idx As Integer
- Dim numPts As Integer
- Dim numBulge As Integer
- Dim bulge As Double
- 'set an array to store the coordinates of the pline
- Dim newcoord() As Double
- numPts = UBound(polyEnt.Coordinates) - 1
- ReDim newcoord(numPts + 1)
- 'set an array to store the bludge factor for each segment
- Dim newbulge() As Double
- numBulge = ((numPts - 3) / 2)
-
- If ((UBound(polyEnt.Coordinates) + 1) / 2) Mod 2 = 0 Then
- GoTo myout
- Else
- numBulge = numBulge + 1
- End If
- myout:
- ReDim newbulge(numBulge)
- 'loop through the vertices of the pline and save x,y in reverse order
- For idx = 0 To numPts Step 2
- newcoord(numPts - idx) = polyEnt.Coordinates(idx)
- newcoord(numPts - idx + 1) = polyEnt.Coordinates(idx + 1)
- Next idx
- 'loop through the bulge factors and save in reverse order
- For idx = 0 To numBulge
- newbulge(numBulge - idx) = polyEnt.GetBulge(idx) * -1
- Next idx
-
- 'reverse the original pline
- polyEnt.Coordinates = newcoord
-
- For idx = 0 To numBulge
- polyEnt.SetBulge idx, newbulge(idx)
- Next idx
-
- polyEnt.Update
- End Sub
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |