Skip to content

Commit

Permalink
Fixed gltf export instructions per #1508 (#1523)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwright authored Feb 16, 2024
1 parent 4e0f058 commit 153ed3f
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion doc/importexport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Notes on the Formats
* 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.
* VRML is a mesh-based format for representing interactive 3D objects in a web browser.
* VTP is a mesh-based format used by the VTK library.
* 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.
* 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.

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

Exporting Assemblies to glTF
#############################

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.

CadQuery assemblies have a :meth:`Assembly.save` method which can write an assembly to a glTF file. An example assembly
export with all defaults is shown below. To export to a binary glTF file, change the extension to ``glb``.

.. code-block:: python
import cadquery as cq
# Create a sample assembly
assy = cq.Assembly()
body = cq.Workplane().box(10, 10, 10)
assy.add(body, color=cq.Color(1, 0, 0), name="body")
pin = cq.Workplane().center(2, 2).cylinder(radius=2, height=20)
assy.add(pin, color=cq.Color(0, 1, 0), name="pin")
# Save the assembly to STEP
assy.save("out.gltf")
Exporting SVG
###############

Expand Down

0 comments on commit 153ed3f

Please sign in to comment.