IFC export AddOptions don't work

python
revit
dynamo
#1

Hi guys,

I am using the custom node “Export IFC” from GeniusLoci.
This Python script refers to AddOptions such as: options.AddOption(“ExportLinkedFiles”, “false”)

However, despite all the comments on these forums the options don’t seem to do anything here…
If i set the ExportLinkedFiles option to “true” it doesn’t export the linked file in my model.
None of the options seem to work, tested multiple.
Am i doing something wrong here? If so, what can i do to fix this problem?

The Python script:

#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 *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

folder=UnwrapElement(IN[0])
name=UnwrapElement(IN[1])
view = UnwrapElement(IN[2])
fileversion = IN[3]
wallandcolumnsplitting = IN[4]
exportbasequantities = IN[5]
Projectorigin = IN[6]

#IFCVersion=UnwrapElement(IN[3])

TransactionManager.Instance.EnsureInTransaction(doc)
result = []

for i,v in enumerate(view):
	options=IFCExportOptions()
	
	#if fileversion != None:
	#	options.FileVersion = fileversion
	if fileversion == "IFC4":
		options.FileVersion = IFCVersion.IFC4
	if fileversion == "IFC2x2":
		options.FileVersion = IFCVersion.IFC2x2
	if fileversion == "IFC2x3":
		options.FileVersion = IFCVersion.IFC2x3
	if fileversion == "IFC2x3":
		options.FileVersion = IFCVersion.IFC2x3CV2
	if fileversion == "IFCBCA":
		options.FileVersion = IFCVersion.IFCBCA
	if fileversion == "IFCCOBIE":
		options.FileVersion = IFCVersion.IFCCOBIE
	if fileversion == "":
		options.FileVersion = IFCVersion.Default
		
	options.WallAndColumnSplitting = wallandcolumnsplitting
	options.ExportBaseQuantities = exportbasequantities
	options.FilterViewId = v.Id
	options.AddOption("ExportInternalRevitPropertySets","true");
	options.AddOption("ExportIFCCommonPropertySets","true");	
	options.AddOption("ExportAnnotations ","true");
	options.AddOption("SpaceBoundaries ", "0");
	options.AddOption("ExportRoomsInView", "false");	
	options.AddOption("Use2DRoomBoundaryForVolume ", "false");
	options.AddOption("UseFamilyAndTypeNameForReference ", "true");
	options.AddOption("Export2DElements", "false");
	options.AddOption("ExportPartsAsBuildingElements", "false");
	options.AddOption("ExportBoundingBox", "false");
	options.AddOption("ExportSolidModelRep", "true");
	options.AddOption("ExportSchedulesAsPsets", "false");
	options.AddOption("ExportSpecificSchedules", "false");
	#Doesn't work. It would be necessary to use OpenInBackground.
	options.AddOption("ExportLinkedFiles", "false");
	options.AddOption("IncludeSiteElevation","true");
	options.AddOption("StoreIFCGUID", "true");
	options.AddOption("VisibleElementsOfCurrentView", "true");
	options.AddOption("UseActiveViewGeometry", "true");
	options.AddOption("TessellationLevelOfDetail", "1");
 	options.AddOption("ExportUserDefinedPsets","false");
 	options.AddOption("SitePlacement", IN[6]);
#	options.AddOption("ExportUserDefinedPsetsFileName","the filepath")
#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)

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

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

Thanks in advance :slight_smile:

0 Likes

#2

Hi @m.morsink

First read the Revit IFC manual.
Tons of information there.

Then have you installed the Revit IFC exporter from

This gives you extra options.

If so, have you chosen the IFC4 format?

0 Likes

#3

Hi @m.morsink,

I’m glad you find the package Genius Loci useful.

Did you see the comment above the line "options.AddOption(“ExportLinkedFiles” ?
I wrote “It doesn’t work because it would be necessary to use OpenInBackground.”

When you use the IFC export in Revit, you will see that the linked files will be opened a few seconds.
So with dynamo, you need to do the same thing : open all the linked files in background to export them in IFC.

Hope that makes sense.

0 Likes

#4

@m.rijsmus:
thank you for your fast reply. I am familiar with the manual for IFC, and i have IFC for Revit installed on my pc. I also tried to use multiple IFC types. Didn’t help unfortunately…

@Alban_de_Chasteigner:
Thank you for your fast reply. I noticed the note in the pythonscript. Maybe i used the wrong example for this topic. But none of the Options seem to work.
F.e. the “ExportRoomsInView” doesn’t work either.
Btw. I am using Revit 2017 at the moment, not sure if that can influence the success?

0 Likes

#5

Autodesk have made efforts to improve IFC export in Revit 2018 and again in Revit 2019, so yes

0 Likes

#6

Hi,

I tried with options.AddOption(“ExportRoomsInView”, “true”); and it worked perfectly :

Did you notice that “ExportRoomsInView” and “UseActiveViewGeometry” must be set together on true ?
Export%20rooms

Is the IFC file exported when you edit the python script ?

0 Likes

#7

Hi,

yes, i am aware of the dependency of those two with the IFC export option!

as you can see, both are set to “true”. When i change the status from “false” to “true” the node still works, and it exports to IFC like it’s supposed to do, but not with the options i want it to have.
Maybe it’s the Revit version that’s causing the problems, like @m.rijsmus says…

0 Likes

#8

My previous try was with Revit 2018 and I have now tested with Revit 2017.
It works, so the error is probably not inside the python script.
Do you edit the custom node “Export IFC” and save changes or do you copy the python script to your graph ?

0 Likes

#9

ah, okay, so the version is not the problem…
I edit the custom node “Export IFC” and save changes

0 Likes

#10

Can you confirm that you are exporting a 3D view ?

0 Likes

#11

3D%20view

see pictures above. As you can see, i selected a 3D view, called PINO.
I used the .dyn file you sent in your reply. But as you can see the Rooms are not exported…

0 Likes

#12

When I open an IFC file with Naviswork, I can not find any room either !
Open your IFC with Tekla Bimsigth or Solibri instead. :grinning:

0 Likes

#13

damn… that’s the problem, i assumed it would be visible in any program
When i load the IFC file back into Revit it shows the room with the correct name.

Thanks a lot!

0 Likes

#14

I have just released an update which includes IFC export… Would be great to get this tested for external linked files as well :slight_smile:

0 Likes