Open multiple Ifc's

since i’m not that developed in Python maybe someone can help me?
i’m trying to open multiple Ifc’s to batch convert them to .rvt but the script is complaining i’m feeding a list instead of a string. is there a way to let the script accept multiple files?

image

Hi @lennart030,

A For Loops should do the trick :

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

#input IFC file paths:
IFCfilepaths = IN[0]

for IFCfilepath in IFCfilepaths :
	IFCopen = app.OpenIFCDocument(IFCfilepath)

#Save resulting Revit file to the destination path:
OUT = IFCopen.SaveAs(IN[1])

it seems to work but revit keeps looping opening the IFC instead of saving it and opening the next.
i think I’ll try to replace the out for a [0] and saving the ifc’s via some node’s
or do you know a better way with Python?

I tested and it’s necessary to close each IFC.

Here is the script :

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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


IFCfilepaths = IN[0]
RVTfilepaths=[]
for IFCfilepath in IFCfilepaths :
	IFCopen = app.OpenIFCDocument(IFCfilepath)
	RVTfilepath=IFCfilepath.replace(".ifc", ".rvt", 1)
	IFCopen.SaveAs(RVTfilepath)
	IFCopen.Close(False)
	RVTfilepaths.append(RVTfilepath)

OUT = RVTfilepaths 

works like a charm. thanks