IFC Batch Export : Classification settings

Hello,

does anyone have an idea how to adjust the classification settings in the IFC batch export custom nodes or Python script ?

it worked using:
options.AddOption(“ClassificationName”,“x”)
options.AddOption(“ClassificationFieldName”,“x”)

1 Like

Hey,

I’m not fluent in Python. Could you please explain how to implement this option to be able to adjust classification for IFC export?

Hi @piotr.bocian,

Maybe this topic can point you in the right direction.
https://forum.dynamobim.com/t/export-a-model-using-different-sites/91208/6?u=mjb-online

which python code are you using?
it has to be added to the lines where the other options are.
image

I’m using node from Genius Loci, it has python script as follows:

#Based on a Nicklas Verdier Østergaard's script, nvo@niras.dk
#https://github.com/Autodesk/revit-ifc/tree/2810c479e27819da97656759a1dda28cbdde0538/Source
#Revised by Alban de Chasteigner

import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

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

folder=UnwrapElement(IN[0])
view = tolist(UnwrapElement(IN[1]))
name=tolist(UnwrapElement(IN[2]))
fileversion = IN[3]
Projectorigin = IN[4]
inputPhase = UnwrapElement(IN[5])
userDefinedPset = IN[6]
revitInternalPset = IN[7]
wallandcolumnsplitting = IN[8]
exportbasequantities = IN[9]

if inputPhase != None:
	phaseString=str(inputPhase.Id)
else:
	pass

if userDefinedPset != "":
	userDefPsetBool= "true"
else:
	userDefPsetBool= "false"

if revitInternalPset ==True:
	revitInternalPset= "true"
else:
	revitInternalPset= "false"

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",revitInternalPset)
	options.AddOption("ExportIFCCommonPropertySets","true")	
	options.AddOption("ExportAnnotations ","true")
	options.AddOption("SpaceBoundaries ", "0")
	options.AddOption("ExportRoomsInView", "false")	
	options.AddOption("Use2DRoomBoundaryForVolume ", "true")
	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")
	
	#True doesn't work. It would be necessary to use OpenInBackground method.
	options.AddOption("ExportLinkedFiles", "false")
	
	options.AddOption("IncludeSiteElevation","true")
	options.AddOption("StoreIFCGUID", "true")
	options.AddOption("VisibleElementsOfCurrentView ", "true")
	options.AddOption("UseActiveViewGeometry", "true")
	options.AddOption("TessellationLevelOfDetail", "0,5")
	options.AddOption("ExportUserDefinedPsets",userDefPsetBool)
	if userDefinedPset != "":
		options.AddOption("ExportUserDefinedPsetsFileName",userDefinedPset)	
	else:
		pass
	if inputPhase != None:
		options.AddOption("ActivePhase", phaseString)
	else:
		pass
	options.AddOption("SitePlacement", IN[4])	
#	options.AddOption("ClassificationName","x")
#	options.AddOption("ClassificationFieldName","x")

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

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

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

But don’t know how to add the option.

they are in the code but disabled. i have adjusted the script you only need to all two inputs to the python node (10: Classification Name) and (11: Classification Field Name) and use the following code:

import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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

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

folder=UnwrapElement(IN[0])
view = tolist(UnwrapElement(IN[1]))
name=tolist(UnwrapElement(IN[2]))
fileversion = IN[3]
Projectorigin = IN[4]
inputPhase = UnwrapElement(IN[5])
userDefinedPset = IN[6]
revitInternalPset = IN[7]
wallandcolumnsplitting = IN[8]
exportbasequantities = IN[9]
clN = IN[10]
clFN = IN[11]


if inputPhase != None:
	phaseString=str(inputPhase.Id)
else:
	pass

if userDefinedPset != "":
	userDefPsetBool= "true"
else:
	userDefPsetBool= "false"

if revitInternalPset ==True:
	revitInternalPset= "true"
else:
	revitInternalPset= "false"

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",revitInternalPset)
	options.AddOption("ExportIFCCommonPropertySets","true")	
	options.AddOption("ExportAnnotations ","true")
	options.AddOption("SpaceBoundaries ", "0")
	options.AddOption("ExportRoomsInView", "false")	
	options.AddOption("Use2DRoomBoundaryForVolume ", "true")
	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")
	
	#True doesn't work. It would be necessary to use OpenInBackground method.
	options.AddOption("ExportLinkedFiles", "false")
	
	options.AddOption("IncludeSiteElevation","true")
	options.AddOption("StoreIFCGUID", "true")
	options.AddOption("VisibleElementsOfCurrentView ", "true")
	options.AddOption("UseActiveViewGeometry", "true")
	options.AddOption("TessellationLevelOfDetail", "0,5")
	options.AddOption("ExportUserDefinedPsets",userDefPsetBool)
	if userDefinedPset != "":
		options.AddOption("ExportUserDefinedPsetsFileName",userDefinedPset)	
	else:
		pass
	if inputPhase != None:
		options.AddOption("ActivePhase", phaseString)
	else:
		pass
	options.AddOption("SitePlacement", IN[4])	
	options.AddOption("ClassificationAltName",clN)
	options.AddOption("ClassificationFieldName",clFN)

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

# End Transaction
TransactionManager.Instance.TransactionTaskDone()

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

Replaced Python code with yours @Mohamad_Kayali and modified node as on picture, but it doesn’t export classification

i have edited the code will you try again to copy it and run your script?
and remember outside the node you need to provide string inputs

Tried your code one more time and still doesn’t export classification options. String inputs are as on picture (now for test)

does the parameter in revit called test2 and does it contain values?
otherwise please upload the revit file with the dynamo script you’re using.

No, there is no parameter called test2. It’s just string for testing purpose. What type of data does it expect? Isn’t it string?

correct it is a string but the string should be the name of a revit parameter. the script will export the value of that parameter under certain name (test1). the name can be anything but the classification field name not. so now if you make a project parameter in revit and add a value to that parameter (for example “x”). you will get in the ifc viewer (test1 : “x” )

Tried to do so, but still doesn’t work

i have tried as well it didn’t work! but when i filled classification name in export settings in revit and a run the dynamo script it did work!




It worked because you filled them in export settings in revit not because of dynamo.
Additionally is there any way to adjust other classification setting in dynamo like on picture?

correct, i have tried to fix them but they’re not working!
@Alban_de_Chasteigner do you have any idea how to solve it?