CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.22k stars 293 forks source link

Model works when using rect().extrude(), hangs when using box() #698

Open marcus7070 opened 3 years ago

marcus7070 commented 3 years ago

To Reproduce

In the following, result0 will work fine, result1 will not perform the final cut and will not print "finished!".

import cadquery as cq
from cadquery.selectors import AreaNthSelector

result0 = (
    cq.Workplane("XY")
    .rect(20, 20)
    .extrude(10)
    .edges("|Z or <Z")
    .fillet(2)
    .faces(">Z")
    .shell(2)
    .faces(">Z")
    .wires(AreaNthSelector(-1))
    .toPending()
    .workplane()
    .offset2D(-1)
    .extrude(1)
    .faces(">Z[-2]")
    .wires(AreaNthSelector(0))
    .toPending()
    .workplane()
    .cutBlind(2)
)

print(f"rect -> extrude is valid? {result0.val().isValid()}")

result1 = (
    cq.Workplane("XY")
    .box(20, 20, 10, centered=(True, True, False))
    .edges("|Z or <Z")
    .fillet(2)
    .faces(">Z")
    .shell(2)
    .faces(">Z")
    .wires(AreaNthSelector(-1))
    .toPending()
    .workplane()
    .offset2D(-1)
    .extrude(1)
    .faces(">Z[-2]")
    .wires(AreaNthSelector(0))
    .toPending()
    .workplane()
)
print("about to cut")
result1 = (
    result1
    .cutBlind(2)
)
print("finished!")

Code is adapted from here.

Here is a screenshot of result0: screenshot2021-03-19-085133

Environment

OS: Ubuntu 20.04

Was CadQuery installed using Conda?: Yes.

Output of `conda list` from your active Conda environment: ``` # packages in environment at /home/marcus/miniconda: # # Name Version Build Channel _libgcc_mutex 0.1 main alabaster 0.7.12 py_0 conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge argh 0.26.2 pyh9f0ad1d_1002 conda-forge astroid 2.5.1 py38h578d9bd_0 conda-forge async_generator 1.10 py_0 conda-forge atomicwrites 1.4.0 pyh9f0ad1d_0 conda-forge attrs 20.3.0 pyhd3deb0d_0 conda-forge autopep8 1.5.6 pyhd8ed1ab_0 conda-forge babel 2.9.0 pyhd3deb0d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.1 py_0 conda-forge black 20.8b1 py_1 conda-forge bleach 3.3.0 pyh44b312d_0 conda-forge brotlipy 0.7.0 py38h27cfd23_1003 bzip2 1.0.8 h516909a_3 conda-forge ca-certificates 2020.12.5 ha878542_0 conda-forge cadquery master py3.8 cadquery certifi 2020.12.5 py38h578d9bd_1 conda-forge cffi 1.14.3 py38h261ae71_2 chardet 3.0.4 py38h06a4308_1003 click 7.1.2 pyh9f0ad1d_0 conda-forge cloudpickle 1.6.0 py_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge conda 4.9.2 py38h578d9bd_0 conda-forge conda-package-handling 1.7.2 py38h03888b9_0 cq-editor master py3.8 cadquery cryptography 3.2.1 py38h3c74f83_1 curl 7.71.1 he644dc0_3 conda-forge dataclasses 0.8 pyhc8e2a94_1 conda-forge dbus 1.13.16 hb2f20db_0 decorator 4.4.2 py_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge diff-match-patch 20200713 pyh9f0ad1d_0 conda-forge docutils 0.16 py38h578d9bd_3 conda-forge double-conversion 3.1.5 he1b5a44_2 conda-forge eigen 3.3.8 h0efe328_0 conda-forge entrypoints 0.3 pyhd8ed1ab_1003 conda-forge expat 2.2.9 he1b5a44_2 conda-forge ezdxf 0.14.2 py_0 conda-forge ffmpeg 4.3.1 h3215721_1 conda-forge flake8 3.8.4 py_0 conda-forge fontconfig 2.13.1 he4413a7_1000 conda-forge freeimage 3.18.0 he1b5a44_0 conda-forge freetype 2.10.4 h7ca028e_0 conda-forge future 0.18.2 py38h578d9bd_3 conda-forge gl2ps 1.4.2 he06d7ca_0 conda-forge glew 2.1.0 he1b5a44_0 conda-forge glib 2.67.4 h36276a3_1 gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.6.13 h85f3911_1 conda-forge gst-plugins-base 1.14.0 hbbd80ab_1 gstreamer 1.14.0 h28cd5cc_2 hdf4 4.2.13 hf30be14_1003 conda-forge hdf5 1.10.6 nompi_h7c3c948_1111 conda-forge helpdev 0.7.1 pyhd8ed1ab_0 conda-forge icu 58.2 hf484d3e_1000 conda-forge idna 2.10 py_0 imagesize 1.2.0 py_0 conda-forge importlib-metadata 3.7.3 py38h578d9bd_0 conda-forge importlib_metadata 3.7.3 hd8ed1ab_0 conda-forge intervaltree 3.0.2 py_0 conda-forge ipykernel 5.5.0 py38h81c977d_1 conda-forge ipython 7.21.0 py38h81c977d_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge isort 5.7.0 pyhd8ed1ab_0 conda-forge jedi 0.17.2 py38h578d9bd_1 conda-forge jeepney 0.6.0 pyhd8ed1ab_0 conda-forge jinja2 2.11.3 pyh44b312d_0 conda-forge jpeg 9d h36c2ea0_0 conda-forge jsoncpp 1.8.4 hc9558a2_1002 conda-forge jsonschema 3.2.0 pyhd8ed1ab_3 conda-forge jupyter_client 6.1.12 pyhd8ed1ab_0 conda-forge jupyter_core 4.7.1 py38h578d9bd_0 conda-forge jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge keyring 23.0.0 py38h578d9bd_0 conda-forge krb5 1.17.2 h926e7f8_0 conda-forge lame 3.100 h14c3975_1001 conda-forge lazy-object-proxy 1.5.1 py38h25fe258_1 conda-forge ld_impl_linux-64 2.33.1 h53a641e_7 libblas 3.9.0 8_openblas conda-forge libcblas 3.9.0 8_openblas conda-forge libcurl 7.71.1 hcdd3856_3 conda-forge libedit 3.1.20191231 h14c3975_1 libffi 3.3 he6710b0_2 libgcc-ng 9.1.0 hdf63c60_0 libgfortran-ng 7.5.0 h14aa051_18 conda-forge libgfortran4 7.5.0 h14aa051_18 conda-forge libglu 9.0.0 he1b5a44_1001 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.9.0 8_openblas conda-forge libnetcdf 4.7.4 nompi_h56d31a8_107 conda-forge libogg 1.3.2 h516909a_1002 conda-forge libopenblas 0.3.12 pthreads_hb3c22a3_1 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libspatialindex 1.9.3 he1b5a44_3 conda-forge libssh2 1.9.0 hab1572f_5 conda-forge libstdcxx-ng 9.1.0 hdf63c60_0 libtheora 1.1.1 h516909a_1004 conda-forge libtiff 4.1.0 hc3755c2_3 conda-forge libuuid 2.32.1 h14c3975_1000 conda-forge libvorbis 1.3.7 he1b5a44_0 conda-forge libxcb 1.13 h14c3975_1002 conda-forge libxml2 2.9.10 hb55368b_3 logbook 1.5.3 py38h1e0a361_3 conda-forge loguru 0.5.3 py38h32f6830_2 conda-forge lz4-c 1.9.2 he1b5a44_3 conda-forge markupsafe 1.1.1 py38h8df0ef7_2 conda-forge mccabe 0.6.1 py_1 conda-forge mistune 0.8.4 py38h25fe258_1002 conda-forge mypy_extensions 0.4.3 py38h578d9bd_3 conda-forge nbclient 0.5.3 pyhd8ed1ab_0 conda-forge nbconvert 6.0.7 py38h578d9bd_3 conda-forge nbformat 5.1.2 pyhd8ed1ab_1 conda-forge ncurses 6.2 he6710b0_1 nest-asyncio 1.4.3 pyhd8ed1ab_0 conda-forge nettle 3.6 he412f7d_0 conda-forge nptyping 1.4.0 pyhd3deb0d_0 conda-forge numpy 1.19.4 py38hf0fd68c_1 conda-forge numpydoc 1.1.0 py_1 conda-forge occt 7.5.0 h69e9b4c_0 conda-forge ocp 7.5beta 1_py3.8 cadquery openh264 2.1.1 h8b12597_0 conda-forge openssl 1.1.1h h516909a_0 conda-forge packaging 20.9 pyh44b312d_0 conda-forge pandoc 2.12 h7f98852_0 conda-forge pandocfilters 1.4.2 py_1 conda-forge parso 0.7.0 pyh9f0ad1d_0 conda-forge path 15.1.2 py38h578d9bd_0 conda-forge path.py 12.5.0 0 conda-forge pathspec 0.8.1 pyhd3deb0d_0 conda-forge pcre 8.44 he1b5a44_0 conda-forge pexpect 4.8.0 pyh9f0ad1d_2 conda-forge pickleshare 0.7.5 py_1003 conda-forge pip 20.2.4 py38h06a4308_0 pluggy 0.13.1 py38h578d9bd_4 conda-forge proj 7.1.1 h966b41f_3 conda-forge prompt-toolkit 3.0.17 pyha770c72_0 conda-forge psutil 5.7.3 py38h8df0ef7_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pugixml 1.10 he1b5a44_1 conda-forge pycodestyle 2.6.0 pyh9f0ad1d_0 conda-forge pycosat 0.6.3 py38h7b6447c_1 pycparser 2.20 py_2 pydocstyle 5.1.1 py_0 conda-forge pyflakes 2.2.0 pyh9f0ad1d_0 conda-forge pygments 2.8.1 pyhd8ed1ab_0 conda-forge pylint 2.7.2 py38h578d9bd_0 conda-forge pyls-black 0.4.6 pyh9f0ad1d_0 conda-forge pyls-spyder 0.3.2 pyhd8ed1ab_0 conda-forge pyopenssl 19.1.0 pyhd3eb1b0_1 pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge pyqt 5.9.2 py38h05f1152_4 pyqtgraph 0.11.1 pyhd3deb0d_0 conda-forge pyrsistent 0.17.3 py38h25fe258_1 conda-forge pysocks 1.7.1 py38h06a4308_0 python 3.8.5 h7579374_1 python-dateutil 2.8.1 py_0 conda-forge python-jsonrpc-server 0.4.0 pyh9f0ad1d_0 conda-forge python-language-server 0.36.2 pyhd8ed1ab_0 conda-forge python_abi 3.8 1_cp38 conda-forge pytz 2021.1 pyhd8ed1ab_0 conda-forge pyxdg 0.26 py_0 conda-forge pyyaml 5.3.1 py38h8df0ef7_1 conda-forge pyzmq 20.0.0 py38h1d1b12f_1 conda-forge qdarkstyle 2.8.1 pyhd8ed1ab_2 conda-forge qt 5.9.7 h5867ecd_1 qtawesome 1.0.2 pyhd8ed1ab_0 conda-forge qtconsole 5.0.3 pyhd8ed1ab_0 conda-forge qtpy 1.9.0 py_0 conda-forge rapidjson 1.1.0 he1b5a44_1002 conda-forge readline 8.0 h7b6447c_0 regex 2020.11.13 py38h25fe258_0 conda-forge requests 2.24.0 py_0 rope 0.18.0 pyh9f0ad1d_0 conda-forge rtree 0.9.7 py38h02d302b_1 conda-forge ruamel_yaml 0.15.87 py38h7b6447c_1 scipy 1.5.3 py38h828c644_0 conda-forge secretstorage 3.3.1 py38h578d9bd_0 conda-forge setuptools 50.3.1 py38h06a4308_1 sip 4.19.13 py38he6710b0_0 six 1.15.0 py38h06a4308_0 snowballstemmer 2.1.0 pyhd8ed1ab_0 conda-forge sortedcontainers 2.3.0 pyhd8ed1ab_0 conda-forge sphinx 3.5.2 pyhd8ed1ab_0 conda-forge sphinxcontrib-applehelp 1.0.2 py_0 conda-forge sphinxcontrib-devhelp 1.0.2 py_0 conda-forge sphinxcontrib-htmlhelp 1.0.3 py_0 conda-forge sphinxcontrib-jsmath 1.0.1 py_0 conda-forge sphinxcontrib-qthelp 1.0.3 py_0 conda-forge sphinxcontrib-serializinghtml 1.1.4 py_0 conda-forge spyder 4.2.1 py38h578d9bd_3 conda-forge spyder-kernels 1.10.2 py38h578d9bd_0 conda-forge sqlite 3.33.0 h62c20be_0 tbb 2020.2 hc9558a2_0 conda-forge tbb-devel 2020.2 hc9558a2_0 conda-forge testpath 0.4.4 py_0 conda-forge textdistance 4.2.1 pyhd8ed1ab_0 conda-forge three-merge 0.1.1 pyh9f0ad1d_0 conda-forge tk 8.6.10 hbc83047_0 toml 0.10.2 pyhd8ed1ab_0 conda-forge tornado 6.1 py38h25fe258_0 conda-forge tqdm 4.51.0 pyhd3eb1b0_0 traitlets 5.0.5 py_0 conda-forge typed-ast 1.4.1 py38h25fe258_1 conda-forge typing_extensions 3.7.4.3 py_0 conda-forge typish 1.9.1 pyh9f0ad1d_0 conda-forge ujson 4.0.1 py38h950e882_1 conda-forge urllib3 1.25.11 py_0 utfcpp 3.1.2 0 conda-forge vtk 9.0.1 no_osmesa_py38h31de780_102 conda-forge watchdog 2.0.2 py38h578d9bd_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge wheel 0.35.1 pyhd3eb1b0_0 wrapt 1.12.1 py38h25fe258_2 conda-forge wurlitzer 2.0.1 py38h578d9bd_1 conda-forge x264 1!152.20180806 h14c3975_0 conda-forge xorg-kbproto 1.0.7 h14c3975_1002 conda-forge xorg-libice 1.0.10 h516909a_0 conda-forge xorg-libsm 1.2.3 h84519dc_1000 conda-forge xorg-libx11 1.6.12 h516909a_0 conda-forge xorg-libxau 1.0.9 h14c3975_0 conda-forge xorg-libxdmcp 1.1.3 h516909a_0 conda-forge xorg-libxext 1.3.4 h516909a_0 conda-forge xorg-libxt 1.2.0 h516909a_0 conda-forge xorg-xextproto 7.3.0 h14c3975_1002 conda-forge xorg-xproto 7.0.31 h14c3975_1007 conda-forge xz 5.2.5 h7b6447c_0 yaml 0.2.5 h7b6447c_0 yapf 0.30.0 pyh9f0ad1d_0 conda-forge zeromq 4.3.3 h58526e2_3 conda-forge zipp 3.4.1 pyhd8ed1ab_0 conda-forge zlib 1.2.11 h7b6447c_3 zstd 1.4.5 h6597ccf_2 conda-forge ```

Using: Python interpreter

marcus7070 commented 3 years ago

I forgot to check before I submitted this; clean=False in the final cut prevents the hang.

fedorkotov commented 3 years ago

clean=False in the final cut prevents the hang.

Probably related to #660