<?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: Erase last object in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378923#M56688</link>
    <description>&lt;P&gt;&lt;FONT face="%value"&gt;I have not used it and of course 'not supported' but maybe you can search for&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Internal.&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;Utils&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.EntLast();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" face="%value"&gt;&lt;FONT size="2"&gt;and see if people have had success&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2012 23:48:26 GMT</pubDate>
    <dc:creator>jeff</dc:creator>
    <dc:date>2012-03-20T23:48:26Z</dc:date>
    <item>
      <title>Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378573#M56684</link>
      <description>Hey everyone, In AutoCAD, i can type "erase" and then "last" into the commandline and it will automatically select and erase the last object i created. How is this accomplished in C#? I'm generating a polyline to automatically calculate areas, but i would like that polyline to vanish once the area has been measured. Thanks Vince</description>
      <pubDate>Tue, 20 Mar 2012 19:27:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378573#M56684</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-20T19:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378667#M56685</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a SelectLast option:&lt;/P&gt;&lt;PRE&gt;PromptSelectionResult acSSPrompt;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
acSSPrompt = ed.SelectLast();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2012 20:20:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378667#M56685</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-03-20T20:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378725#M56686</link>
      <description>&lt;P&gt;Ok that helps, what would i use to delete what i selected with the editor?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2012 20:42:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378725#M56686</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-20T20:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378777#M56687</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should start a transaction, get the last object (as entity) &amp;nbsp;erase it (entity.erase), and commit the transaction and that's it. Like this (not tested, and translated from VB)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("ELAST")]
public void EraseObj()
{
	Document acDoc = Application.DocumentManager.MdiActiveDocument;
	Database acCurDb = acDoc.Database;
	Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

	using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) {
		PromptSelectionResult acSSPrompt;
		acSSPrompt = ed.SelectLast;
		Entity ent;
		SelectionSet ss = acSSPrompt.Value;

		if (ss.Count &amp;gt; 0) {
			ent = acTrans.GetObject(ss.Item(0).ObjectId, OpenMode.ForWrite);
			ent.Erase();
		}
		acTrans.Commit();
	}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2012 21:22:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378777#M56687</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-03-20T21:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378923#M56688</link>
      <description>&lt;P&gt;&lt;FONT face="%value"&gt;I have not used it and of course 'not supported' but maybe you can search for&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.Internal.&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;&lt;FONT size="2" face="Consolas" color="#2b91af"&gt;Utils&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2" face="Consolas"&gt;&lt;FONT size="2" face="Consolas"&gt;.EntLast();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" face="%value"&gt;&lt;FONT size="2"&gt;and see if people have had success&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2012 23:48:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3378923#M56688</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2012-03-20T23:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379477#M56689</link>
      <description>&lt;P&gt;Thanks for this sample, i'm having an issue with the line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;ent = acTrans.GetObject(ss.(0).ObjectId, OpenMode.ForWrite);&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Visual Studio 2010 and AutoCAD 2012 are telling me that there is no definition for ss.item and thus i cannot compile. As i missing &amp;nbsp;a reference?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.EditorInput;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;using Autodesk.AutoCAD.Colors;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 12:49:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379477#M56689</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T12:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379481#M56690</link>
      <description>&lt;P&gt;Thanks jeff, i'll have a look into this as well.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Vince&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 12:49:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379481#M56690</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T12:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379521#M56691</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SelectionSet &amp;nbsp;it's part of the EditorInput, and I see you are "using" it, so I have no idea why VS is telling you that. Any way the correct sintax is : &lt;STRONG&gt;&lt;FONT color="#0000FF"&gt;ss(index).ObjectId &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;without a dot after ss.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;FONT color="#000000"&gt;Gaston Nunez&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:12:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379521#M56691</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-03-21T13:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379537#M56692</link>
      <description>&lt;P&gt;Ok, so i've got this now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;PromptSelectionResult acSSPrompt;&lt;BR /&gt;acSSPrompt = ed.SelectLast();&lt;BR /&gt;Entity ent;&lt;BR /&gt;SelectionSet ss = acSSPrompt.Value;&lt;/P&gt;&lt;P&gt;if (ss.Count &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;ent = acTrans.GetObject(ss(0).ObjectId, OpenMode.ForWrite);&lt;BR /&gt;ent.Erase();&lt;BR /&gt;}&lt;BR /&gt;acTrans.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the error I have is 'ss' is a 'variable' but is used like a 'method'&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:20:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379537#M56692</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T13:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379541#M56693</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My mistake (i'm a vb guy), just change ss(0) by ss[0].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:25:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379541#M56693</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-03-21T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379551#M56694</link>
      <description>&lt;P&gt;Haha didn't even notice that. Now when i change it to ss[0], i get&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error 1 Cannot implicitly convert type 'Autodesk.AutoCAD.DatabaseServices.DBObject' to 'Autodesk.AutoCAD.DatabaseServices.Entity'. An explicit conversion exists (are you missing a cast?) C:\Users\user\Dropbox\Programming\Cad\Cad\TheProgram\Drawing Commands\Copy of AREA.cs 28 27 Commands&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if (ss.Count &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;ent = acTrans.GetObject(ss[0].ObjectId, OpenMode.ForWrite);&lt;BR /&gt;ent.Erase();&lt;BR /&gt;}&lt;BR /&gt;acTrans.Commit();&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:30:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379551#M56694</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T13:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379591#M56695</link>
      <description>&lt;P&gt;Scratch that, fixed it &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public void EraseObj()&lt;BR /&gt;{&lt;BR /&gt;Document acDoc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;Database acCurDb = acDoc.Database;&lt;BR /&gt;Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;/P&gt;&lt;P&gt;using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())&lt;BR /&gt;{&lt;BR /&gt;PromptSelectionResult acSSPrompt;&lt;BR /&gt;acSSPrompt = ed.SelectLast();&lt;BR /&gt;Entity ent;&lt;BR /&gt;SelectionSet ss = acSSPrompt.Value;&lt;/P&gt;&lt;P&gt;if (ss.Count &amp;gt; 0)&lt;BR /&gt;{&lt;BR /&gt;ent = acTrans.GetObject(ss[0].ObjectId, OpenMode.ForWrite) as Entity;&lt;BR /&gt;ent.Erase();&lt;BR /&gt;}&lt;BR /&gt;acTrans.Commit();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a million for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 13:47:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379591#M56695</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T13:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379625#M56696</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Glad to help you, sorry the mistake, i feel much comfortable with vb 'cause I'd like to see "End this", "End That"... instead of a lot of brackets at the end of a block of code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gaston Nunez&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 14:02:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379625#M56696</guid>
      <dc:creator>hgasty1001</dc:creator>
      <dc:date>2012-03-21T14:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Erase last object</title>
      <link>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379645#M56697</link>
      <description>&lt;P&gt;No worries, thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2012 14:11:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/erase-last-object/m-p/3379645#M56697</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-03-21T14:11:43Z</dc:date>
    </item>
  </channel>
</rss>

