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.

1 Like

works like a charm. thanks

Hi,

When using the python code u supplied to batch open IFC files it works but;

When linking those .rvt files the geometry shows in a 3D view but not in plan view, where when i link the IFC files directly they do show up in the plan view so it must be something in the workflow/nodes used in the script.

Hi,
Try instead with the Link IFC node of the Genius Loci package.
The script in this thread was only a “work in progress”.

Hi Alban,

I have the script working, but now I’m getting errors.

situation 1: when I run the script, I get the following message at the end of every imported ifc file.
Schermafbeelding 2022-01-26 154800

situation 2: if I import the ifc 1 by 1 via manage links, it works fine.

when I look in the folder where the ifc files are located, the file name is also different between situation 1 and 2.
situation 1: filename.rvt
situation 2: filename.ifc.rvt

any idea what this could be?

No, I don’t know.

It can be changed in the python script but I’m not sure it is related to the error message.

Hi,

This node requires a single file input right?
I’d like to convert multiple IFC files in a folder to .rvt without linking them into my project.

The reason behind this is; after the models are converted i save them as a cloud model to BIM360 so they work as published models that show up in my own model when publishing.

At this moment i also get a “null” returned from my path, this wasnt the case before…

maybe close your dyn file and reopen can solve it. it is possible to do multiple files as mentioned above

Re-creating the script made the null dissapear, sadly it only creates 1 .rvt file while there are 2 .ifc files inside the folder.

Any suggestions in how to solve this?

maybe set list level @1 on the link IFC node

maybe remove the created rvt file and txt log file and try it again?

That seems to do the trick, i still havent figured out how to use those levels properly :unamused:
Thank you for that!

(Introducing List@Level: Working with Lists Made Easier - Dynamo BIM)

Back to “null” again with Revit 2023

Referencing directly to the Ifc files also gives a null