Export ifc access denied

Export ifc access denied

dante.van.wettum
Advocate Advocate
1,329 Views
3 Replies
Message 1 of 4

Export ifc access denied

dante.van.wettum
Advocate
Advocate

the code:

 

try
                                {
                                    ifcExport(doc, v, "name_of_file", "C:\\test123\\ifc_out");
                                }
                                catch (Exception ex) { File.AppendAllLines(path, new string[] { "ifcExport Exception: " + ex.Message }); }

 

public void ifcExport(Document doc, Autodesk.Revit.DB.View viewExport, string filename, string path)
{
IFCExportOptions ifcOptions = new IFCExportOptions();
ifcOptions.ExportBaseQuantities = true;
ifcOptions.FamilyMappingFile = "C:\\test123\\SAS_IFC-export.txt";
ifcOptions.FileVersion = IFCVersion.IFC2x3;
ifcOptions.FilterViewId = viewExport.Id;
ifcOptions.WallAndColumnSplitting = true;

doc.Export(path, filename, ifcOptions);
}

but for some reason it keeps giving me this error message, no matter what folder i choose to export to.

Access to the path 'C:\test123\ifc_out' is denied.

 

and to make the case even stranger, if i make an nwc export to the exact same folder and that works without any errors or warnings.

 

I have no idea why it does give me this error for an ifc file while i can write other file types to the folder without any issues.

 

Edit:

it made me also wonder, when i installed the IFC for revit (from Autodesk) do i even need to call the default doc.export ? or is there another method i should be calling to make the ifc exports ?

0 Likes
Accepted solutions (1)
1,330 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Dante,

 

Thank you for your query.

 

That does sound strange indeed.

 

What happens if you specify no path at all?

 

Oh no, I see that the folder must exist, according to the docs:

 

http://www.revitapidocs.com/2018.1/7efa4eb3-8d94-b8e7-f608-3dbae751331d.htm

 

For testing purposes, I would use the simplest possible one, and one that belongs to you, e.g., your Windows home folder, or run Revit as administrator, so that it has more powerful access when writing files.

 

The output filename can be left empty, it seems.

 

Afaik, the IFC for Revit is automatically hooked up to the standard doc.Export method.

 

I would also try raising this question in the IFC for Revit discussion forum:

 

https://sourceforge.net/p/ifcexporter/discussion/general

 

They are presumably the most experienced with all IFC-related questions.

 

Best regards,

 

Jeremy

 



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

Message 3 of 4

dante.van.wettum
Advocate
Advocate

its is really strange as i get it working for Dwg / nwc and whatsoever.

 

made absolutely sure the dir exists by doublechecking with the Directory.exists(path) bool. its returning a true (as i knew should 😉 )

So i tried running as Admin: nope...

 

 

so the next step was to try a an empty string "" and that already gave me a more sensible error message:

"Modifying  is forbidden because the document has no open transaction."

 

Although i think its is a strange message. after all, Why would an export need an transaction ?

but the good thing is, it worked !!

 

so it seems that the IFC export needs to be done within an transaction, while the other exports (nwc/dwg) do not need an transaction.

 

so the final step was to again try to set a name, with the only difference that the export is done within an transaction:

All worked as designed! 

 

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Dante,

 

Thank you for your update.

 

Aha!

 

A simple case of RTFM:

 

http://www.revitapidocs.com/2018.1/7efa4eb3-8d94-b8e7-f608-3dbae751331d.htm

 

Export Method (String, String, IFCExportOptions)

 

Remarks

 

Exporting to IFC requires that document is modifiable, therefore there must be a transaction already open when this method is called. 

 

This method may not be invoked during dynamic update, for the internal routine might need to modify the existing transaction.

 

I noticed that remark when I checked yesterday, but omitted explicitly pointing it out...

 

Glad you found it!

 

Best regards,

 

Jeremy

 



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

0 Likes