get solid geometry with IfcOpenShell 0.8.3

edited May 31 in General

We're trying to switch to 0.8.x ...

  • We do extract geometry out of ifc in brep format.
  • We do process this geometry by the use of FreeCAD.

Follows up:

PS: I made a related post on FreeCAD forum but after some more work on this I realized this is more a IfcOpenShell problem ... thus this post here ... https://forum.freecad.org/viewtopic.php?t=97333

paullee

Comments

  • Just the setting names became strings

    >>> st = ifcopenshell.geom.settings()
    >>> st.set('use-python-opencascade', True)
    

    OpenCASCADE is not gone. It's just there is also the possibility to use CGAL now, which is currently of no use when you want to interface with FreeCAD

  • edited June 1

    Thomas, thanks for the hint, but somehow OCC is not part of the ifcopenshell which comes with pip ?

    on windows ... in a PowerShell ...

    (myvenv) PS C:\0_BHA_privat\BIMTesterCode\myvenv\Scripts>
    (myvenv) PS C:\0_BHA_privat\BIMTesterCode\myvenv\Scripts> python -m pip install ifcopenshell
    Requirement already satisfied: ifcopenshell in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (0.8.2)
    Requirement already satisfied: numpy in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (1.26.4)
    Requirement already satisfied: python-dateutil in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (2.9.0.post0)
    Requirement already satisfied: shapely in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (2.1.1)
    Requirement already satisfied: lark in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (1.2.2)
    Requirement already satisfied: isodate in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (0.7.2)
    Requirement already satisfied: typing-extensions in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from ifcopenshell) (4.13.2)
    Requirement already satisfied: six>=1.5 in c:\0_bha_privat\bimtestercode\myvenv\lib\site-packages (from python-dateutil->ifcopenshell) (1.17.0)
    
    [notice] A new release of pip available: 22.3.1 -> 25.1.1
    [notice] To update, run: python.exe -m pip install --upgrade pip
    (myvenv) PS C:\0_BHA_privat\BIMTesterCode\myvenv\Scripts>
    

    in Python:

    Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    >>> import ifcopenshell
    >>> ifcopenshell.version
    '0.8.2'
    >>>
    >>> from ifcopenshell import geom
    >>> settings = geom.settings()
    >>> settings.set('use-python-opencascade', True)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\0_BHA_privat\BIMTesterCode\myvenv\lib\site-packages\ifcopenshell\geom\main.py", line 179, in set
        raise AttributeError("Python OpenCASCADE is not installed")
    AttributeError: Python OpenCASCADE is not installed
    >>>
    >>>
    
  • is there a version to download available which includes Python OpenCascade, which could I copy to my site-packages manually ?

  • Thomas, thanks for the hint, but somehow OCC is not part of the ifcopenshell which comes with pip ?

    No, but that has always been the case. The OCC C++ code is linked in into the executable, but PythonOCC is not packaged as part of the python module. Easiest way to install is using anaconda conda install -c conda-forge pythonocc

  • Ahh, I got the point now ...

  • edited June 2

    @aothms said:

    Thomas, thanks for the hint, but somehow OCC is not part of the ifcopenshell which comes with pip ?

    No, but that has always been the case. The OCC C++ code is linked in into the executable, but PythonOCC is not packaged as part of the python module. Easiest way to install is using anaconda conda install -c conda-forge pythonocc

    I still have som missunderstandings, because it works without installing PythonOCC for 0.7.x

    # 0.7.x
    import ifcopenshell
    ifcopenshell.version
    from ifcopenshell import geom
    settings = geom.settings()
    settings.set(settings.USE_BREP_DATA, True)
    settings.set(settings.SEW_SHELLS, True)
    settings.set(settings.USE_WORLD_COORDS, True)
    ifcpath = 'C:/Users/BHA/Desktop/exporter.ifc'
    ifcfile = ifcopenshell.open(ifcpath)
    p=ifcfile.by_type("IfcBuildingElement")[0]
    p.Name
    p.GlobalId
    cr = ifcopenshell.geom.create_shape(settings, p)
    brep = cr.geometry.brep_data
    brep
    
    >>>
    >>> import ifcopenshell
    >>> ifcopenshell.version
    'v0.7.0-c7830e9e5'
    >>> from ifcopenshell import geom
    >>> settings = geom.settings()
    >>> settings.set(settings.USE_BREP_DATA, True)
    >>> settings.set(settings.SEW_SHELLS, True)
    >>> settings.set(settings.USE_WORLD_COORDS, True)
    >>> ifcpath = 'C:/Users/BHA/Desktop/exporter.ifc'
    >>> ifcfile = ifcopenshell.open(ifcpath)
    >>> p=ifcfile.by_type("IfcBuildingElement")[0]
    >>> p.Name
    'Beschriftung_meshed'
    >>> p.GlobalId
    '3CUsmHJ1r0x96Xw23d0w_r'
    >>> cr = ifcopenshell.geom.create_shape(settings, p)
    >>> brep = cr.geometry.brep_data
    >>> brep
    '\nCASCADE Topology V1, (c) Matra-Datavision\nLocations 1\n1\n              1               0               0  102.2121953125 \n              0               1               0   74.7216015625 \n              0               0               1    -4.415953125 \nCurve2ds 0\nCurves 93\n1 0 0.32534374999999999 0.18697265625000001 0 0.35813583799135751 -0.93366949267191335 \n1 0 0.32534374999999999 0.18697265625000001 0 -1 0 \n1 0 0.29871874999999998 0.18697265625000001 0 -0.37838207834077947 -0.92564950320869954 \n1 0 0.2222890625 0 0 1 0 \n1 0 0.2504374999999
    ...
    -65 0 *\nFa\n0  1e-07 30 0\n\n0101000\n-26 0 *\nEd\n 1e-07 1 1 0\n1  88 0 0 0.015\n0\n\n0101000\n+64 0 -39 0 *\nWi\n\n0101100\n+27 0 -36 0 -24 0 -63 0 *\nFa\n0  1e-07 31 0\n\n0101000\n-23 0 *\nEd\n 1e-07 1 1 0\n1  89 0 0 0.015\n0\n\n0101000\n+62 0 -41 0 *\nWi\n\n0101100\n+24 0 -38 0 -21 0 -61 0 *\nFa\n0  1e-07 32 0\n\n0101000\n-20 0 *\nEd\n 1e-07 1 1 0\n1  90 0 0 0.015\n0\n\n0101000\n+60 0 -44 0 *\nWi\n\n0101100\n+21 0 -40 0 -18 0 -59 0 *\nFa\n0  1e-07 33 0\n\n0101000\n-17 0 *\nEd\n 1e-07 1 1 0\n1  91 0 0 0.015\n0\n\n0101000\n+58 0 -43 0 *\nWi\n\n0101100\n+18 0 +42 0 -15 0 -57 0 *\nFa\n0  1e-07 34 0\n\n0101000\n-14 0 *\nEd\n 1e-07 1 1 0\n1  92 0 0 0.015\n0\n\n0101000\n+56 0 -32 0 *\nWi\n\n0101100\n-55 0 +15 0 -30 0 -12 0 *\nFa\n0  1e-07 35 0\n\n0101000\n-11 0 *\nEd\n 1e-07 1 1 0\n1  93 0 0 0.015\n0\n\n0101000\n+70 0 -34 0 *\nWi\n\n0101100\n-54 0 +12 0 -31 0 -9 0 *\nFa\n0  1e-07 36 0\n\n0101000\n-8 0 *\nWi\n\n0101100\n+69 0 +9 0 -33 0 -50 0 *\nFa\n0  1e-07 37 0\n\n0101000\n-6 0 *\nSh\n\n0101100\n+52 0 +45 0 +28 0 +25 0 +22 0 +19 0 +16 0 +13 0 +10 0 +7 0 \n+5 0 *\nSo\n\n0100000\n+4 0 *\nCo\n\n0100000\n+141 0 +72 0 +3 0 *\nCo\n\n1100000\n+2 1 *\n\n+1 0 '
    >>>
    
  • Ah that's what you mean. That indeed doesn't depend on pythonocc.
    settings.set(settings.USE_BREP_DATA, True)
    became
    settings.set('iterator-output', ifcopenshell.ifcopenshell_wrapper.SERIALIZED)

  • edited June 2

    great :-) thanks very much Thomas ...

    >>> import ifcopenshell
    >>> ifcopenshell.version
    '0.8.2'
    >>>
    >>> from ifcopenshell import geom
    >>> settings = geom.settings()
    >>> settings.set('iterator-output', ifcopenshell.ifcopenshell_wrapper.SERIALIZED)
    >>>
    >>> ifcpath = 'C:/Users/BHA/Desktop/exporter.ifc'
    >>> ifcfile = ifcopenshell.open(ifcpath)
    >>>
    >>> p = ifcfile.by_type("IfcBuildingElement")[0]
    >>> p.Name
    'Beschriftung_meshed'
    >>> p.GlobalId
    '3CUsmHJ1r0x96Xw23d0w_r'
    >>>
    >>> cr = ifcopenshell.geom.create_shape(settings, p)
    >>> brep = cr.geometry.brep_data
    >>>
    >>> brep
    '\nCASCADE Topology V2, (c) Matra-Datavision\nLocations 0\nCurve2ds 0\nCurves 93\n1 0 0.32534374999999999 0.18697265625000001 0 -1 0 \n1 0 0.32534374999999999 0.18697265625000001 0 0.35813583799135751 -0.93366949267191335 \n1 0 0.39706249999999998 0 0 -1 0 \n1 0 0.37082031250000003 0 0 -0.34250248078992379 0.93951692409
    
    paullee
  • You probably still want to set the other settings

    st.set('reorient-shells', True)
    st.set('use-world-coords', True)

  • ahh for sure, because they are not included in iterator-output ...

    Eventually the problem was, I was totally on the wrong track ...

  • for reference ...

    import ifcopenshell
    # ifcopenshell.version
    from ifcopenshell import geom as ifcgeom
    settings = ifcgeom.settings()
    settings.set('iterator-output', ifcopenshell.ifcopenshell_wrapper.SERIALIZED)
    settings.set('reorient-shells', True)
    settings.set('use-world-coords', True)
    ifcpath = 'C:/Users/BHA/Desktop/exporter.ifc'
    ifcfile = ifcopenshell.open(ifcpath)
    p = ifcfile.by_type("IfcBuildingElement")[0]
    p.Name
    p.GlobalId
    cr = ifcopenshell.geom.create_shape(settings, p)
    brep = cr.geometry.brep_data
    brep
    
    
    semhustejBedsonpaulleewalpa
Sign In or Register to comment.