.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,
Needed help in the following solution.
doc.SendStringToExecute("_-Purge _A _* _N ", True, False, False)
Thanks
www.lojadosdesenhadores.blogspot.com
Solved! Go to Solution.
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
What help do you need?
Maybe simplest sample:
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.GetA cadDocument();
// For AutoCAD 2012-
// object adoc = Application.DocumentManager.MdiActiveDocument.Acad Document;
if (adoc != null) {
adoc.GetType().InvokeMember("PurgeAll",BindingFlag s.InvokeMethod, null, adoc, null);
}
}
}
}
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Alexander
i have this message:
Error 1 'GetAcadDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.
www.lojadosdesenhadores.blogspot.com
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Alexander,
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).
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.
I don't know what is missing.
Thanks,
e.g.
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
franciscocsilva wrote:
Thanks Alexander
i have this message:
Error 1 'GetAcadDocument' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.
This is because you did not read the comments in the program. Read them carefully.
e.g. wrote:
...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...
Sorry but I can not reproduce this behavior.
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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 ![]()
Thanks Alexander (or is it Alex?)
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? sad face lol
Thanks!
"Very funny, Scotty. Now beam down my clothes."
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Resolved
Thanks Alexander
www.lojadosdesenhadores.blogspot.com
Re: Purgeall
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
This code have to work in both AutoCAD 2012 (and 2011, 2010...) and AutoCAD 2013:
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 < 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
.GetType("Autodesk.AutoCAD.ApplicationServices.Doc umentExtension", 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);
}
}
}
}



