<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Reverse Polyline - With Bulges - Last Bulge Problem in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362611#M17594</link>
    <description>Ok, I'm writing a VBA to reverse the direction of a closed polyline, with bulges. I've pulled code from this forum (Thank yall very much) and it seems to be working except where the last point joins the first.  If there is a bulge between the last point and the first point, it doesn't seem to register, and when the reversal is finished, the last bulge is reversed.&lt;BR /&gt;
&lt;BR /&gt;
Is there a trick to getting and/or setting the bulge between the last and first points of a closed polyline?  If I get the bulge from the last point, it says Zero, even though it's rounded.&lt;BR /&gt;
&lt;BR /&gt;
I'm at the end of my day here, so I can't post code right now, but I'll toss it in here tomorrow.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
    <pubDate>Wed, 15 Oct 2008 21:57:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-10-15T21:57:47Z</dc:date>
    <item>
      <title>Reverse Polyline - With Bulges - Last Bulge Problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362611#M17594</link>
      <description>Ok, I'm writing a VBA to reverse the direction of a closed polyline, with bulges. I've pulled code from this forum (Thank yall very much) and it seems to be working except where the last point joins the first.  If there is a bulge between the last point and the first point, it doesn't seem to register, and when the reversal is finished, the last bulge is reversed.&lt;BR /&gt;
&lt;BR /&gt;
Is there a trick to getting and/or setting the bulge between the last and first points of a closed polyline?  If I get the bulge from the last point, it says Zero, even though it's rounded.&lt;BR /&gt;
&lt;BR /&gt;
I'm at the end of my day here, so I can't post code right now, but I'll toss it in here tomorrow.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Wed, 15 Oct 2008 21:57:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362611#M17594</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-15T21:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Polyline - With Bulges - Last Bulge Problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362612#M17595</link>
      <description>Uh oh, no responses yet. Hope someone can help me figure this out.&lt;BR /&gt;
&lt;BR /&gt;
As an example, draw a rectangle using RECTANG, then use FILLET to round off the corners.  That'll be the GuineaPig.  Here's the code I got from this forum.  I forgot the name, but thank you very much.&lt;BR /&gt;
&lt;P&gt;
&lt;BR /&gt;
Private Sub ReversePline(plineObj As AcadEntity)&lt;BR /&gt;
Dim pts() As Double&lt;BR /&gt;
Dim bulge() As Double&lt;BR /&gt;
Dim legs As Integer&lt;BR /&gt;
Dim retcoord As Variant&lt;BR /&gt;
Dim i As Integer&lt;BR /&gt;
Dim i2 As Integer&lt;BR /&gt;
Dim FN As Long
&lt;/P&gt;
&lt;P&gt;
'--- I added some code to write bulges to a text file so I can see what its doing ---&lt;BR /&gt;
FN = FreeFile&lt;BR /&gt;
Open "C:\bulge.txt" For Output As #FN
&lt;/P&gt;
&lt;P&gt;
retcoord = plineObj.Coordinates&lt;BR /&gt;
ReDim Preserve pts(UBound(retcoord))&lt;BR /&gt;
legs = (UBound(retcoord) / 2) - 1&lt;BR /&gt;
ReDim Preserve bulge(legs)&lt;BR /&gt;
For i = legs To 0 Step -1&lt;BR /&gt;
    Print #FN, i &amp;amp; " = " &amp;amp; CStr(plineObj.GetBulge(legs - i))&lt;BR /&gt;
    bulge(i) = plineObj.GetBulge(legs - i) * -1&lt;BR /&gt;
Next i&lt;BR /&gt;
For i = UBound(retcoord) To 0 Step -2&lt;BR /&gt;
    i2 = UBound(retcoord) - i&lt;BR /&gt;
    pts(i2 + 1) = retcoord(i)&lt;BR /&gt;
    pts(i2) = retcoord(i - 1)&lt;BR /&gt;
Next i&lt;BR /&gt;
plineObj.Coordinates = pts&lt;BR /&gt;
For i = 0 To legs&lt;BR /&gt;
    plineObj.SetBulge i, bulge(i)&lt;BR /&gt;
    Print #FN, i &amp;amp; " = " &amp;amp; CStr(plineObj.GetBulge(legs - i))&lt;BR /&gt;
Next i&lt;BR /&gt;
Close #FN&lt;BR /&gt;
End Sub
&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2008 13:23:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362612#M17595</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-16T13:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Polyline - With Bulges - Last Bulge Problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362613#M17596</link>
      <description>Eureka! (eeka...eeka)  I figgered it out.&lt;BR /&gt;
&lt;BR /&gt;
I went back and applied a little brute force tactics, making OLDX and OLDY then swapping NEWX and NEWY, etc.  Not very elegant, but "Life is pain. Get used to it."  (Name that movie.)&lt;BR /&gt;
&lt;BR /&gt;
Anyway, it worked, and I'll post it below for anyone who's interested.&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;
&lt;BR /&gt;
Private Sub ReversePline(plineObj As AcadEntity)&lt;BR /&gt;
Dim pts() As Double&lt;BR /&gt;
Dim OLDptX() As Double&lt;BR /&gt;
Dim OLDptY() As Double&lt;BR /&gt;
Dim NEWptX() As Double&lt;BR /&gt;
Dim NEWptY() As Double&lt;BR /&gt;
Dim bulge() As Double&lt;BR /&gt;
Dim legs As Integer&lt;BR /&gt;
Dim retcoord As Variant&lt;BR /&gt;
Dim i As Integer&lt;BR /&gt;
Dim iOLD As Integer&lt;BR /&gt;
Dim iNEW As Integer&lt;BR /&gt;
retcoord = plineObj.Coordinates&lt;BR /&gt;
ReDim Preserve pts(UBound(retcoord))&lt;BR /&gt;
legs = ((UBound(retcoord) + 1) / 2) - 1&lt;BR /&gt;
ReDim Preserve OLDptX(legs)&lt;BR /&gt;
ReDim Preserve OLDptY(legs)&lt;BR /&gt;
ReDim Preserve NEWptX(legs)&lt;BR /&gt;
ReDim Preserve NEWptY(legs)&lt;BR /&gt;
ReDim Preserve bulge(legs)&lt;BR /&gt;
'\\\Establish Points Array from PolyLine Coords&lt;BR /&gt;
For i = 0 To UBound(retcoord)&lt;BR /&gt;
    pts(i) = retcoord(i)&lt;BR /&gt;
Next i&lt;BR /&gt;
'\\\Keep PointZero the same and Reverse Remaining Points&lt;BR /&gt;
'\\\Brute Force Method  (Ugh *scratch scratch*)&lt;BR /&gt;
iNEW = legs&lt;BR /&gt;
For iOLD = 1 To legs&lt;BR /&gt;
    OLDptX(iOLD) = pts(iOLD * 2)&lt;BR /&gt;
    OLDptY(iOLD) = pts((iOLD * 2) + 1)&lt;BR /&gt;
    NEWptX(iNEW) = OLDptX(iOLD)&lt;BR /&gt;
    NEWptY(iNEW) = OLDptY(iOLD)&lt;BR /&gt;
    iNEW = iNEW - 1&lt;BR /&gt;
Next iOLD&lt;BR /&gt;
'\\\NOTE-New Points Gathered, but Not Applied Yet&lt;BR /&gt;
'\\\Get Bulges in Reverse Order and Make Them Negative&lt;BR /&gt;
For i = 0 To legs&lt;BR /&gt;
    bulge(i) = plineObj.GetBulge(legs - i) * -1&lt;BR /&gt;
Next i&lt;BR /&gt;
'\\\Reverse All Points Except PointZero (Apply New Points)&lt;BR /&gt;
For i = 1 To legs&lt;BR /&gt;
    pts(i * 2) = NEWptX(i)&lt;BR /&gt;
    pts((i * 2) + 1) = NEWptY(i)&lt;BR /&gt;
Next i&lt;BR /&gt;
'\\\Give New Points to PolyLine&lt;BR /&gt;
plineObj.Coordinates = pts&lt;BR /&gt;
'\\\Set New Bulges&lt;BR /&gt;
For i = 0 To legs&lt;BR /&gt;
    plineObj.SetBulge i, bulge(i)&lt;BR /&gt;
Next i&lt;BR /&gt;
plineObj.Update
&lt;/P&gt;
&lt;P&gt;
End Sub
&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2008 15:23:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362613#M17596</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-16T15:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Polyline - With Bulges - Last Bulge Problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362614#M17597</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;another option&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;just changed your indexes slightly&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;seems to work&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Private Sub ReversePline(plineObj As &lt;BR /&gt;
AcadEntity)&lt;BR /&gt;Dim pts() As Double&lt;BR /&gt;Dim bulge() As Double&lt;BR /&gt;Dim legs As &lt;BR /&gt;
Integer&lt;BR /&gt;Dim retcoord As Variant&lt;BR /&gt;Dim i As Integer&lt;BR /&gt;Dim i2 As &lt;BR /&gt;
Integer&lt;BR /&gt;Dim FN As Long&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;'--- I added some code to write bulges to a text &lt;BR /&gt;
file so I can see what its doing ---&lt;BR /&gt;FN = FreeFile&lt;BR /&gt;Open "C:\bulge.txt" For &lt;BR /&gt;
Output As #FN&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;retcoord = plineObj.Coordinates&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;ReDim Preserve &lt;BR /&gt;
pts(UBound(retcoord))&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;'changed legs calc&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;legs = ((UBound(retcoord) + 1) / 2)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;ReDim Preserve bulge(legs)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;'changed index&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;For i = legs To 1 Step -1&lt;BR /&gt;'Print #FN, i &amp;amp; " = " &amp;amp; &lt;BR /&gt;
CStr(plineObj.GetBulge(legs - i))&lt;BR /&gt;Print #FN, i &amp;amp; " = " &amp;amp; &lt;BR /&gt;
CStr(plineObj.GetBulge(i - 1))&lt;BR /&gt;'bulge(i) = plineObj.GetBulge(legs - i) * &lt;BR /&gt;
-1&lt;BR /&gt;bulge(i - 1) = plineObj.GetBulge(i - 1) * -1&lt;BR /&gt;Next i&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;For i = UBound(retcoord) To 0 Step -2&lt;BR /&gt;i2 = &lt;BR /&gt;
UBound(retcoord) - i&lt;BR /&gt;pts(i2 + 1) = retcoord(i)&lt;BR /&gt;pts(i2) = retcoord(i - &lt;BR /&gt;
1)&lt;BR /&gt;Next i&lt;BR /&gt;plineObj.Coordinates = pts&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;'changed index&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;For i = 0 To legs - 1&lt;BR /&gt;plineObj.SetBulge i, bulge(i)&lt;BR /&gt;Print #FN, i &lt;BR /&gt;
&amp;amp; " = " &amp;amp; CStr(plineObj.GetBulge(i))&lt;BR /&gt;Next i&lt;BR /&gt;Close #FN&lt;BR /&gt;End &lt;BR /&gt;
Sub&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;hth&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;mark&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;StevieLee&amp;gt; wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6052776@discussion.autodesk.com"&amp;gt;news:6052776@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;Eureka! &lt;BR /&gt;
  (eeka...eeka) I figgered it out.&lt;BR /&gt;&lt;BR /&gt;I went back and applied a little brute &lt;BR /&gt;
  force tactics, making OLDX and OLDY then swapping NEWX and NEWY, etc. Not very &lt;BR /&gt;
  elegant, but "Life is pain. Get used to it." (Name that movie.)&lt;BR /&gt;&lt;BR /&gt;Anyway, &lt;BR /&gt;
  it worked, and I'll post it below for anyone who's interested.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
  &lt;P&gt;&lt;FONT face="Arial" size="2"&gt;snip&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Oct 2008 15:58:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/2362614#M17597</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-10-16T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Polyline - With Bulges - Last Bulge Problem</title>
      <link>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/3767053#M17598</link>
      <description>&lt;P&gt;Public Sub ReversePolyline()&lt;/P&gt;&lt;P&gt;Dim NewCoords() As Double&lt;BR /&gt;Dim Bulge() As Double&lt;BR /&gt;Dim Segm() As Double&lt;BR /&gt;Dim Bul As Double&lt;BR /&gt;Dim OldCoords As Variant&lt;BR /&gt;Dim Entity As AcadEntity&lt;BR /&gt;Dim legs As Integer&lt;BR /&gt;Dim I As Integer&lt;BR /&gt;Dim J As Integer&lt;BR /&gt;Dim N As Integer&lt;BR /&gt;&lt;BR /&gt;OldCoords = plineObj.Coordinates&lt;BR /&gt;ReDim NewCoords(LBound(OldCoords) To UBound(OldCoords)) As Double&lt;BR /&gt;&lt;BR /&gt;J = LBound(NewCoords)&lt;BR /&gt;&lt;BR /&gt;For I = UBound(OldCoords) To LBound(OldCoords) + 1 Step -2&lt;BR /&gt;NewCoords(J) = OldCoords(I - 1)&lt;BR /&gt;NewCoords(J + 1) = OldCoords(I)&lt;BR /&gt;J = J + 2&lt;BR /&gt;Next I&lt;BR /&gt;&lt;BR /&gt;N = 0&lt;/P&gt;&lt;P&gt;For I = LBound(OldCoords) To UBound(OldCoords) - 2 Step 2&lt;BR /&gt;Bul = plineObj.GetBulge(I / 2)&lt;BR /&gt;N = N + 1&lt;BR /&gt;ReDim Preserve Bulge(N)&lt;BR /&gt;ReDim Preserve Segm(N)&lt;BR /&gt;Bulge(N) = Bul * -1&lt;BR /&gt;Segm(N - 1) = (I / 2)&lt;BR /&gt;Next I&lt;BR /&gt;&lt;BR /&gt;Segm(N) = N&lt;BR /&gt;&lt;BR /&gt;For I = LBound(OldCoords) To UBound(OldCoords) - 2 Step 2&lt;BR /&gt;plineObj.SetBulge Segm(I / 2), 0&lt;BR /&gt;Next I&lt;BR /&gt;&lt;BR /&gt;For I = 0 To N - 1&lt;BR /&gt;plineObj.SetBulge Segm(I + 1) - 1, Bulge(N - I)&lt;BR /&gt;Next I&lt;BR /&gt;&lt;BR /&gt;plineObj.SetBulge Segm(N), Bulge(1)&lt;BR /&gt;&lt;BR /&gt;plineObj.Coordinates = NewCoords&lt;BR /&gt;plineObj.Update&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2013 18:58:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/reverse-polyline-with-bulges-last-bulge-problem/m-p/3767053#M17598</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-01T18:58:18Z</dc:date>
    </item>
  </channel>
</rss>

