<?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: Purgeall in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789780#M50940</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Alexander&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have this message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error 1 'GetAcadDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is because you did not read the comments in the program. Read them carefully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;...When I open up the drawing and try to run the code (just as the first command in the drawing), it doesn't run. Although if I enter model space through viewport or switch back and forth between model space and paper space, the code will run as supposed to...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry but I can not reproduce this behavior.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2013 21:49:27 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2013-02-25T21:49:27Z</dc:date>
    <item>
      <title>Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3788986#M50936</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Needed help in the following solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doc.SendStringToExecute("_-Purge _A _* _N ", True, False, False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 11:13:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3788986#M50936</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-25T11:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789272#M50937</link>
      <description>&lt;P&gt;What help do you need?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe simplest sample:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Reflection;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

[assembly: CommandClass(typeof(Rivilis.Purge))]

namespace Rivilis
{
  public class Purge
  {
    [CommandMethod("MyPurgeAll")]
    static public void MyPurgeAll()
    {
      // For AutoCAD 2013+
      object adoc = Application.DocumentManager.MdiActiveDocument.GetAcadDocument();
      // For AutoCAD 2012-
      // object adoc = Application.DocumentManager.MdiActiveDocument.AcadDocument;
      if (adoc != null) {
        adoc.GetType().InvokeMember("PurgeAll",BindingFlags.InvokeMethod, null, adoc, null);
      }
    }
  }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 15:14:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789272#M50937</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-25T15:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789518#M50938</link>
      <description>&lt;P&gt;Thanks Alexander&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have this message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error 1 'GetAcadDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 18:41:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789518#M50938</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-25T18:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789730#M50939</link>
      <description>&lt;P&gt;Hi Alexander,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code works ok, but I have though a question: I have a drawing that was last saved in paper space (paper space being active space).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I open up the drawing and try to run the code (just as the first command in the drawing), it doesn't run. Although if I enter model space through viewport or switch back and forth between model space and paper space, the code will run as supposed to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know what is missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 20:59:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789730#M50939</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-25T20:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789780#M50940</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Alexander&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have this message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error 1 'GetAcadDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is because you did not read the comments in the program. Read them carefully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;...When I open up the drawing and try to run the code (just as the first command in the drawing), it doesn't run. Although if I enter model space through viewport or switch back and forth between model space and paper space, the code will run as supposed to...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry but I can not reproduce this behavior.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2013 21:49:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3789780#M50940</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-25T21:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790136#M50941</link>
      <description>&lt;P&gt;I was just telling myself, as an uneducated programming hobbyiest writing addins for myself only, that modifying geometry in CAD so far has been fairly straight forward, but there was no way I could figure out how to "purge all".... VUALA! Magic appears at Autodesk &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Alexander (or is it Alex?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more question... I couldn't help but notice the difference in the adoc dealio... everything I've written for myself has been for 2012... are you showing me that I'll have to update every flippin acdoc in my code when I update to 2013?&amp;nbsp; sad face lol&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 11:02:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790136#M50941</guid>
      <dc:creator>brianchapmandesign</dc:creator>
      <dc:date>2013-02-26T11:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790195#M50942</link>
      <description>&lt;P&gt;Resolved&lt;BR /&gt;Thanks Alexander&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 12:07:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790195#M50942</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-02-26T12:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Purgeall</title>
      <link>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790255#M50943</link>
      <description>&lt;P&gt;This code have to work in both AutoCAD 2012 (and 2011, 2010...) and AutoCAD 2013:&lt;/P&gt;
&lt;PRE&gt;using System;
using System.Reflection;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

[assembly: CommandClass(typeof(Rivilis.Purge))]

namespace Rivilis
{
  public class Purge
  {
    [CommandMethod("MyPurgeAll")]
    static public void MyPurgeAll()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      object adoc = null;
      if (Application.Version.Major &amp;lt; 19) { 
        // For AutoCAD 2012- (i.e. 2012, 2011, 2010, ...)
        adoc = doc.GetType().InvokeMember("AcadDocument", 
          BindingFlags.GetProperty, null, doc, null);
      } else { 
        // For AutoCAD 2013+ (i.e. 2013, 2014 (???), ...)
        Type ext = typeof(Autodesk.AutoCAD.Windows.Menu).Assembly&lt;BR /&gt;.GetType("Autodesk.AutoCAD.ApplicationServices.DocumentExtension", true);
        MethodInfo GetAcadDocumentMethod = 
          ext.GetMethod("GetAcadDocument", BindingFlags.Public | BindingFlags.Static);
        adoc = GetAcadDocumentMethod.Invoke(doc, new object[1] { doc });
      }
      if (adoc != null) {
        adoc.GetType().InvokeMember("PurgeAll", BindingFlags.InvokeMethod, null, adoc, null);
      }
    }
  }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2013 13:08:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/purgeall/m-p/3790255#M50943</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-02-26T13:08:03Z</dc:date>
    </item>
  </channel>
</rss>

