Document.Export

Document.Export

Anonymous
Not applicable
595 Views
2 Replies
Message 1 of 3

Document.Export

Anonymous
Not applicable

Hello,

 

I am trying to export a dwg file. The following code works in Windows 7, but does not work in Windows 8. I can't find any reason why it wouldn't. Can someone tell me what I am doing wrong? Both windows systems are running Revit 2015 with service pack 2.

 

string exportfolder = "C:\Revit\Exports\";

string filename = "FirstFloor.DWG";

var tmpViews = new List<ElementId>() { _view.Id };

DWGExportOptions _dwgExportOptions = new DWGExportOptions()
{
     ExportingAreas = true,
     ExportOfSolids = SolidGeometry.Polymesh,
     FileVersion = ACADVersion.R2010,
     LayerMapping = "AIA",
     LineScaling = LineScaling.PaperSpace,
     MergedViews = false,
     PropOverrides = PropOverrideMode.ByEntity,
     SharedCoords = false,
     TargetUnit = ExportUnit.Default,
     TextTreatment = TextTreatment.Exact
};

 

_view.Document.Export(exportfolder, filename, tmpViews, _dwgExportOptions);   <-----Fails here with "Object reference not set to instance of an object"

 

0 Likes
596 Views
2 Replies
Replies (2)
Message 2 of 3

arnostlobel
Alumni
Alumni
Hi klneutron:

It's hard to tell without further info and/or testing. Can you please confirm or deny the following:

1. Does it also fail when you give it NULL as the Options?

2. Does it also fail when you give it one of the predefined options obtained by calling BaseExportOptions.GetPredefindOptions?

Thank you
Arnošt Löbel
0 Likes
Message 3 of 3

Troy_Gates
Advocate
Advocate
Shouldn't this line:

string exportfolder = "C:\Revit\Exports\";

be like this:

string exportfolder = "C:\\Revit\\Exports\\";

or

string exportfolder = @"C:\Revit\Exports\";
0 Likes