Hello all
Trying to ease our process into our collaboration with Civil 3D users and Revit by working with Revit.
Since our Civil 3D users are exporting each network per 1 IFC files, this can get teadious when linking an IFC file in Revit.
Now I managed to write a little python script code and i’m not quite sure how to work with the IFCImportOptions class
But hey, i’m here to learn so i’m reaching out for guidance here ![]()
Here’s my code :
import clr
import System
import os
# Import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIIFC')
from Autodesk.Revit.DB.IFC import *
# Import RevitServices
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
# Input directory path
directory_path = IN[0]
# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument
# Get all IFC files in the directory
ifc_files = [f for f in os.listdir(directory_path) if f.endswith('.ifc')]
# Initialize the list to store results
imported_files = []
# Start a transaction to import IFC files
TransactionManager.Instance.EnsureInTransaction(doc)
for ifc_file in ifc_files:
ifc_path = os.path.join(directory_path, ifc_file)
try:
# Create IFC import options
options = IFCImportOptions()
# Import the IFC file
result = doc.Import(ifc_path, options)
imported_files.append(result)
except Exception as e:
# Append error message in case of failure
imported_files.append(str(e))
TransactionManager.Instance.TransactionTaskDone()
# Output the result
OUT = imported_files
I think this may be a big learning curve for me right now but, am i going in the right direction with this approach ?




