veux.render#
- veux.render(sam_file, res_file=None, ndf=6, canvas=None, show=None, hide=None, verbose=False, vertical=2, displaced=None, reference=None, **opts)#
Primary rendering function.
To render a model directly from Python:
artist = veux.render(model, canvas=canvas)
Parameters#
- modelstr, dict, or Model
The
model
parameter can be of several types:str: Treated as a file path. Supported file formats are
.json
and.tcl
.dict: A dictionary representation of the model.
Model: An instance of the
Model
class from the sees Python package. See the documentation for details.
- canvasstr, optional
The rendering backend to use. Options are:
"gltf"
(default): Produces high-quality renderings. Files can be saved as.html
or.glb
..glb
is recommended for 3D object portability."plotly"
: Best for model debugging. Includes detailed annotations (e.g., node/element numbers, properties) but lower visual quality thangltf
."matplotlib"
: Generates.png
files programmatically. Note that renderings are lower quality compared togltf
.
Returns#
- artistArtist
An object representing the rendered model. Can be used to view or save the rendering.
Viewing the Rendering#
To view a rendering generated with
canvas="gltf"
orcanvas="plotly"
, use theveux.serve()
function:veux.serve(artist)
This will start a local web server and output a message like:
Bottle v0.13.1 server starting up (using WSGIRefServer())... Listening on http://localhost:8081/ Hit Ctrl-C to quit.
Open the URL (e.g., http://localhost:8081) in a web browser to interactively view the rendering.
Saving the Rendering#
Use the
artist.save()
method to write the rendering to a file. The file format depends on the selected canvas:gltf: Files are saved in the glTF format with a
.glb
extension:artist.save("model.glb")
plotly: Files are saved as
.html
:artist.save("model.html")
matplotlib: Files are saved as
.png
:artist.save("model.png")
Note#
Renderings produced with the
"matplotlib"
canvas are typically of poor quality. For high-quality images, use the"gltf"
canvas and take screen captures.