The classes listed in the table below expose read and write access to the tables used for mapping on export to various formats such as DWG and DGN. Each class contains (key, info) pairs of mapping data.
Class |
Description |
ExportLayerTable |
Represents a table supporting a mapping of various layer properties (Category, name, color name) to layer name in the target export format. |
ExportLinetypeTable |
Represents a table supporting a mapping of linetype names in the target export format. |
ExportPatternTable |
Represents a table supporting a mapping of FillPattern names and ids to FillPattern names in the target export format. |
ExportFontTable |
Represents a table s upporting a mapping of font names in the target export format. |
ExportLineweightTable | Represents a table s upporting a mapping of lineweight names in the target export format. |
Most of these tables are available through the BaseExportOptions class (the base class for options for DGN, DXF and DWG formats). The ExportLineweightTable is available from the DGNExportOptions class. Each table has a corresponding Get and Set method. To modify the mappings, get the corresponding table, make changes and then set it back to the options class.
The following example modifies the ExportLayerTable prior to exporting a DWG file.
Code Region: Export DWG with modified ExportLayerTable |
public bool ExportDWGModifyLayerTable(Document document, View view) { bool exported = false; IList<string> setupNames = BaseExportOptions.GetPredefinedSetupNames(document); if (setupNames.Count > 0) { // Get the export options for the first predefined setup DWGExportOptions dwgOptions = DWGExportOptions.GetPredefinedOptions(document, setupNames[0]); // Get the export layer table ExportLayerTable layerTable = dwgOptions.GetExportLayerTable(); // Find the first mapping for the Ceilings category string category = "Ceilings"; ExportLayerKey targetKey = layerTable.GetKeys().First<ExportLayerKey>(layerKey => layerKey.CategoryName == category); ExportLayerInfo targetInfo = layerTable[targetKey]; // change the color name and cut color number for this mapping targetInfo.ColorName = "31"; targetInfo.CutColorNumber = 31; // Set the change back to the map layerTable[targetKey] = targetInfo; // Set the modified table back to the options dwgOptions.SetExportLayerTable(layerTable); ICollection<ElementId> views = new List<ElementId>(); views.Add(view.Id); exported = document.Export(Path.GetDirectoryName(document.PathName), Path.GetFileNameWithoutExtension(document.PathName), views, dwgOptions); } return exported; } |