CadQuery / cadquery

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

unexected behaviour in gltf export #935

Open smalltoe opened 2 years ago

smalltoe commented 2 years ago

Dear experts, I found an unexpected behaviour in the gltf export. For illustration the following script to be executed once with exportType='step' and once with exportType='gltf' will create the files test.step and test.gltf respectively.

import cadquery as cq
exportType='step' #'gltf'
pts=[[19.5,0,0],[9.5,0,0]]
assy = cq.Assembly()
w = cq.Workplane('YZ')
tube = w.rect(1,1).rect(0.95,0.95).extrude(-9)
for p in pts:
    assy.add(tube, loc=cq.Location(cq.Vector(p)))

assy.save("./test.%s" % exportType.lower(), exportType=exportType.upper())

If I open now the file test.step in FreeCAD I find two tubes one after the other - my expected behaviour: grafik

If I open the file test.gltf in Blender, I can find only one tube and an error message - opening the file in three.js is not possible at all: grafik

To me this looks unexpected and I suspect a bug as other formats like STL are working like test.step.

Many Thanks for any insights!

jmwright commented 2 years ago

Try calling toCompound() on your assembly before exporting it. https://cadquery.readthedocs.io/en/latest/classreference.html?highlight=tocompound#cadquery.Assembly.toCompound