How to Export View/Sheet set to PDF DWG and DWF format

How to Export View/Sheet set to PDF DWG and DWF format

Anonymous
Not applicable
5,174 Views
7 Replies
Message 1 of 8

How to Export View/Sheet set to PDF DWG and DWF format

Anonymous
Not applicable

Hello all,

 

I'm developing an add-in that will export selected view/sheet set into PDF, DWG and DWF file format. I'd like to know how can I achieve this functionality through revit API. Appreciate any suggestion or hint.

 

Thanks

Ali

 

 

File Exporter.PNG

 

 

 

0 Likes
Accepted solutions (1)
5,175 Views
7 Replies
Replies (7)
Message 2 of 8

jeremytammik
Autodesk
Autodesk
Accepted solution

Use the Autodesk.Revit.DB.Export method with DWGExportOptions or DWFExportOptions:

 

 

Afaik, you have to use the printing functionality for PDF export:

 

 

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 8

Anonymous
Not applicable

Thank you so much for sharing the links. 

 

Cheers,

Ali

0 Likes
Message 4 of 8

Anonymous
Not applicable

  Hi,

This code will export the  views  to  DWG files.

before using this command open the views(views you want to export(selected views)) .

Here GetOpenUIViews() will not get all the views instead it will get only  the opened views in the document

 

                  UIDOCUMENT uidoc;

                  DWGExportOptions Option = new DWGExportOptions();

                  Option.FileVersion = ACADVersion.R2010;

                  ICollection<ElementId> views = new Collection<ElementId>();

//GET ALL THE OPENED VIEWS IN THE DOCUMENT

                  IList<UIView> uiviewss = uidoc.GetOpenUIViews();

 

                                  foreach (UIView V in uiviewss)

                                         {

                                              views.Add(V.ViewId);

                                         }

//EXPORT AS DWG FILE

                      uidoc.Document.Export(@"C:\folder", @"filename.dwg", views, Option);

Message 5 of 8

Anonymous
Not applicable

Thanks @Anonymous I'll definitely check this code out. Do you know how to export sheets set in PDF format? 

0 Likes
Message 6 of 8

Anonymous
Not applicable

Hi @jeremytammik I checked the link for auto-pdf-print. The code is well documented. However, when I used the PrintToPDF method in my addin the following error popup up while running the PrintManager.SubmitPrint(); method. Do you know the fix?

 

"Attempted to read or write protected memory. This is often an indication that another memory is corrupt"

0 Likes
Message 7 of 8

jeremytammik
Autodesk
Autodesk

Glad to hear it is well documented and you are able to run it. Nope, sorry, I do not know how to fix that. Good luck!



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 8

Anonymous
Not applicable

I think the error comes because of the  oPM.SelectNewPrintDriver("CutePDF writer"); do not run smoothly. however, by changing CutePDF writer to 'Microsoft Print to PDF"  the error got fixed. Thanks for those links, they really helped!

 

cheers,

Ali

0 Likes