Read text file line by line

Hello everyone,

unfortunately I couldn’t find a solution: how can I read a text file line by line?

Best regards


What output do you want?
Try to use the String.Split with a \n string.

1 Like


Thank you for the information.

IFC files with a minimum of 400 megabytes are to be processed.

Reading line by line is then surely better than File.ReadText?

Best regards


Not sure I completely understand.
Do you want to only ‘load’ part of the IFC at a time (Line-by-line)?
Is the txt file also 400 MB?

Can you please share the file, or some concept of what you want to achieve so its easier to help :slight_smile:


the ifc file is at least 400 MB in size.

Office_A_20110811.ifc.txt (3.9 MB)

Lines containing certain texts (e.g. “IFCCOLOURRGB”, “IFCSURFACESTYLE”, “IFCSTYLEDITEM” etc.) are deleted from the file and the file is then saved again (with a different name).

Best regards


like this?

import sys
filePath = IN[0]
with open(filePath, "r") as file:
	mylines = [file.readline().strip('\n') for i in range(IN[1])]
	lastLine = mylines[-1]

OUT = mylines, lastLine

Hi Cyril,

thanks, so it works with Python Script (i’m learning it!).

Line-by-line import is only possible with Python Script , or is there also a Dynamo version?

Best regards


Like this, maybe?
It takes less than a second to run, if that’s what you are afraid of, with the File.Readtext node?


the sample IFC file is only 4MB.

With the planned use, the files will be at least 400 MB (up to approx. 1000 MB) in size.

My test with 400MB showed a good speed for File.ReadText with String.Split. File.ReadText with String.Split can therefore be used.

Python Script is then used when required.

Thanks very much.

Best regards


What is the intent in this modification?

I would recommend extreme caution here. Modifying the IFCs like this can lock you out in the near or long term as one missing reference can corrupt the whole data series. While some applications may not care, others will, and the larger team may not be able to work with the file. This includes current IFC applications, historic applications, and even ones which don’t yet exist.


Hi JacobSmall,

I am aware of the potential problems of manipulating IFC files.

Unfortunately, in 2021 the Revit IFC interface will still not be able to adopt material properties such as ThermalConductivity, SpecificHeatCapacity and MassDensity for an IFC-Link.
Only the graphical properties are adopted.
The thermal properties can only be generated as Revit material using Dynamo by deleting the graphical properties in front of the IFC-Link.

Importing material from an IFC link is imperative because “stupid” architecture models are unusable for HVAC engineers.

Best regards


1 Like

Ah! Glad to hear this wasn’t for an extended multi user workflow but a ‘get the project done’ one.

Do you know of the materiality is fixed in 2022, and if the Revit team who works on IFC is aware of the issue? If not I can try and escalate for you.

1 Like

In the current version IFC.for.Revit.2022.2.1.0, the import of material is not solved.
This problem has been asked by many users for years - with no result.
You are welcome to ask the development team.
Another urgent requirement is the takeover of rooms or MEP rooms.

Best regards


I can second the rooms/spaces export issue - this is probably one of the most requested items I’ve seen since IFC and Revit were related to one another. Development team is likely aware, but know that you’re one of many hoping for that feature soon! I believe there are workarounds for this using Rhino Inside and/or Geometry Gym that some people use to extract room/space volumes and append them outside Revit to IFC.

Interesting method for correcting an IFC file as well, it may be worth contacting Dion Moult (he goes by ‘Moult’ on most IFC boards) about this, might be an interesting case for the osarch team to be aware of. Wonder if the IfcPythonShell project has any overlap with this sort of use case.

The use of Dynamo for Revit to make Revit more open in nature is not without a sense of irony.

1 Like

Hi Garvin,

on the subject “Development team is likely aware”:

My Message
Sent: Tuesday, April 20, 2021 3:46 AM
To: Angel Velez <[angel.velez@a
Subject: Ifc Link and ROOM

Hi Angel Velez-Sosa,

please excuse my poor google english.
I am writing to you as an HVAC engineer, since you are the head of Ifc- “contributed by Autodesk and our Open Source contributors”.

Ifc Import creates (architecture) room, but Ifc Link does not create a room.
I can not understand that.

The program code for “Rooms” is therefore available in the Ifc Import branch.
The program code of IfcSpace.cs, for example, only has approx. 100 lines (without comments).
What is the problem with using this function with Ifc Link as well?

All HVAC engineers are waiting for “rooms” to take over from Ifc Link - a great result can be achieved with little work!

When will this important function “rooms” finally be activated for Ifc Link? We can’t wait until IFC5!

The helpful answer:
From: Angel Velez [mailto:angel.velez@a
Sent: Dienstag, 20. April 2021 15:14
Subject: Ifc Link and ROOM

Thanks for reaching out to me – that is on our roadmap, and we will be sending out a survey soon to ask people about their most important requests for IFC, so be on the lookout for that!


I have big eyes and yet I couldn’t see a poll! :frowning:

We solved the problem of “rooms” with Dynamo. But not every Revit user can do this for himself. In my opinion, Autodesk is clearly responsible for this!
Autodesk has no real interest in OpenBIM. Autodesk is always on the brakes and tries to delay the process as long as possible.

Best regeards to the southern hemisphere


1 Like

Unfortunately I have to agree in most regards. Revit seems to be one of the only platforms not moving towards open data standards and IFC export. I am not sure it is intentional or just through the archaic nature or Revit’s setup behind the scenes.

Probably getting a bit off topic but I appreciate your sharing the update. They have sent a few polls out now but not sure how much has come from it yet.