OSArch Community

[IfcOpenShell-Python] How to update an ifc2x3 to ifc4 with a script?

  1. M

    So in BlenderBIM there is the possibility to update an ifc2x3 to ifc4

    What is the command behind it? so that can be used for an script?

  2. T

    does this get you started?

  3. M
  4. M

    So i wrote that little script. The varibale path_to_directory is just a directory, the script takes all the ifc file in a given directory and tries to make an IFC4 and optimize a litte bit.

    
    import ifcpatch
    
    import ifcopenshell
    
    from pathlib import Path
    
    
    for path in path_to_directory.glob("*.ifc"):
    
        abs_path = path.resolve()
    
        name = path.name
    
        model = ifcopenshell.open(abs_path)
    
        output = ifcpatch.execute({"input": name, 
    
                      "file": model,"recipe": "Migrate", "arguments": ["IFC4"]})
    
    
    
        new_name_ifc4 =  f"IFC4-{name}"
    
        path_to_new = new_Folder / new_name_ifc4
    
        ifcpatch.write(output, str(path_to_new))
    
    
    
        output_2 = ifcpatch.execute({"input": new_name_ifc4,"file": output, "recipe": "RecycleNonRootedElements", "arguments": []})
    
    
    
        name_ifc4_opt =  f"Opt-IFC4-{name}"
    
    
    
        path_to_new = new_Folder / name_ifc4_opt
    
    
    
        ifcpatch.write(output,  str(path_to_new))
    

Login or Register to reply.