DWG export, Cleanup dwg files after the export. Purgeall().materials

Anonymous

DWG export, Cleanup dwg files after the export. Purgeall().materials

Anonymous
Not applicable

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;
 
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();
 
            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;
        }
    }
}

 

 

 

 

 

 

 

0 Likes
Reply
696 Views
2 Replies
Replies (2)

Aaron.Lu
Autodesk
Autodesk
Dear awpe,

If you calling the same procedures outside of Revit, e.g. in an independent application, will the same problem occur?
if yes, then can we say it is an AutoCAD api problem?


Aaron Lu
Developer Technical Services
Autodesk Developer Network
0 Likes

Anonymous
Not applicable

Dear Aaron.      

 

I have never tried to made add in for AutoCAD, do not know if the problem also exists outside the Revit.

 

Is it possible for you to test the function outside Revit?

 

Best Regards

awpe

0 Likes