IFC export with custom setup possible?

Hi all,

what i’m trying to set up is the “Current selected setup:”

is there a way to select this setup inside python?
if not, maybe there is a workaround to achieve the same settings?

This is the setup: (differences to IFC2x3 Coordination view 2.0 Setup are marked red)
image
image
image
image
image

In @Alban_de_Chasteigners package, Genius Loci, you can find an IFC export node that allows for some costumization. But if you open the node and look into the python, I believe he’s included loads of actions but commented them out in the script. Have a look and add what you need :slightly_smiling_face:

2 Likes

Thanks! i ll look in to this on monday when i m back at the computer :slight_smile:

I have looked inside the Pyton code and only found a few that could help me.
Any idea which one of these options it is and how to include the costum setup?

options.AddOption("ExportSchedulesAsPsets", "false");
options.AddOption("ExportSpecificSchedules", "false");
options.AddOption("ExportUserDefinedPsets","false");
options.AddOption("ExportUserDefinedPsetsFileName","the filepath")

Thanks

I’ve altered Albans code and used a python snippet from @c.poupin to allow users to use an export setting

You can read about it here

1 Like

Neat!
Uhm, I have only very limited knowledge of coding, how did you get that dropdown menu working?
I only ever need one specific setting so it would make it easier if I could preselect that and have a one click IFC export.
But thanks so far!
*Also: What packages are you using?

Hi,

I can send the DYN file in like half an hour or something.
The dropdown menu is from datashapes, but you could also just fill in the name in the script and never change it if thats what you want.
This dyn file uses datashapes and GeniusLoci

1 Like

@Chrissi
Export IFC with config.dyn (30.0 KB)

I removed all my inputs and replaced them with a codeblock with a description. Replace the codeblocks with the correct inputs and it should work

1 Like

Thank you!

If my limited coding is correct, there seems to be an issue with the Name of the IFC Export Setup.
Either the format of the Name makes issues or it’s another problem.
The name on the code fragment and the one listed in the Export Setup are the same.

Sorry, last time I coded was probably 4 years ago for an arduino ^^’
Edit: I installed all packages referenced in this project, so it should work

error

can you show the output of the tryGetValue node?

The Python Script returns “Empty Directory”, thus the .TryGetValue returns “null”

Seems like it’s simply not able to find your settings.
Are you sure the settings are in the project?

I really don’t know.
Tried central models, local models and cloud models, all return the same error.
Couldn’t even find which directory they normally would be stored in

Hmm, i wonder if @c.poupin can help you out with this…

1 Like

I guess I figured it out with a collegue of mine by accident.
Context: We are from Germany.
While exporting a IFC File manually, we realised some values weren’t beeing exported as expected.
Turns out, launching Revit with the english language pack causes variables to change names, which breakes the IFC settings.

I suspect the german base version has other value names, would make sense it returns null.

As launching Revit in English didn’t fix the issue, maybe the paths and variables at instalation matter.

If it works on another english Version of Revit, it’s a local issue

I only added a current Day directory for the file name.
If anyone wants to try it:

Export IFC with config_Chris.dyn (43.5 KB)

It is possible to update IFCExportOptions from IFCExportConfiguration

code 1

import clr
import sys
import System

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


clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument
app = uiapp.Application
sdkNumber = int(app.VersionNumber)


IFCExportConfiguration = None
IFCExportConfigurationsMap = None
pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
pf_data_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData)
ifc_bundle_path = "{0}\\Autodesk\\ApplicationPlugins\\IFC {1}.bundle\\Contents\\{1}".format(pf_data_path, sdkNumber)
if System.IO.Directory.Exists(ifc_bundle_path):
	# 1st try
	sys.path.append(ifc_bundle_path)
	clr.AddReference("IFCExporterUIOverride")
	from BIM.IFC.Export.UI import IFCExportConfigurationsMap, IFCExportConfiguration, IFCCommandOverrideApplication
else:
	ifc_addin_path = "{}\\Autodesk\\Revit {}\\AddIns\IFCExporterUI".format(pf_path, sdkNumber)
	if System.IO.Directory.Exists(ifc_addin_path):
		# 2nd try
		sys.path.append(ifc_addin_path)
		clr.AddReference("Autodesk.IFC.Export.UI")
		from BIM.IFC.Export.UI import IFCExportConfigurationsMap, IFCExportConfiguration, IFCCommandOverrideApplication

import json

ifc_dict_config = {}
if IFCExportConfigurationsMap is not None:
	idfdocA = IFCCommandOverrideApplication.TheDocument
	if idfdocA is None:
		propinfo = clr.GetClrType(IFCCommandOverrideApplication).GetProperty('TheDocument')
		propinfo.SetValue(None, doc)
	configurationsMap = IFCExportConfigurationsMap()
	configurationsMap.AddBuiltInConfigurations()
	configurationsMap.AddSavedConfigurations()
	for config in configurationsMap.Values:
		print(config.GetType())
		#dict_ifc_version_str = {"IFC_Version_str": config.IFCVersion.ToString() }
		#dict_config = json.loads(config.SerializeConfigToJson())
		# merge dictionaries
		#merge_dict_3 = dict(dict_ifc_version_str,**dict_config)
		ifc_dict_config[config.Name] = config
  
OUT = ifc_dict_config

code 2

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

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


# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
sdkNumber = int(app.VersionNumber)

my_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)

myIFCExportConfiguration = IN[0]

TransactionManager.Instance.EnsureInTransaction(doc)
options = IFCExportOptions()

#Define the of a 3d view to export
exportViewId = ElementId.InvalidElementId 

# Pass the setting of the myIFCExportConfiguration to the IFCExportOptions
myIFCExportConfiguration.UpdateOptions(options, exportViewId)
TransactionManager.Instance.TransactionTaskDone()

doc.Export(my_path, "test330.ifc", options)

OUT = options, options.FileVersion
3 Likes

Thank you so much for responding!

I copied it, but it fails to return anything. Must be something going on on my end, no idea.
I found the directionaries, so they exist, but it fails to catch them.

I have installed these packages:

image

Do you have the IFC exporter installed?

1 Like

This?

image