- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to export a ViewSheet as a DWG or DXF. Looking through examples on the forums and help files it seems simple, but is not working for me. Exporting as DWG or DXF manually from the Export menu works fine but I cannot get it working through the API. One problem I'm having is that my document has no predefined setup options. When I use the following code:
IList<string> setupNames = BaseExportOptions.GetPredefinedSetupNames(document);
setupNames has no strings in it, so there are no predefined options in my document as far as I know. So I have to create my own DWGExportOptions or DXFExportOptions. I tried doing this by exporting the sheet manually and opening up the "Modify DWG/DXF Export Setup" dialog box to see the settings and then use those to create my own export options object. This is not working however. The AutoCAD file I get has just a small white square where the sheet should be. Here is my code:
List<ElementId> viewIds = new List<ElementId>(); viewIds.Add(viewSheet.Id); DWGExportOptions options = new DWGExportOptions(); options.Colors = ExportColorMode.IndexColors; options.ExportOfSolids = SolidGeometry.Polymesh; options.FileVersion = ACADVersion.R2013; options.HatchPatternsFileName = @"C:\Program Files\Autodesk\Revit 2016\ACADInterop\acdb.pat"; options.HideScopeBox = true; options.HideUnreferenceViewTags = true; options.HideReferencePlane = true; options.LayerMapping = "AIA"; options.LineScaling = LineScaling.PaperSpace; options.LinetypesFileName = @"C:\Program Files\Autodesk\Revit 2016\ACADInterop\acdb.lin"; options.MergedViews = false; options.PropOverrides = PropOverrideMode.ByEntity; options.TextTreatment = TextTreatment.Exact; document.Export(filePath, fileName, viewIds, options);
Any help is appreciated. Thank you.
Solved! Go to Solution.