IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.88k stars 735 forks source link

None return from shape.geometry on pythonocc >= 7.8.0 #4942

Closed smr02 closed 4 months ago

smr02 commented 4 months ago

i have the following code and i'm running it in two different conda envs:

    import ifcopenshell
    import ifcopenshell.geom

    ifc_file = ifcopenshell.open('test.ifc')
    element = ifc_file.by_type('IfcBeam')[0]

    settings = ifcopenshell.geom.settings()
    settings.set(settings.USE_PYTHON_OPENCASCADE, True)

    shape = ifcopenshell.geom.create_shape(settings, element)
    print(shape)
    print()

    geometry = shape.geometry # see #1124
    print(geometry)

in the first one, it returns as expected:

shape_tuple(data=<ifcopenshell.ifcopenshell_wrapper.SerializedElement; proxy of <Swig Object of type 'IfcGeom::SerializedElement *' at 0x7171463a8b40> >, geometry=<class 'TopoDS_Compound'>, styles=((0.749019607843137, 0.537254901960784, 0.352941176470588, 1.0),), style_ids=(4117,))

<class 'TopoDS_Compound'>

in the second one shape.geometry is None, but i don't get any error. What am I missing?

shape_tuple(data=<ifcopenshell.ifcopenshell_wrapper.SerializedElement; proxy of <Swig Object of type 'IfcGeom::SerializedElement *' at 0x7094d2e3aa00> >, geometry=None, styles=((0.749019607843137, 0.537254901960784, 0.352941176470588, 1.0),), style_ids=(4117,))

None

in the not working env the following is installed:

```conda list # packages in environment at /home//miniconda3/envs/app: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge aiohttp 3.9.5 py310h2372a71_0 conda-forge aiosignal 1.3.1 pyhd8ed1ab_0 conda-forge alsa-lib 1.2.12 h4ab18f5_0 conda-forge aom 3.9.1 hac33072_0 conda-forge async-timeout 4.0.3 pyhd8ed1ab_0 conda-forge attr 2.5.1 h166bdaf_1 conda-forge attrs 23.2.0 pyh71513ae_0 conda-forge blinker 1.8.2 pypi_0 pypi blosc 1.21.5 hc2324a3_1 conda-forge bzip2 1.0.8 h5eee18b_6 c-ares 1.28.1 hd590300_0 conda-forge ca-certificates 2024.6.2 hbcca054_0 conda-forge cairo 1.18.0 h3faef2a_0 conda-forge certifi 2024.6.2 pypi_0 pypi charset-normalizer 3.3.2 pypi_0 pypi click 8.1.7 pypi_0 pypi dav1d 1.2.1 hd590300_0 conda-forge dbus 1.13.6 h5008d03_3 conda-forge double-conversion 3.3.0 h59595ed_0 conda-forge eigen 3.4.0 h00ab1b0_0 conda-forge expat 2.5.0 hcb278e6_1 conda-forge ffmpeg 6.1.1 gpl_h853fe30_113 conda-forge flask 3.0.3 pypi_0 pypi font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 h77eed37_2 conda-forge fontconfig 2.14.2 h14ed4e7_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge freeimage 3.18.0 h4b96d29_20 conda-forge freetype 2.12.1 h267a509_2 conda-forge fribidi 1.0.10 h36c2ea0_0 conda-forge frozenlist 1.4.1 py310h2372a71_0 conda-forge gettext 0.22.5 h59595ed_2 conda-forge gettext-tools 0.22.5 h59595ed_2 conda-forge gl2ps 1.4.2 hae5d5c5_1 conda-forge glew 2.1.0 h9c3ff4c_2 conda-forge glib 2.80.2 h8a4344b_1 conda-forge glib-tools 2.80.2 h73ef956_1 conda-forge gmp 6.3.0 hac33072_2 conda-forge gnutls 3.7.9 hb077bed_0 conda-forge graphite2 1.3.13 h59595ed_1003 conda-forge gst-plugins-base 1.22.9 h8e1006c_0 conda-forge gstreamer 1.22.9 h98fc4e7_0 conda-forge harfbuzz 8.5.0 hfac3d4d_0 conda-forge hdf4 4.2.15 h2a13503_7 conda-forge hdf5 1.14.3 nompi_hdf9ad27_105 conda-forge icu 73.2 h59595ed_0 conda-forge idna 3.7 pyhd8ed1ab_0 conda-forge ifcopenshell 0.7.0.240627 pypi_0 pypi imath 3.1.11 hfc55251_0 conda-forge isodate 0.6.1 pypi_0 pypi itsdangerous 2.2.0 pypi_0 pypi jinja2 3.1.4 pypi_0 pypi jsoncpp 1.9.5 h4bd325d_1 conda-forge jxrlib 1.1 hd590300_3 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge krb5 1.21.2 h659d440_0 conda-forge lame 3.100 h166bdaf_1003 conda-forge lark 1.1.9 pypi_0 pypi lcms2 2.16 hb7c19ff_0 conda-forge ld_impl_linux-64 2.38 h1181459_1 lerc 4.0.0 h27087fc_0 conda-forge libabseil 20240116.2 cxx17_h59595ed_0 conda-forge libaec 1.1.3 h59595ed_0 conda-forge libasprintf 0.22.5 h661eb56_2 conda-forge libasprintf-devel 0.22.5 h661eb56_2 conda-forge libass 0.17.1 h8fe9dca_1 conda-forge libblas 3.9.0 22_linux64_openblas conda-forge libcap 2.69 h0f662aa_0 conda-forge libcblas 3.9.0 22_linux64_openblas conda-forge libclang 15.0.7 default_h127d8a8_5 conda-forge libclang13 15.0.7 default_h5d6823c_5 conda-forge libcups 2.3.3 h4637d8d_4 conda-forge libcurl 8.8.0 hca28451_0 conda-forge libdeflate 1.20 hd590300_0 conda-forge libdrm 2.4.121 h4ab18f5_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 hd590300_2 conda-forge libevent 2.1.12 hf998b51_1 conda-forge libexpat 2.5.0 hcb278e6_1 conda-forge libffi 3.4.4 h6a678d5_1 libflac 1.4.3 h59595ed_0 conda-forge libgcc-ng 13.2.0 h77fa898_13 conda-forge libgcrypt 1.10.3 hd590300_0 conda-forge libgettextpo 0.22.5 h59595ed_2 conda-forge libgettextpo-devel 0.22.5 h59595ed_2 conda-forge libgfortran-ng 13.2.0 h69a702a_13 conda-forge libgfortran5 13.2.0 h3d2ce59_13 conda-forge libglib 2.80.2 h8a4344b_1 conda-forge libglu 9.0.0 hac7e632_1003 conda-forge libgomp 13.2.0 h77fa898_13 conda-forge libgpg-error 1.49 h4f305b6_0 conda-forge libhwloc 2.10.0 default_h5622ce7_1001 conda-forge libiconv 1.17 hd590300_2 conda-forge libidn2 2.3.7 hd590300_0 conda-forge libjpeg-turbo 3.0.0 hd590300_1 conda-forge liblapack 3.9.0 22_linux64_openblas conda-forge libllvm15 15.0.7 hb3ce162_4 conda-forge libnetcdf 4.9.2 nompi_h135f659_114 conda-forge libnghttp2 1.58.0 h47da74e_1 conda-forge libnsl 2.0.1 hd590300_0 conda-forge libogg 1.3.5 h27cfd23_1 libopenblas 0.3.27 pthreads_h413a1c8_0 conda-forge libopenvino 2024.2.0 h2da1b83_1 conda-forge libopenvino-auto-batch-plugin 2024.2.0 hb045406_1 conda-forge libopenvino-auto-plugin 2024.2.0 hb045406_1 conda-forge libopenvino-hetero-plugin 2024.2.0 h5c03a75_1 conda-forge libopenvino-intel-cpu-plugin 2024.2.0 h2da1b83_1 conda-forge libopenvino-intel-gpu-plugin 2024.2.0 h2da1b83_1 conda-forge libopenvino-intel-npu-plugin 2024.2.0 he02047a_1 conda-forge libopenvino-ir-frontend 2024.2.0 h5c03a75_1 conda-forge libopenvino-onnx-frontend 2024.2.0 h07e8aee_1 conda-forge libopenvino-paddle-frontend 2024.2.0 h07e8aee_1 conda-forge libopenvino-pytorch-frontend 2024.2.0 he02047a_1 conda-forge libopenvino-tensorflow-frontend 2024.2.0 h39126c6_1 conda-forge libopenvino-tensorflow-lite-frontend 2024.2.0 he02047a_1 conda-forge libopus 1.3.1 h7f98852_1 conda-forge libpciaccess 0.18 hd590300_0 conda-forge libpng 1.6.43 h2797004_0 conda-forge libpq 16.3 ha72fbe1_0 conda-forge libprotobuf 4.25.3 h08a7969_0 conda-forge libraw 0.21.1 h2a13503_2 conda-forge libsndfile 1.2.2 hc60ed4a_1 conda-forge libsqlite 3.45.2 h2797004_0 conda-forge libssh2 1.11.0 h0841786_0 conda-forge libstdcxx-ng 13.2.0 hc0a3c3a_13 conda-forge libsystemd0 255 h3516f8a_1 conda-forge libtasn1 4.19.0 h166bdaf_0 conda-forge libtheora 1.1.1 h7f8727e_3 libtiff 4.6.0 h1dd3fc0_3 conda-forge libunistring 0.9.10 h7f98852_0 conda-forge libuuid 2.38.1 h0b41bf4_0 conda-forge libva 2.21.0 h4ab18f5_2 conda-forge libvorbis 1.3.7 h9c3ff4c_0 conda-forge libvpx 1.14.1 hac33072_0 conda-forge libwebp-base 1.4.0 hd590300_0 conda-forge libxcb 1.15 h0b41bf4_0 conda-forge libxcrypt 4.4.36 hd590300_1 conda-forge libxkbcommon 1.7.0 h662e7e4_0 conda-forge libxml2 2.12.7 hc051c1a_1 conda-forge libzip 1.10.1 h2629f0a_3 conda-forge libzlib 1.3.1 h4ab18f5_1 conda-forge loguru 0.7.2 py310hff52083_1 conda-forge lz4-c 1.9.4 hcb278e6_0 conda-forge markupsafe 2.1.5 pypi_0 pypi mathutils 3.3.0 pypi_0 pypi mpg123 1.32.6 h59595ed_0 conda-forge msgpack-python 1.0.8 py310h25c7140_0 conda-forge multidict 6.0.5 py310h2372a71_0 conda-forge mysql-common 8.0.33 hf1915f5_6 conda-forge mysql-libs 8.0.33 hca2cd23_6 conda-forge ncurses 6.4 h6a678d5_0 nettle 3.9.1 h7ab15ed_0 conda-forge nlohmann_json 3.11.3 h59595ed_0 conda-forge nspr 4.35 h27087fc_0 conda-forge nss 3.98 h1d7d5a4_0 conda-forge numpy 1.26.4 py310hb13e2d6_0 conda-forge numpy-stl 3.1.1 pypi_0 pypi occt 7.8.1 all_hc3954f8_201 conda-forge ocl-icd 2.3.2 hd590300_1 conda-forge openexr 3.2.2 haf962dd_1 conda-forge openh264 2.4.1 h59595ed_0 conda-forge openjpeg 2.5.2 h488ebb8_0 conda-forge openssl 3.3.1 h4ab18f5_0 conda-forge p11-kit 0.24.1 hc5aa10d_0 conda-forge pcre2 10.44 h0f59acf_0 conda-forge pip 24.0 py310h06a4308_0 pixman 0.43.2 h59595ed_0 conda-forge proj 9.3.1 h1d62c97_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge pugixml 1.14 h59595ed_0 conda-forge pulseaudio-client 16.1 hb77b528_5 conda-forge pyparsing 3.1.2 pyhd8ed1ab_0 conda-forge python 3.10.13 hd12c33a_1_cpython conda-forge python-dateutil 2.9.0.post0 pypi_0 pypi python-utils 3.8.2 pypi_0 pypi python_abi 3.10 4_cp310 conda-forge pythonocc-core 7.8.1 all_h0eda030_200 conda-forge qt-main 5.15.8 h5810be5_19 conda-forge rapidjson 1.1.0.post20240409 hac33072_1 conda-forge readline 8.2 h5eee18b_0 requests 2.32.3 pypi_0 pypi setuptools 69.5.1 py310h06a4308_0 shapely 2.0.4 pypi_0 pypi six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.2.0 hdb0a2a9_1 conda-forge sqlite 3.45.2 h2c6b66d_0 conda-forge svgwrite 1.4.3 pyhd8ed1ab_0 conda-forge svt-av1 2.1.0 hac33072_0 conda-forge tbb 2021.12.0 h297d8ca_1 conda-forge tbb-devel 2021.12.0 h7c56ddd_1 conda-forge tk 8.6.13 noxft_h4845f30_101 conda-forge typing-extensions 4.12.2 hd8ed1ab_0 conda-forge typing_extensions 4.12.2 pyha770c72_0 conda-forge tzdata 2024a h04d1e81_0 urllib3 2.2.2 pypi_0 pypi utfcpp 4.0.5 ha770c72_0 conda-forge vtk 9.2.6 qt_py310h1234567_220 conda-forge vtk-base 9.2.6 qt_py310h1234567_220 conda-forge vtk-io-ffmpeg 9.2.6 qt_py310h1234567_220 conda-forge werkzeug 3.0.3 pypi_0 pypi wheel 0.43.0 py310h06a4308_0 wslink 2.1.1 pyhd8ed1ab_0 conda-forge x264 1!164.3095 h166bdaf_2 conda-forge x265 3.5 h924138e_3 conda-forge xcb-util 0.4.0 hd590300_1 conda-forge xcb-util-image 0.4.0 h8ee46fc_1 conda-forge xcb-util-keysyms 0.4.0 h8ee46fc_1 conda-forge xcb-util-renderutil 0.3.9 hd590300_1 conda-forge xcb-util-wm 0.4.1 h8ee46fc_1 conda-forge xkeyboard-config 2.42 h4ab18f5_0 conda-forge xorg-fixesproto 5.0 h7f98852_1002 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.1.1 hd590300_0 conda-forge xorg-libsm 1.2.4 h7391055_0 conda-forge xorg-libx11 1.8.9 h8ee46fc_0 conda-forge xorg-libxau 1.0.11 hd590300_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h0b41bf4_2 conda-forge xorg-libxfixes 5.0.3 h7f98852_1004 conda-forge xorg-libxrender 0.9.11 hd590300_0 conda-forge xorg-libxt 1.3.0 hd590300_1 conda-forge xorg-renderproto 0.11.1 h7f98852_1002 conda-forge xorg-xextproto 7.3.0 h0b41bf4_1003 conda-forge xorg-xf86vidmodeproto 2.3.1 h7f98852_1002 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.4.6 h5eee18b_1 yarl 1.9.4 py310h2372a71_0 conda-forge zlib 1.3.1 h4ab18f5_1 conda-forge zstd 1.5.6 ha6fb4c9_0 conda-forge ```
Andrej730 commented 4 months ago

Hi! Can you please share the .ifc file to reproduce the issue?

smr02 commented 4 months ago

Seems to happen with every file. Here's one:

test.ifc.txt

Moult commented 4 months ago

@Krande is this something you can recreate?

Krande commented 4 months ago

@smr02 and @Moult

Yes, I can recreate it:

/home/kristoffer/miniforge3/envs/ifcotest/bin/python /home/kristoffer/code/testing2/main.py 
shape_tuple(data=<ifcopenshell.ifcopenshell_wrapper.SerializedElement; proxy of <Swig Object of type 'IfcGeom::SerializedElement *' at 0x745343bf1d40> >, geometry=None, styles=((-1.0, -1.0, -1.0, 1.0),), style_ids=(-1,))

None

Process finished with exit code 0

Using the following linux environment created using

mamba create -n ifcotest ifcopenshell occt=*=*novtk* python=3.10 pythonocc-core=*=*novtk* lark

environment

# packages in environment at /home/kristoffer/miniforge3/envs/ifcotest:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
c-ares                    1.28.1               hd590300_0    conda-forge
ca-certificates           2024.6.2             hbcca054_0    conda-forge
cgal-cpp                  5.6.1                h096c278_1    conda-forge
eigen                     3.4.0                h00ab1b0_0    conda-forge
expat                     2.6.2                h59595ed_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_2    conda-forge
fontconfig                2.14.2               h14ed4e7_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freeimage                 3.18.0              h4b96d29_20    conda-forge
freetype                  2.12.1               h267a509_2    conda-forge
gmp                       6.3.0                hac33072_2    conda-forge
hdf5                      1.14.3          nompi_hdf9ad27_105    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
ifcopenshell              0.7.9           py310_novtk_h8585866_200    conda-forge
imath                     3.1.11               hfc55251_0    conda-forge
jxrlib                    1.1                  hd590300_3    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.21.3               h659f571_0    conda-forge
lark                      1.1.9              pyhd8ed1ab_0    conda-forge
lcms2                     2.16                 hb7c19ff_0    conda-forge
ld_impl_linux-64          2.40                 hf3520f5_7    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libaec                    1.1.3                h59595ed_0    conda-forge
libblas                   3.9.0           22_linux64_openblas    conda-forge
libboost                  1.84.0               hba137d9_3    conda-forge
libboost-devel            1.84.0               h00ab1b0_3    conda-forge
libboost-headers          1.84.0               ha770c72_3    conda-forge
libcblas                  3.9.0           22_linux64_openblas    conda-forge
libcurl                   8.8.0                hca28451_1    conda-forge
libdeflate                1.20                 hd590300_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 hd590300_2    conda-forge
libexpat                  2.6.2                h59595ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 14.1.0               h77fa898_0    conda-forge
libgfortran-ng            14.1.0               h69a702a_0    conda-forge
libgfortran5              14.1.0               hc5f4f2c_0    conda-forge
libgomp                   14.1.0               h77fa898_0    conda-forge
libiconv                  1.17                 hd590300_2    conda-forge
libjpeg-turbo             3.0.0                hd590300_1    conda-forge
liblapack                 3.9.0           22_linux64_openblas    conda-forge
libnghttp2                1.58.0               h47da74e_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libopenblas               0.3.27          pthreads_h413a1c8_0    conda-forge
libpng                    1.6.43               h2797004_0    conda-forge
libraw                    0.21.1               h2a13503_2    conda-forge
libsqlite                 3.46.0               hde9e2c9_0    conda-forge
libssh2                   1.11.0               h0841786_0    conda-forge
libstdcxx-ng              14.1.0               hc0a3c3a_0    conda-forge
libtiff                   4.6.0                h1dd3fc0_3    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libwebp-base              1.4.0                hd590300_0    conda-forge
libxcb                    1.16                 hd590300_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxml2                   2.12.7               hc051c1a_1    conda-forge
libzlib                   1.3.1                h4ab18f5_1    conda-forge
mpfr                      4.2.1                h9458935_1    conda-forge
ncurses                   6.5                  h59595ed_0    conda-forge
numpy                     1.26.4          py310hb13e2d6_0    conda-forge
occt                      7.8.1           novtk_h44cb049_102    conda-forge
openexr                   3.2.2                haf962dd_1    conda-forge
openjpeg                  2.5.2                h488ebb8_0    conda-forge
openssl                   3.3.1                h4ab18f5_1    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pyparsing                 3.1.2              pyhd8ed1ab_0    conda-forge
python                    3.10.14         hd12c33a_0_cpython    conda-forge
python_abi                3.10                    4_cp310    conda-forge
pythonocc-core            7.8.1           novtk_h1101785_100    conda-forge
rapidjson                 1.1.0.post20240409      hac33072_1    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                70.1.1             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
svgwrite                  1.4.3              pyhd8ed1ab_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
wheel                     0.43.0             pyhd8ed1ab_1    conda-forge
xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
xorg-libice               1.1.1                hd590300_0    conda-forge
xorg-libsm                1.2.4                h7391055_0    conda-forge
xorg-libx11               1.8.9                hb711507_1    conda-forge
xorg-libxau               1.0.11               hd590300_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xorg-libxt                1.3.0                hd590300_1    conda-forge
xorg-xextproto            7.3.0             h0b41bf4_1003    conda-forge
xorg-xproto               7.0.31            h7f98852_1007    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zstd                      1.5.6                ha6fb4c9_0    conda-forge

Got same results for Windows also

tldddd commented 4 months ago

Same results for me on Windows, minimal example:

import ifcopenshell
import ifcopenshell.geom

file_path = "1019-column.ifc"
ifc = ifcopenshell.open(file_path)
products = ifc.by_type("IfcProduct")

settings = ifcopenshell.geom.settings()
settings.set("use-python-opencascade", True)

shape = ifcopenshell.geom.create_shape(settings, products[0])

print(shape.geometry)
print(shape)

Returns:

None
shape_tuple(data=<ifcopenshell.ifcopenshell_wrapper.SerializedElement; proxy of <Swig Object of type 'IfcGeom::SerializedElement *' at 0x0000022297ADB210> >, geometry=None, styles=((-1.0, -1.0, -1.0, 1.0),), style_ids=(-1,))
Andrej730 commented 4 months ago

Related issue - https://github.com/tpaviot/pythonocc-core/issues/1350