If you're reading this, we've just migrated servers! If anything looks broken please email dion@thinkmoult.com :)

[IfcOpenShell-Python] convert from ifc to ifczip and back

Is there in IfcOpenShell-Python already a function implemented to create from ifc ifczip and vis versa?

Comments

  • I did now create my own litte python script for it:

    from zipfile import ZipFile, ZIP_DEFLATED
    from pathlib import Path
    
    def ifc2ifczip(path_ifc):
        path_ifczip = path_ifc.split(".")[0]+'.ifczip'
        with ZipFile(path_ifczip, 'w', ZIP_DEFLATED, compresslevel=9) as zip:
            zip.write(path)
        filesize_ifc = Path(path_ifc).stat().st_size
        filesize_ifczip = Path(path_ifczip).stat().st_size
        print('ifczip created: ' + path_ifczip)
        print("Size of ifc is :", filesize_ifc/1000, "megabytes")
        print("Size of ifczip is :", filesize_ifczip/1000, "megabytes")
    
    def ifczip2ifc(path_ifczip):
        with ZipFile(path_ifczip, 'r') as zip:
            zip.printdir()
            print('Extracting the ifc-file now...')
            zip.extractall()
            print('Done!')
    
    

    If there are any suggestions for improvement, please write them :D

    Coen
Sign In or Register to comment.