Menu

Combining multiple IFC files into 1 file

Jango
2019-06-10
2019-06-11
  • Jango

    Jango - 2019-06-10

    I'm trying to combine a number of IFC files that were exported from Revit. The reason they are separate files is because Revit can't export a project with linked elements as one IFC.
    I'm using Python and I haven't installed Qt or OCC as I figured it is unnecessary for this use case.
    The code I've been trying is this:

    import ifcopenshell
    
    new_file = ifcopenshell.open()
    
    old_files = list(map(ifcopenshell.open, [
        "wall1.ifc",
        "wall2.ifc"
    ]))
    
    for old_file in old_files:
        for inst in old_file:
            new_file.add(inst)
    
    new_file.write("merged.ifc")
    

    In BIMCollab I check out the resulting IFC file, but as the attachment shows, it just "unreferenced items" and doesn't show any geometry.

    How would I go about combining several IFC files and what are the pitfalls I need to be aware of?

     

    Last edit: Jango 2019-06-10
  • Thomas Krijnen

    Thomas Krijnen - 2019-06-11

    Hi,

    unreferenced items

    Not a very descriptive error message, but first of all, be sure to check with a recent version of IfcOpenShell, preferably https://github.com/IfcOpenBot/IfcOpenShell/commit/1a5716287343163d4dc137dea762553f91833ac6#commitcomment-33675356 I think there have been bugs previously.

    what are the pitfalls I need to be aware of?

    Well there is a major one in the sense that IFC has pretty strict requirements in what the project hierarchy is supposed to look like. There can be only one IfcProject and decomposition and placement hierarchies should match. Your approach will create two disjoint IfcProject trees, but some viewers will allow that. If you want to do this fully correctly, you need to somehow merge the IfcProject > Site > Building > Storey tree.

    Qt or OCC

    Your correct, they're not necessary in this case.

    Kind regards,
    Thomas

     

Log in to post a comment.