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: 

Export DWG from Revit with custom layer overrides

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
2068 Views, 3 Replies

Export DWG from Revit with custom layer overrides

I'm having some problems exporting some adjusted layers in a DWG format from a Revit model. The project we're working on is using the duct families as place holders for future content. For this reason, we need to adjust the layer name and projection color ID on the export for the duct and duct fitting families in the project. 

 

I initially looked at the LayerMapping property within the DWGExportOptions class, but found it only pointed at the standards and couldn't find a way to adjust single categories.

 

After spinning my wheels there, I started looking at SetExportLayerTable Method. I've tried setting up KeyValuePairs for single category overrides and adding them to the table, but doing so actually caused the exports to inherit subcategory values from object styles as the layer names and the one override I tried didn't work. (code below)

 

DWGExportOptions optDWG = new DWGExportOptions();

 

foreach (View3D vt in collection)
if (vt.Name.Contains("xxxxxxxx"))
{
ViewSet viewsToExport = new ViewSet();
viewsToExport.Insert(vt);

ICollection<ElementId> exportViews = new List<ElementId>();

foreach (View view in viewsToExport)
{
exportViews.Add(view.Id);

}

ExportLayerKey layerKey = new ExportLayerKey();
layerKey.CategoryName = "Ducts";

ExportLayerInfo layerInfo = new ExportLayerInfo();
layerInfo.LayerName = "E-DUCT-BANK";
layerInfo.ColorNumber = 1;

ExportLayerTable layerTable = new ExportLayerTable();

layerTable.Add(layerKey,layerInfo);

 

string viewName = vt.Name.Replace("xxxxxxxx", DateTime.Now.ToString("yyyyMMdd"));
optDWG.ExportOfSolids = SolidGeometry.ACIS;
optDWG.SharedCoords = true;
optDWG.PropOverrides = PropOverrideMode.ByLayer;
optDWG.LayerMapping = "AIA";
optDWG.SetExportLayerTable(layerTable);
doc.Export(folderNameDWG, viewName, exportViews, optDWG);

 

Can someone please help me understand what steps I would need to take to utilize the AIA standards for dwg layer naming on the exports by default and only override select categories to override color and layer name?

 

-Jared

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

I found the solution in the GetPredefinedOptions method within the DWGExportOptions class. I just used the method to pass in the settings that the user had set up in the project and it worked fine. 

Message 3 of 4
TomRam
in reply to: Anonymous

hi jregan,
I'm having the same problem.
Could please explain in more detail your solution to export correctly the adjusted layers in a DWG format from a Revit model or share the final code ?
TomRam
Message 4 of 4
Anonymous
in reply to: TomRam

TomRam,

 

I work in a significant number of models on the day to day basis that have varying contractual requirements for what layer name, export color, line type etc the exports needed to have. So what I ended up doing was having project leads define their export settings in the project using the Modify DWG/DXF Export Setup like they would if they manually exported, save the settings with a specific title, then email me the title. 

 

So if they emailed me and said my export setup is called "Standard Export Setup", when it came time to use the export method, it would look like 

 

 

Document.Export(folderName, viewName, exportViewCollection, DWGExportOptions.GetPredefinedOptions(Document,"Standad Export Setup"));

 

Reply to this if you need more information

 

-JRegan

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community