Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
697 Views, 2 Replies

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

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

 

 

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
Aaron.Lu
in reply to: Anonymous

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
Message 3 of 3
Anonymous
in reply to: Aaron.Lu

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report