<?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 Re: Drawing multiple polylines in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2787758#M63662</link>
    <description>&lt;P&gt;I do not see all your code but your PL variable is pointing to the ployline you just added try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  Dim PL As New Polyline

 

        PL.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)

        PL.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)

        PL.AddVertexAt(2, New Point2d(1, 1), 0, 0, 0)

        PL.AddVertexAt(3, New Point2d(0, 1), 0, 0, 0)

        PL.AddVertexAt(3, New Point2d(0, 0), 0, 0, 0)

        Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)

        'This works and draws a little box

      

        'Now change the vertices and draw another one.

        

        'Uncomment these lines and it fails

       
&amp;nbsp;Dim PL2 As New Polyline&lt;BR /&gt;
        PL2.AddVertexAt(0, New Point2d(5, 5), 0, 0, 0)

        PL2.AddVertexAt(1, New Point2d(5, 6), 0, 0, 0)

        PL2.AddVertexAt(2, New Point2d(6, 6), 0, 0, 0)

        PL2.AddVertexAt(3, New Point2d(5, 6), 0, 0, 0)

        PL2.AddVertexAt(4 New Point2d(5, 5), 0, 0, 0)

        Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL2)

 

 

 

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Oct 2010 03:21:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-10-05T03:21:39Z</dc:date>
    <item>
      <title>Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2787750#M63661</link>
      <description>&lt;P&gt;I am trying to draw multiple LWPOLYLINES and I can't seem to figure out how. I can draw one shape OK but when I try to draw another one it fails. I can do a similar thing with lines but can't make it work with polylines. The first little routine is lifted from Jerry Winters' book as is the 'AddToModelSpace' code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Class DrawPoly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CommandMethod("DrawPoly2")&amp;gt; _&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub DrawPoly()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'This little routine draws several lines by changing the points and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'calling the add routine. This works OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim myStartPoint As Point3d = DocumentManager.MdiActiveDocument.Editor.GetPoint("pick point").Value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For x As Double = myStartPoint.X - 4 To myStartPoint.X + 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim myline As New Line(myStartPoint, New Point3d(x, myStartPoint.Y + 2, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, myline)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim PL As New Polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(2, New Point2d(1, 1), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(3, New Point2d(0, 1), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(3, New Point2d(0, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'This works and draws a little box&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Now change the vertices and draw another one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Uncomment these lines and it fails&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PL.AddVertexAt(0, New Point2d(5, 5), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PL.AddVertexAt(1, New Point2d(5, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PL.AddVertexAt(2, New Point2d(6, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PL.AddVertexAt(3, New Point2d(5, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'PL.AddVertexAt(4 New Point2d(5, 5), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2010 03:01:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2787750#M63661</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-05T03:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2787758#M63662</link>
      <description>&lt;P&gt;I do not see all your code but your PL variable is pointing to the ployline you just added try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  Dim PL As New Polyline

 

        PL.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)

        PL.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)

        PL.AddVertexAt(2, New Point2d(1, 1), 0, 0, 0)

        PL.AddVertexAt(3, New Point2d(0, 1), 0, 0, 0)

        PL.AddVertexAt(3, New Point2d(0, 0), 0, 0, 0)

        Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)

        'This works and draws a little box

      

        'Now change the vertices and draw another one.

        

        'Uncomment these lines and it fails

       
&amp;nbsp;Dim PL2 As New Polyline&lt;BR /&gt;
        PL2.AddVertexAt(0, New Point2d(5, 5), 0, 0, 0)

        PL2.AddVertexAt(1, New Point2d(5, 6), 0, 0, 0)

        PL2.AddVertexAt(2, New Point2d(6, 6), 0, 0, 0)

        PL2.AddVertexAt(3, New Point2d(5, 6), 0, 0, 0)

        PL2.AddVertexAt(4 New Point2d(5, 5), 0, 0, 0)

        Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL2)

 

 

 

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2010 03:21:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2787758#M63662</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-05T03:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788002#M63663</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Times New Roman" color="#000000" size="3"&gt;Yes, that will work. But what if I don't know how many of these shapes I wish to draw when I write the code? The number required will be based on user input. What I am trying to figure out is why I can draw multiple lines but not multiple polylines. What I want to do is place the code in a for-next loop like the line example and change the verticies for each group of four vertices thereby drawing a group of rectangles. &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2010 13:00:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788002#M63663</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-05T13:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788196#M63664</link>
      <description>&lt;P&gt;What are you trying to accomplish?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2010 14:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788196#M63664</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-05T14:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788634#M63665</link>
      <description>&lt;P&gt;You did not post the AddToModelSpace code (and I don't have Jerry's book), but I am sure it is Disposing of the object after adding it to the Model Space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice, in your Line code, you declare the myline variable as a New Line inside the For loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is what is missing from the Polyline code.&amp;nbsp; So, ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim PL As New Polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(0, New Point2d(0, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(1, New Point2d(1, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(2, New Point2d(1, 1), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(3, New Point2d(0, 1), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(3, New Point2d(0, 0), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'This works and draws a little box&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Re-initialize the PL variable&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PL = New Polyline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(0, New Point2d(5, 5), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(1, New Point2d(5, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(2, New Point2d(6, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(3, New Point2d(5, 6), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PL.AddVertexAt(4 New Point2d(5, 5), 0, 0, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Util.AddToModelSpace(HostApplicationServices.WorkingDatabase, PL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2010 18:53:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788634#M63665</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-05T18:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788986#M63666</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468374"&gt;@chiefbraincloud&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&amp;lt; .. &amp;gt; but I am sure it is Disposing of the object after adding it to the Model Space.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT size="2"&gt;Why would you think that ??&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT size="2"&gt;.. and why would he want to ??&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;As a side note&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;This question is typical of a majority of questions I read on discussion groups and forums,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;in that there is frequently insufficient information provided by the original poster to allow anything other than a wild assed guess at the problem let alone the solution.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;... but perhaps that's just me. &lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://forums.autodesk.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 00:33:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2788986#M63666</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2010-10-06T00:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789024#M63667</link>
      <description>&lt;P&gt;For one thing, it should be done, either explicitly or through a Using statement on the transaction, so if it is not being done in the AddToModelSpace routine, it should be being done in the OP's code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, note that there is no Transaction in the OP's code, so there must be one in the AddToModelSpace routine.&amp;nbsp;&amp;nbsp; Even if the object is not getting properly disposed, it must be added to the transaction, and then can not be accessed after the transaction has been committed, unless the variable is reassigned to a new reference, so the same fix would work, but leave the original object undisposed.&amp;nbsp; (should be a "Forgot to Call Dispose? message in the VS output window at runtime)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Personally, I prefer to keep the New Object creation and the transaction in the same function, returning the newly created ObjectID to&amp;nbsp;the calling function, rather than passing Non-DB resident objects between functions.&amp;nbsp; It helps me to make sure I'm disposing of everything that needs disposed, and not disposing things that shouldn't be.&amp;nbsp;But maybe that's just me.&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit:&amp;nbsp; I also just noticed that Jeffrey's post also suggested creating a&amp;nbsp;New reference, but perhaps he did not quite correctly explain what was happenning behind the scene's, and from the OP's response to his message, I might add (for the benefit of the OP) that of course you could put the polyline stuff into a foreach/next or for/next loop just like the Line code, as long as the PL object is reset to a new reference inside the loop (and each original object properly disposed somewhere).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 02:42:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789024#M63667</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T02:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789030#M63668</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ahhh&lt;/P&gt;&lt;P&gt;You meant 'dispose the transaction'&lt;/P&gt;&lt;P&gt;You said 'Disposing of the object after adding it to the Model Space'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;likely to lead to confusion ... in fact it did &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 02:59:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789030#M63668</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2010-10-06T02:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789046#M63669</link>
      <description>&lt;P&gt;To be clear, both the object and the transaction need to be disposed.&amp;nbsp; Under certain circumstances, disposing the transaction will automatically dispose the object that has been added to it.&amp;nbsp;&amp;nbsp;Under other circumstances, such as an exception thrown prior to adding the object to the transaction,&amp;nbsp;the object should be disposed of individually.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 03:33:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789046#M63669</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T03:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789048#M63670</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Sorry, you lost me ..&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;What object needs to be disposed. ??&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Are you discussing the polyline or the line. ?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;A sample of what you mean may clarify your point.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;And just a semantic point.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;We&amp;nbsp;don't add an object to the transaction.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;We&amp;nbsp;do use the transaction to wrap the adding (writing) of the object to the database ... simarly read access.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="ArialMT"&gt;&lt;FONT size="2" face="ArialMT"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;We commit the transaction if we want changes to appear in the database&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 03:48:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789048#M63670</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2010-10-06T03:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789050#M63671</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Times New Roman" color="#000000" size="3"&gt;Yes, that will work. But what if I don't know how many of these shapes I wish to draw when I write the code? The number required will be based on user input. What I am trying to figure out is why I can draw multiple lines but not multiple polylines. What I want to do is place the code in a for-next loop like the line example and change the verticies for each group of four vertices thereby drawing a group of rectangles. &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The problem is he has not stated a problem. How can you have a solution if you do not know what you are trying to solve?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Normally I would tell him to put it in a for loop but I am trying to get out of the habit of&amp;nbsp;solving the problem syntaxtically(if that is a real word) and solving it programatically.&lt;/P&gt;&lt;P&gt;If he would state it problem in pseuudocode&lt;/P&gt;&lt;P&gt;For Example&lt;/P&gt;&lt;P&gt;1. Let user select two points and draw rectangle&lt;/P&gt;&lt;P&gt;2. keep drawing rectangles for every two points until user presses escape&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;1. User selected point is the center of a predetermined size rectangle.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then a for loop would probably not be the best solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If he would state the problem there are experienced and smart guys like Kerry and chiefbraincloud out there that will help him out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 03:57:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789050#M63671</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-06T03:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789052#M63672</link>
      <description>&lt;P&gt;Here is the mystery code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt; Function AddToModelSpace(ByVal DBIn As Database, ByVal EntityIn As Entity) As ObjectId
            Using myTrans As Transaction = DBIn.TransactionManager.StartTransaction
                Dim myBT As BlockTable = DBIn.BlockTableId.GetObject(OpenMode.ForRead)
                Dim myModelSpace As BlockTableRecord = _
               myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)
                myModelSpace.AppendEntity(EntityIn)
                myTrans.AddNewlyCreatedDBObject(EntityIn, True)
                myTrans.Commit()
                Return EntityIn.ObjectId
            End Using
        End Function&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 04:05:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789052#M63672</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-06T04:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789060#M63673</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;"What object needs to be disposed. ??"&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All Objects that implement iDisposable&amp;nbsp;should be disposed.&lt;/P&gt;&lt;P&gt;All DBobject and DBobject derived objects implement iDisposable, as far as I know.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;We&amp;nbsp;don't add an object to the transaction.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Transaction.AddNewlyCreatedDBOobject(entity, true)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is how an object is 'added to the transaction'.&amp;nbsp; When this is done, and the transaction is properly disposed (wether committed or not) the transaction will dispose of the original object.&amp;nbsp; If this is not done (ie. an exception prior) then the object needs disposed explicitly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;We&amp;nbsp;do use the transaction to wrap the adding (writing) of the object to the database ... simarly read access. &lt;/EM&gt;&lt;/FONT&gt;&lt;EM&gt;We commit the transaction if we want changes to appear in the database.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;FYI, I have read many times, and can somewhat understand how, even (especially) if the transaction only performs Read Only opperations, it should still be committed, because the commit operation has less overhead than the Abort operation, which will happen any time a transaction is disposed without being committed.&amp;nbsp; The only time you should explicitly abort a transaction, or implicitly abort a transaction by calling dispose without calling commit, is if there are changes to Objects associated with that transaction (in write mode, New objects or edited objects) that you do Not want to be comitted to the database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, my experience is quite heavy on the AutoCAD side (since V.10, ~1991), but I've only been in the .NET framework since late 2006, on Acad 2007.&amp;nbsp; I'm still learning, and don't propose to be the consumate expert, but all I have said here is based on what I have learned.&amp;nbsp; I monitor this site mostly for the opportunity to learn from others, but when I feel&amp;nbsp;have something to contribute, I do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 04:28:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789060#M63673</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T04:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789066#M63674</link>
      <description>&lt;P&gt;First,&amp;nbsp;My comment was only meant to give you credit for first proposing to reset or recreate the PL reference.&amp;nbsp; I realized after the fact of my post that while I attempted to explain the why a little more than you did, your post was in fact correct in addressing the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second, I can't believe Jerry didn't put a Try/Catch in there,&amp;nbsp;which, in essence, &amp;nbsp;assumes that the Entity passed is valid (and the DB reference is valid), but regardless, the Using statement on the transaction, combined with the AddNewlyCreatedDBObject, will automatically dispose of the original object if the function completes successfully, making our point valid, that the original PL reference is no longer valid, and has to be recreated.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 04:49:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789066#M63674</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T04:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789070#M63675</link>
      <description>&lt;BLOCKQUOTE&gt;I feel it worth mentioning...&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeffrey_H wrote:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"For Example&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;1. Let user select two points and draw rectangle&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;2. keep drawing rectangles for every two points until user presses escape&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;or&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;1. User selected point is the center of a predetermined size rectangle.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Then a for loop would probably not be the best solution.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If he would state the problem there are experienced and smart guys like Kerry and chiefbraincloud out there that will help him out."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I chose not to address how he is going to construct his loop, or get his points for the rectangles.&amp;nbsp; He did not ask that question, and I'm not sure I would even try to answer it if he did, at least not on this forum.&amp;nbsp; That is more of a basic programming point, rather than an AutoCAD API specific point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's my general rule.&amp;nbsp; Attempt to address&amp;nbsp;the&amp;nbsp;presented problem, without giving a general programming tutorial in the process.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 05:08:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789070#M63675</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T05:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789954#M63676</link>
      <description>&lt;P&gt;I apoligize if my post seemed like I was trying to have a go at someone.&lt;/P&gt;&lt;P&gt;That is not what I intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;k5xh,&lt;/P&gt;&lt;P&gt;You posted that the number of rectangles depended on user input. Do the points where the rectangle are drawn depend on user input? If so I have a routine that I can modify that mifgt help you out.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 19:01:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2789954#M63676</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-10-06T19:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Drawing multiple polylines</title>
      <link>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2790010#M63677</link>
      <description>&lt;P&gt;I did not take it that way, and I did not intend to be confrontational, either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is, after all, called a Discussion Group.&amp;nbsp; I was just discussing.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2010 19:25:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/drawing-multiple-polylines/m-p/2790010#M63677</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2010-10-06T19:25:16Z</dc:date>
    </item>
  </channel>
</rss>

