sethfischer / sphinxcontrib-cadquery

Sphinx extension for rendering CadQuery models with VTK.js.
https://sphinxcontrib-cadquery.readthedocs.io/
Other
1 stars 0 forks source link

Provide stl download link #48

Open geiseri opened 1 year ago

geiseri commented 1 year ago

First of all THANKS! I was using cadquery-server to generate a static site with my models. While it works very well it is quite hard to customize. Sphinx makes that MUCH easier. One feature I miss though is the ability to export links to the models for download.

When I present my models I like to provide a download link to the part. Like below:

image

Right now I just have my pipeline run the export before the sphinx round and throw them in the _static directory. It would be cool to have a directive like this:

.. cadquery-export::
    :format: stl
    :caption: 3D print
    :name: front.stl

    result = cadquery.Workplane("front").box(2, 2, 0.5)

Where :format: is optional and the :name: would be used similarly to the cadquery export behavior.

That would present a link for download similar to the download directive below:

:download:`3D print <front.stl>`

Theoretically, the export function of the cqgi interface could be used. I have never written a directive before, so maybe that won't work for generating a file.

One other choice (while IMHO less flexible) could be to add a parameter like :export: file.stl that can add a download link next to the image like the image above.

.. cadquery-svg::
    :export: file.3mf

    result = cadquery.Workplane("front").box(2, 2, 0.5)
    show_object(result)
sethfischer commented 1 year ago

@geiseri I think this feature would be a great addition to the extension. My intention is to add new features as a Sphinx domain so the syntax would be something like:

.. cadquery:export::
    :format: stl
    :caption: 3D print
    :name: front.stl

    result = cadquery.Workplane("front").box(2, 2, 0.5)
:cadquery:download:`3D print <front.stl>`