DWG export, Cleanup dwg files after the export. Purgeall().materials
Not applicable
03-26-2016
03:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone.
I want to make a DWG exporter for our company, that can remove all unused items in the DWG files after the export.
I use the DWGExportOptions(), and the doc.export() for the DWG export. I use the Purgeall() command to Cleanup the dwg filer.
My problem is the Prugeall() command does not remove the materials (Revit materials) in the dwg file, If I do the prugeall command manually in AutoCAD, all the materials are removed.
Best Regards
awpe
My code to clenup dwg files after the export:
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
namespace Exporter
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
class PurgeAll_Autocad : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
Autodesk.AutoCAD.Interop.AcadApplication a = new Autodesk.AutoCAD.Interop.AcadApplication();
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)]
class PurgeAll_Autocad : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
Autodesk.AutoCAD.Interop.AcadApplication a = new Autodesk.AutoCAD.Interop.AcadApplication();
a.Visible = true;
Autodesk.AutoCAD.Interop.AcadDocument doc = a.Documents.Open(@"C:\temp\test.dwg", false, false);
doc.PurgeAll();
doc.SaveAs(@"C:\temp\test.dwg", Autodesk.AutoCAD.Interop.Common.AcSaveAsType.ac2010_dwg);
a.Quit();
return Autodesk.Revit.UI.Result.Succeeded;
}
}
}
}
}
}
Link copied