-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing components when exporting assembly to GLTF #993
Comments
I also just noticed that the meshes are not inside the correct containers - in the above image, |
Your top level assy is empty so I think that the warning is fine. If I use a non-empty top assy the export seems to be fine. This is either a bug of CQ or OCCT - I have too little experience with the GLTF OCCT export functionality to be able to tell. |
Adding something to the top-level assembly lets me work around the issue for now which is nice, thanks! |
I'm testing a fix on the CQ side in #1157. Example script: import cadquery as cq
box = cq.Workplane().box(1, 2, 3)
assy = cq.Assembly(name="toplevel")
assy.add(box, name="box1")
assy.add(box, name="box2", loc=cq.Location((4, 0, 0)))
assy.save("boxes.gltf")
assy.save("boxes.step") Importing boxes.step (master) into CAD Assistant shows: Importing boxes.gltf (master) into CAD Assistant results in error Scene node '5' refers to non-existing mesh. |
I tested again with current master which includes #1156. The issue is now resolved with OCCT/OCP 7.6. Here is the cone example GLTF imported in blender: Importing boxes.gltf into CAD Assistant is also working now: I'd still like to consider PR #1157 even though it is not required to fix this issue. It would resolve an issue where an extraneous leaf part is added (at least for STEP) due to empty root assembly. |
#1157) * Assembly export: do not add leaf component when shapes is empty (#993) * Add test to validate number of leaf nodes in OCAF data * mypy fix * Remove len call * Improve assembly makeCompound and color handling for glTF, STEP * Create single compound for multiple instances of same shape * Fix glTF, STEP export color handling * Special handling for part names and naming convention for multiple instances of a shape * Change default glTF mesh tolerance to be consistent with other formats * Allow creation of default Color (when color name, tuple values unspecified) * Add tests of assembly colors including STEP export * Fix tests on Python 3.8 * Apply changes from code review * Add assembly children recursively * Remove STEP part naming special handling * Add glTF test to check for missing mesh * Extend copy * Refactor to use the updated copy method * Black fix Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
I'm trying to export an assembly to GLTF, as it seems to be a good way to get it into Blender, however I always get a warning during export and one piece is missing mesh data.
Reproducing using the two cones assembly example from the documentation:
When run, this gives the following output:
The generated GLTF file looks like this when viewed in Blender:

Note that both parts show up in the scene hierarchy but only cone0 has mesh data.
I have also tried with a few other assemblies with varying numbers of parts - they all seem to produce a single warning and be missing a single part.
Three object version
```py import cadquery as cq
cone = cq.Solid.makeCone(1, 0, 2)
cube = cq.Solid.makeBox(1, 1, 1)
assy = cq.Assembly()
assy.add(cone, name="cone0", color=cq.Color("green"))
assy.add(cone, name="cone1", color=cq.Color("blue"))
assy.add(cone, name="cube0", color=cq.Color("pink"))
assy.constrain("cone0@faces@<Z", "cube0@faces@<Z", "Axis")
assy.constrain("cube0@faces@>Z", "cone1@faces@<Z", "Axis")
assy.solve()
assy.save("test3.gltf")
Meshing <cadquery.occ_impl.shapes.Solid object at 0x7fe8dca77fd0> from <cadquery.assembly.Assembly object at 0x7fe8879c0910>
Meshing <cadquery.occ_impl.shapes.Solid object at 0x7fe8dca77fd0> from <cadquery.assembly.Assembly object at 0x7fe88746aec0>
Meshing <cadquery.occ_impl.shapes.Solid object at 0x7fe8dca77fd0> from <cadquery.assembly.Assembly object at 0x7fe88746afe0>
RWGltf_CafWriter skipped node '6aed5336-8bf4-11ec-936e-0090f5f2c22d_part' without triangulation data
In Blender:

`conda list`
Installed using `micromamba install -c cadquery -c conda-forge cadquery=master` ``` # packages in environment at /home/jake/.conda/envs/cadquery: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_gnu conda-forge alsa-lib 1.2.3 h516909a_0 conda-forge aom 3.2.0 h9c3ff4c_2 conda-forge asttokens 2.0.5 pypi_0 pypi backcall 0.2.0 pypi_0 pypi backports 1.0 py_2 conda-forge backports-functools-lru-cache 1.6.4 pypi_0 pypi backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge black 22.1.0 pypi_0 pypi bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.18.1 h7f98852_0 conda-forge ca-certificates 2021.10.8 ha878542_0 conda-forge cadquery 2.1 pypi_0 pypi click 8.0.3 pypi_0 pypi curl 7.81.0 h2574ce0_0 conda-forge dataclasses 0.8 pypi_0 pypi dbus 1.13.6 h5008d03_3 conda-forge decorator 5.1.1 pypi_0 pypi double-conversion 3.1.7 h9c3ff4c_0 conda-forge eigen 3.4.0 h4bd325d_0 conda-forge executing 0.8.2 pypi_0 pypi expat 2.4.4 h9c3ff4c_0 conda-forge ezdxf 0.17.2 pypi_0 pypi ffmpeg 4.4.1 h6987444_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 hab24e00_0 conda-forge fontconfig 2.13.96 ha180cfb_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge freeimage 3.18.0 h88c329d_7 conda-forge freetype 2.10.4 h0708190_1 conda-forge gettext 0.19.8.1 h73d1719_1008 conda-forge gl2ps 1.4.2 h0708190_0 conda-forge glew 2.1.0 h9c3ff4c_2 conda-forge gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.6.13 h85f3911_1 conda-forge gst-plugins-base 1.18.5 hf529b03_3 conda-forge gstreamer 1.18.5 h9f60fe5_3 conda-forge hdf4 4.2.15 h10796ff_3 conda-forge hdf5 1.10.6 nompi_h6a2412b_1114 conda-forge icu 69.1 h9c3ff4c_0 conda-forge ilmbase 2.5.5 h780b84a_0 conda-forge ipython 8.0.1 pypi_0 pypi jbig 2.1 h7f98852_2003 conda-forge jedi 0.18.1 pypi_0 pypi jpeg 9e h7f98852_0 conda-forge jsoncpp 1.9.4 h4bd325d_3 conda-forge jxrlib 1.1 h7f98852_2 conda-forge krb5 1.19.2 hcc1bbae_3 conda-forge lame 3.100 h7f98852_1001 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 3.0 h9c3ff4c_0 conda-forge libblas 3.9.0 13_linux64_openblas conda-forge libcblas 3.9.0 13_linux64_openblas conda-forge libclang 13.0.1 default_hc23dcda_0 conda-forge libcurl 7.81.0 h2574ce0_0 conda-forge libdeflate 1.8 h7f98852_0 conda-forge libdrm 2.4.109 h7f98852_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libevent 2.1.10 h9b69904_4 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc-ng 11.2.0 h1d223b6_12 conda-forge libgfortran-ng 11.2.0 h69a702a_12 conda-forge libgfortran5 11.2.0 h5c6108e_12 conda-forge libglib 2.70.2 h174f98d_2 conda-forge libglu 9.0.0 he1b5a44_1001 conda-forge libgomp 11.2.0 h1d223b6_12 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.9.0 13_linux64_openblas conda-forge libllvm13 13.0.1 hf817b99_0 conda-forge libnetcdf 4.8.1 nompi_hcd642e3_100 conda-forge libnghttp2 1.46.0 h812cca2_0 conda-forge libnsl 2.0.0 h7f98852_0 conda-forge libogg 1.3.4 h7f98852_1 conda-forge libopenblas 0.3.18 pthreads_h8fe5266_0 conda-forge libopus 1.3.1 h7f98852_1 conda-forge libpciaccess 0.16 h516909a_0 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libpq 14.2 hd57d9b9_0 conda-forge libraw 0.20.2 h10796ff_1 conda-forge libssh2 1.10.0 ha56f1ee_2 conda-forge libstdcxx-ng 11.2.0 he4da1e4_12 conda-forge libtheora 1.1.1 h7f98852_1005 conda-forge libtiff 4.3.0 h6f004c6_2 conda-forge libuuid 2.32.1 h7f98852_1000 conda-forge libva 2.13.0 h7f98852_2 conda-forge libvorbis 1.3.7 h9c3ff4c_0 conda-forge libvpx 1.11.0 h9c3ff4c_3 conda-forge libwebp-base 1.2.2 h7f98852_1 conda-forge libxcb 1.13 h7f98852_1004 conda-forge libxkbcommon 1.0.3 he3ba5ed_0 conda-forge libxml2 2.9.12 h885dcf4_1 conda-forge libzip 1.8.0 h4de3113_1 conda-forge libzlib 1.2.11 h36c2ea0_1013 conda-forge loguru 0.5.3 pypi_0 pypi lz4-c 1.9.3 h9c3ff4c_1 conda-forge matplotlib-inline 0.1.3 pypi_0 pypi multimethod 1.6 pypi_0 pypi mypy-extensions 0.4.3 pypi_0 pypi mypy_extensions 0.4.3 py310hff52083_4 conda-forge mysql-common 8.0.28 ha770c72_0 conda-forge mysql-libs 8.0.28 hfa10184_0 conda-forge ncurses 6.3 h9c3ff4c_0 conda-forge nettle 3.6 he412f7d_0 conda-forge nlopt 2.7.1 py310hf38e9df_0 conda-forge nptyping 1.4.4 pypi_0 pypi nspr 4.32 h9c3ff4c_1 conda-forge nss 3.74 hb5efdd6_0 conda-forge numpy 1.22.2 pypi_0 pypi occt 7.5.3 h7391655_0 conda-forge ocp 7.5.3.0 py310_3 cadquery openexr 2.5.5 hf817b99_0 conda-forge openh264 2.1.1 h780b84a_0 conda-forge openjpeg 2.4.0 hb52868f_1 conda-forge openssl 1.1.1l h7f98852_0 conda-forge parso 0.8.3 pypi_0 pypi pathspec 0.9.0 pypi_0 pypi pcre 8.45 h9c3ff4c_0 conda-forge pexpect 4.8.0 pypi_0 pypi pickleshare 0.7.5 pypi_0 pypi pip 22.0.3 pypi_0 pypi platformdirs 2.5.0 pypi_0 pypi proj 7.2.0 h277dcde_2 conda-forge prompt-toolkit 3.0.27 pypi_0 pypi pthread-stubs 0.4 h36c2ea0_1001 conda-forge ptyprocess 0.7.0 pypi_0 pypi pugixml 1.11.4 h9c3ff4c_0 conda-forge pure-eval 0.2.2 pypi_0 pypi pure_eval 0.2.2 pyhd8ed1ab_0 conda-forge pygments 2.11.2 pypi_0 pypi pyparsing 3.0.7 pypi_0 pypi python 3.10.2 h85951f9_3_cpython conda-forge python_abi 3.10 2_cp310 conda-forge qt 5.12.9 ha98a1a1_5 conda-forge rapidjson 1.1.0 he1b5a44_1002 conda-forge readline 8.1 h46c0cb4_0 conda-forge setuptools 60.8.2 pypi_0 pypi six 1.16.0 pypi_0 pypi sqlite 3.37.0 h9cd32fc_0 conda-forge stack-data 0.1.4 pypi_0 pypi stack_data 0.1.4 pyhd8ed1ab_0 conda-forge svt-av1 0.9.0 h9c3ff4c_0 conda-forge tbb 2020.2 h4bd325d_4 conda-forge tbb-devel 2020.2 h4bd325d_4 conda-forge tk 8.6.11 h27826a3_1 conda-forge tomli 2.0.1 pypi_0 pypi traitlets 5.1.1 pypi_0 pypi typed-ast 1.5.2 pypi_0 pypi typing-extensions 4.0.1 pypi_0 pypi typing_extensions 4.0.1 pyha770c72_0 conda-forge typish 1.9.3 pypi_0 pypi tzdata 2021e he74cb21_0 conda-forge utfcpp 3.2.1 ha770c72_0 conda-forge vtk 9.0.1 pypi_0 pypi wcwidth 0.2.5 pypi_0 pypi wheel 0.37.1 pypi_0 pypi x264 1!161.3030 h7f98852_1 conda-forge x265 3.5 h4bd325d_1 conda-forge xorg-fixesproto 5.0 h7f98852_1002 conda-forge xorg-kbproto 1.0.7 h7f98852_1002 conda-forge xorg-libice 1.0.10 h7f98852_0 conda-forge xorg-libsm 1.2.3 hd9c2040_1000 conda-forge xorg-libx11 1.7.2 h7f98852_0 conda-forge xorg-libxau 1.0.9 h7f98852_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xorg-libxext 1.3.4 h7f98852_1 conda-forge xorg-libxfixes 5.0.3 h7f98852_1004 conda-forge xorg-libxt 1.2.1 h7f98852_2 conda-forge xorg-xextproto 7.3.0 h7f98852_1002 conda-forge xorg-xproto 7.0.31 h7f98852_1007 conda-forge xz 5.2.5 h516909a_1 conda-forge zlib 1.2.11 h36c2ea0_1013 conda-forge zstd 1.5.2 ha95c52a_0 conda-forge ```
The text was updated successfully, but these errors were encountered: