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: 

Revit API Export DWF error

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
anderswithkaas7214
1502 Views, 5 Replies

Revit API Export DWF error

Hi

 

I want to export some views to a DWF file

 

But I keep getting this error:

 

cannot convert from 'Autodesk.Revit.DB.DWFExportOptions' to 'Autodesk.Revit.DB.SATExportOptions

 

The code look like this:

 

IList<ElementId> ImageExportList = new List<ElementId>();

 

// Here I select the viewes I want to export

 

ImageExportList.Add(View.Id);

 

                                var Eksport_DWF = new DWFExportOptions

                                {

                                    MergedViews = true,

 

                                };

 

                              String FileName = "TESTNAME";

 

Export(DistFolder + @"\Billeder\", FileName, ImageExportList, Eksport_DWF);

 

The Path and the Imageexport list is the same one I am using in the same code for image export, where they worked well

I have tried to add .dwf to the FileName

 

What do I do vrong ?

 

Anders Kaas

Tags (2)
5 REPLIES 5
Message 2 of 6

Hello Anders,

 

the DWF export method does not take a list of Element Ids as its third parameter. It takes a ViewSet instead, and that is what you have to provide. When you pass your imageExportList, which is a list of Element IDs, the run-time will try to find a matching override. It will believe that the SAT export is a better match, except for the option class, and that is the error you experience.

 

To fix it, construct a ViewSet object and add the views you want to export. Then pass this object as the third argument of the Export method together with our DWF options.

 

I hope this helps.

Arnošt Löbel
Message 3 of 6

Thanks Arnošt

 

That fixed that error, but now I got an error from Revit that..

exporting to DWF/DWFX requires that document is modifiable and that APIUtility.ValidateCanModifyDocument.Export(String,String,Viewset,DWFExportoptions,BATCHEXPORTOPTIONS) but I can't find anything about BATCHEXPORTOPTIONS anywhere ??

I have added the fulle ytext from Revit

 

Can you help me again, please

 

Regards

 

Anders

 

Message 4 of 6

Hello Anders,

 

I am sorry for the trouble you get to experience. I have not been watching the development around DWF export for a while, but, apparently, the responsible programmer(s) has/have altered the code that it now requires the API programmer to be in a transaction at the time of evoking DWF Export. I suppose they have done it so because they need to make some temporary changes. Therefore I suggest you modify your code as follows:

 

using (Transaction trans = new Transaction(document,"DWF Export"))
{
   trans.Start();
   document.Export(....); // the actual export method as you have it
   trans.RollBack();
}

 I hope it'll work now.

Arnošt Löbel
Message 5 of 6

Thanks

It worked insite the transaction 🙂

 

Anders

Message 6 of 6

Thank for the confirmation. I thought it might work.

 

However, please try to use the code exactly as I suggested. In my opinion, it is not quite kosher to export a document in an open transaction and I am quite sure the responsible programmers made that change just to get around some bigger road-block. So, even if a transaction is now required (apparently), try to make sure that you close whatever transaction you may or may not have prior to getting to the exporting part. That will ensure the model is up to date and perfectly valid. Then and only then open a transaction just for that one Export method, and always roll it back.

 

Thank you

Arnošt Löbel

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