Skip to content

Commit 153ed3f

Browse files
authored
Fixed gltf export instructions per #1508 (#1523)
1 parent 4e0f058 commit 153ed3f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

doc/importexport.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Notes on the Formats
4343
* TJS is short for ThreeJS, and is a JSON mesh format that is useful for displaying 3D models in web browsers. The TJS format is used to display embedded 3D examples within the CadQuery documentation.
4444
* VRML is a mesh-based format for representing interactive 3D objects in a web browser.
4545
* VTP is a mesh-based format used by the VTK library.
46-
* glTF is a mesh-based format useful for viewing models on the web. Whether the resulting glTF file is binary (.glb) or text (.gltf) is set by the file extension.
46+
* glTF is a mesh-based format useful for viewing models on the web. Whether the resulting glTF file is binary (.glb) or text (.gltf) is set by the file extension. This export format is only available for assemblies.
4747

4848
Importing DXF
4949
##############
@@ -205,6 +205,28 @@ This is done by setting the name property of the assembly before calling :meth:`
205205
206206
If an assembly name is not specified, a UUID will be used to avoid name conflicts.
207207

208+
Exporting Assemblies to glTF
209+
#############################
210+
211+
It is possible to export CadQuery assemblies to glTF format. glTF is a mesh-based format useful for viewing models on the web. Whether the resulting glTF file is binary (.glb) or text (.gltf) is set by the file extension.
212+
213+
CadQuery assemblies have a :meth:`Assembly.save` method which can write an assembly to a glTF file. An example assembly
214+
export with all defaults is shown below. To export to a binary glTF file, change the extension to ``glb``.
215+
216+
.. code-block:: python
217+
218+
import cadquery as cq
219+
220+
# Create a sample assembly
221+
assy = cq.Assembly()
222+
body = cq.Workplane().box(10, 10, 10)
223+
assy.add(body, color=cq.Color(1, 0, 0), name="body")
224+
pin = cq.Workplane().center(2, 2).cylinder(radius=2, height=20)
225+
assy.add(pin, color=cq.Color(0, 1, 0), name="pin")
226+
227+
# Save the assembly to STEP
228+
assy.save("out.gltf")
229+
208230
Exporting SVG
209231
###############
210232

0 commit comments

Comments
 (0)