IFC Export settings, IFCFileType

Hey,

I am trying to export an IFC file as IFCzip. But i cant seem to get the settings right for a zip file.
My current script i modified from the Genius Loci Package:

# Proposed by Nicklas Verdier Østergaard, nvo@niras.dk
# https://github.com/pzurek/ifcexporter/blob/master/IFCExporterUI/Source/IFCExportConfiguration.cs
# Revised by Alban de Chasteigner

import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application


def tolist(obj1):
    if hasattr(obj1, "__iter__"):
        return obj1
    else:
        return [obj1]


folder = UnwrapElement(IN[0])
name = tolist(UnwrapElement(IN[1]))
view = tolist(UnwrapElement(IN[2]))
fileversion = IN[3]
wallandcolumnsplitting = IN[4]
exportbasequantities = IN[5]
Projectorigin = IN[6]
if isinstance(IN[7], list):
    inputdoc = IN[7]
else:
    inputdoc = [IN[7]]

# Inputdoc : Part of script by Andreas Dieckmann
if inputdoc[0] == None:
    doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc[0].GetType().ToString() == "Autodesk.Revit.DB.Document":
    doc = inputdoc[0]
else:
    doc = DocumentManager.Instance.CurrentDBDocument

t = Transaction(doc, 'export')
t.Start()
result = []

for i, v in enumerate(view):
    options = IFCExportOptions()

    # if fileversion != None:
    #	options.FileVersion = fileversion
    if fileversion == "IFC4":
        options.FileVersion = IFCVersion.IFC4
    if fileversion == "IFC4RV":
        options.FileVersion = IFCVersion.IFC4RV
    if fileversion == "IFC4DTV":
        options.FileVersion = IFCVersion.IFC4DTV
    if fileversion == "IFC2x2":
        options.FileVersion = IFCVersion.IFC2x2
    if fileversion == "IFC2x3":
        options.FileVersion = IFCVersion.IFC2x3
    if fileversion == "IFC2x3CV2":
        options.FileVersion = IFCVersion.IFC2x3CV2
    if fileversion == "IFC2x3BFM":
        options.FileVersion = IFCVersion.IFC2x3BFM
    if fileversion == "IFC2x3FM":
        options.FileVersion = IFCVersion.IFC2x3FM
    if fileversion == "IFCBCA":
        options.FileVersion = IFCVersion.IFCBCA
    if fileversion == "IFCCOBIE":
        options.FileVersion = IFCVersion.IFCCOBIE
    if fileversion == "":
        options.FileVersion = IFCVersion.Default

    options.WallAndColumnSplitting = wallandcolumnsplitting

    options.FilterViewId = v.Id
    options.AddOption("ExportBaseQuantities", "true");
    options.AddOption("SplitWallsAndColumns", "false");
    options.AddOption("ExportInternalRevitPropertySets", "true");
    options.AddOption("ExportIFCCommonPropertySets", "true");
    options.AddOption("Export2DElements", "true");
    options.AddOption("VisibleElementsOfCurrentView", "true");
    options.AddOption("Use2DRoomBoundaryForVolume", "false");
    options.AddOption("UseFamilyAndTypeNameForReference", "true");
    options.AddOption("ExportPartsAsBuildingElements", "false");
    options.AddOption("ExportSolidModelRep", "false");
    options.AddOption("ExportSchedulesAsPsets", "false");
    options.AddOption("ExportUserDefinedPsets", "true");
    options.AddOption("ExportUserDefinedPsetsFileName", "P:/Revit/14_IFC/HEK Revit ILS_OenE Propertyset.txt")
    options.AddOption("ExportUserDefinedParameterMapping", "false");
    options.AddOption("ExportUserDefinedParameterMappingFileName", "");
    options.AddOption("ExportBoundingBox", "false");
    options.AddOption("IncludeSiteElevation", "false");
    options.AddOption("UseActiveViewGeometry", "true");
    options.AddOption("ExportSpecificSchedules", "false");
    options.AddOption("TessellationLevelOfDetail", "0.5");
    options.AddOption("UseOnlyTriangulation", "false");
    options.AddOption("StoreIFCGUID", "false");
    options.AddOption("ExportRoomsInView", "false");
    options.AddOption("ExportLinkedFiles", "false");
    options.AddOption("ActiveViewId", "-1");
    options.AddOption("ExcludeFilter", "");
    options.AddOption("COBieCompanyInfo", "");
    options.AddOption("COBieProjectInfo", "");
    options.AddOption("IncludeSteelElements", "true");
    options.AddOption("UseTypeNameOnlyForIfcType", "false");
    options.AddOption("UseVisibleRevitNameAsEntityName", "true");
    options.AddOption("GeoRefCRSName", "");
    options.AddOption("GeoRefCRSDesc", "");
    options.AddOption("GeoRefEPSGCode", "");
    options.AddOption("GeoRefGeodeticDatum", "");
    options.AddOption("GeoRefMapUnit", "");
    options.AddOption("IsBuiltIn", "false");
    options.AddOption("IsInSession", "false");
# IFCVersion Version = (IFCVersion) Enum.Parse( typeof(IFCVersion), UnwrapElement(IN[3]), true );
# x.FileVersion = IFCVersion.IFC2x3CV2

    c = doc.Export(folder, name[i], options)
    result.append(c)

t.Commit()

if fileversion == "":
    OUT = "Default settings used"
else:
    OUT = 'Success'

Is there some API documentation about AddOption?

Here’s a sample of an JSON file with saved configuration.

{
  "IFCVersion": 21,
  "ExchangeRequirement": 3,
  "IFCFileType": 2,
  "ActivePhaseId": -1,
  "SpaceBoundaries": 0,
  "SitePlacement": 0,
  "SplitWallsAndColumns": false,
  "IncludeSteelElements": true,
  "GeoRefCRSName": "XXXXXX",
  "GeoRefCRSDesc": "XXXXXX",
  "GeoRefEPSGCode": "XXXXXX",
  "GeoRefGeodeticDatum": "XXXXXX",
  "GeoRefMapUnit": "METRE",
  "ProjectAddress": {
    "UpdateProjectInformation": false,
    "AssignAddressToSite": false,
    "AssignAddressToBuilding": true
  },
  "Export2DElements": false,
  "ExportLinkedFiles": false,
  "VisibleElementsOfCurrentView": false,
  "ExportRoomsInView": false,
  "ExportInternalRevitPropertySets": false,
  "ExportIFCCommonPropertySets": true,
  "ExportBaseQuantities": false,
  "ExportSchedulesAsPsets": false,
  "ExportSpecificSchedules": false,
  "ExportUserDefinedPsets": false,
  "ExportUserDefinedPsetsFileName": "C:\\Program Files\\Autodesk\\Revit 2022\\AddIns\\IFCExporterUI\\DefaultUserDefinedParameterSets.txt",
  "ExportUserDefinedParameterMapping": false,
  "ExportUserDefinedParameterMappingFileName": "",
  "ClassificationSettings": {
    "ClassificationName": null,
    "ClassificationEdition": null,
    "ClassificationSource": null,
    "ClassificationEditionDate": "\/Date(-62135596800000)\/",
    "ClassificationLocation": null,
    "ClassificationFieldName": null
  },
  "TessellationLevelOfDetail": 0.5,
  "ExportPartsAsBuildingElements": false,
  "ExportSolidModelRep": false,
  "UseActiveViewGeometry": false,
  "UseFamilyAndTypeNameForReference": false,
  "Use2DRoomBoundaryForVolume": false,
  "IncludeSiteElevation": false,
  "StoreIFCGUID": false,
  "ExportBoundingBox": false,
  "UseOnlyTriangulation": false,
  "UseTypeNameOnlyForIfcType": false,
  "UseVisibleRevitNameAsEntityName": false,
  "ExcludeFilter": "",
  "COBieCompanyInfo": "",
  "COBieProjectInfo": "",
  "Name": "zip",
  "ActiveViewId": -1,
  "IsBuiltIn": false,
  "IsInSession": false,
  "FileVersionDescription": "IFC 2x3 Coordination View 2.0"
}

*Edited - I have removed misleading information

2 Likes

Hey,
This did not do it for me.
I Added the code but i still get a normal IFC.

# Proposed by Nicklas Verdier Østergaard, nvo@niras.dk
# https://github.com/pzurek/ifcexporter/blob/master/IFCExporterUI/Source/IFCExportConfiguration.cs
# Revised by Alban de Chasteigner

import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit

clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application


def tolist(obj1):
    if hasattr(obj1, "__iter__"):
        return obj1
    else:
        return [obj1]


folder = UnwrapElement(IN[0])
name = tolist(UnwrapElement(IN[1]))
view = tolist(UnwrapElement(IN[2]))
fileversion = IN[3]
wallandcolumnsplitting = IN[4]
exportbasequantities = IN[5]
Projectorigin = IN[6]
if isinstance(IN[7], list):
    inputdoc = IN[7]
else:
    inputdoc = [IN[7]]

# Inputdoc : Part of script by Andreas Dieckmann
if inputdoc[0] == None:
    doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc[0].GetType().ToString() == "Autodesk.Revit.DB.Document":
    doc = inputdoc[0]
else:
    doc = DocumentManager.Instance.CurrentDBDocument

t = Transaction(doc, 'export')
t.Start()
result = []

for i, v in enumerate(view):
    options = IFCExportOptions()

    # if fileversion != None:
    #	options.FileVersion = fileversion
    if fileversion == "IFC4":
        options.FileVersion = IFCVersion.IFC4
    if fileversion == "IFC4RV":
        options.FileVersion = IFCVersion.IFC4RV
    if fileversion == "IFC4DTV":
        options.FileVersion = IFCVersion.IFC4DTV
    if fileversion == "IFC2x2":
        options.FileVersion = IFCVersion.IFC2x2
    if fileversion == "IFC2x3":
        options.FileVersion = IFCVersion.IFC2x3
    if fileversion == "IFC2x3CV2":
        options.FileVersion = IFCVersion.IFC2x3CV2
    if fileversion == "IFC2x3BFM":
        options.FileVersion = IFCVersion.IFC2x3BFM
    if fileversion == "IFC2x3FM":
        options.FileVersion = IFCVersion.IFC2x3FM
    if fileversion == "IFCBCA":
        options.FileVersion = IFCVersion.IFCBCA
    if fileversion == "IFCCOBIE":
        options.FileVersion = IFCVersion.IFCCOBIE
    if fileversion == "":
        options.FileVersion = IFCVersion.Default

    options.WallAndColumnSplitting = wallandcolumnsplitting

    options.FilterViewId = v.Id
    options.AddOption("ExportBaseQuantities", "true");
    options.AddOption("SplitWallsAndColumns", "false");
    options.AddOption("ExportInternalRevitPropertySets", "true");
    options.AddOption("ExportIFCCommonPropertySets", "true");
    options.AddOption("Export2DElements", "true");
    options.AddOption("VisibleElementsOfCurrentView", "true");
    options.AddOption("Use2DRoomBoundaryForVolume", "false");
    options.AddOption("UseFamilyAndTypeNameForReference", "true");
    options.AddOption("ExportPartsAsBuildingElements", "false");
    options.AddOption("ExportSolidModelRep", "false");
    options.AddOption("ExportSchedulesAsPsets", "false");
    options.AddOption("ExportUserDefinedPsets", "true");
    options.AddOption("ExportUserDefinedPsetsFileName", "P:/Revit/14_IFC/HEK Revit ILS_OenE Propertyset.txt")
    options.AddOption("ExportUserDefinedParameterMapping", "false");
    options.AddOption("ExportUserDefinedParameterMappingFileName", "");
    options.AddOption("ExportBoundingBox", "false");
    options.AddOption("IncludeSiteElevation", "false");
    options.AddOption("UseActiveViewGeometry", "true");
    options.AddOption("ExportSpecificSchedules", "false");
    options.AddOption("TessellationLevelOfDetail", "0.5");
    options.AddOption("UseOnlyTriangulation", "false");
    options.AddOption("StoreIFCGUID", "false");
    options.AddOption("ExportRoomsInView", "false");
    options.AddOption("ExportLinkedFiles", "false");
    options.AddOption("ActiveViewId", "-1");
    options.AddOption("ExcludeFilter", "");
    options.AddOption("COBieCompanyInfo", "");
    options.AddOption("COBieProjectInfo", "");
    options.AddOption("IncludeSteelElements", "true");
    options.AddOption("UseTypeNameOnlyForIfcType", "false");
    options.AddOption("UseVisibleRevitNameAsEntityName", "true");
    options.AddOption("GeoRefCRSName", "");
    options.AddOption("GeoRefCRSDesc", "");
    options.AddOption("GeoRefEPSGCode", "");
    options.AddOption("GeoRefGeodeticDatum", "");
    options.AddOption("GeoRefMapUnit", "");
    options.AddOption("IsBuiltIn", "false");
    options.AddOption("IsInSession", "false");
    options.AddOption("Name", "zip");
    options.AddOption("SitePlacement", Projectorigin); 
# IFCVersion Version = (IFCVersion) Enum.Parse( typeof(IFCVersion), UnwrapElement(IN[3]), true );
# x.FileVersion = IFCVersion.IFC2x3CV2

    c = doc.Export(folder, name[i], options)
    result.append(c)

t.Commit()

if fileversion == "":
    OUT = "Default settings used"
else:
    OUT = 'Success'

Hi @MelleH,

I think these are the options you are looking for.

options.AddOption("IFCFileType", "0") # "File type"
	#  0 = IFC
	#  1 = IFC XML
	#  2 = Zipped IFC
	#  3 = Zipped IFC XML
3 Likes

It does the trick.

This code is for pyRevit, but it’s quite clear.

import pyrevit
from pyrevit import DB, revit

options = DB.IFCExportOptions()
options.AddOption("IFCFileType", "3")

with revit.Transaction("Export"):
    revit.doc.Export("d:\\", "test", options)
2 Likes

Okay this seems to work for Revit 2022.
I was testing in 2021 and couldn’t get it to work so it seems to be a 2022+ thing.
Thanks all!

1 Like