Interactive (GUI)#
These functions start a wx-based user interface. Use them when you want to
inspect a design interactively or drive a compiler workflow from form controls.
Each one has a CamelCase alias (Render, Export, Select_Mesh_Patch)
that older scripts use; both spellings behave the same.
Viewer#
- pyvcad_rendering.render(vcad_object, materials=None, quality=None, custom_voxel_size=None)[source]#
Open the interactive 3D viewer for
vcad_object(wx main loop).- Parameters:
vcad_object (Node) – The design to show.
materials (MaterialDefs, optional) – Material definitions for volume-fraction colouring.
quality (str, optional) – Starting sampling quality: “low”, “medium”, “high”, “ultra” or “custom”. The named levels scale with the object (128, 256, 512 and 1024 samples along its longest side), so a large design with thin walls or struts needs “high” or a custom voxel size to look right. When given, this is the starting quality every time the script runs; you can still change it in the viewer. When omitted, the viewer restores the quality you last used for this script (or “low” the first time).
custom_voxel_size (float, optional) – Voxel size in millimetres for quality=”custom” (setting it alone implies quality=”custom”).
Example
>>> import pyvcad_rendering as viz >>> viz.render(liner, quality="high") >>> viz.render(liner, custom_voxel_size=0.4)
- pyvcad_rendering.Render(vcad_object, materials=None, quality=None, custom_voxel_size=None)[source]#
Alias for
render().
Two viewer tools show analysis results (see the Analysing Designs guide):
Inspect > Mass Properties computes
pyvcad.mass_properties()for the design at the current quality, with the materials passed toRenderand an optional uniform density. It lists the numbers (with a Copy button) and draws the centre of mass and principal axes over the view.Display > Range > Flag below min / Flag above max paints values outside a Fixed colour range in a flag colour, for example walls thinner than a limit when viewing a thickness attribute from
pyvcad.local_thickness().
Compiler export wizard#
- pyvcad_rendering.export(vcad_object, materials=None)[source]#
Open the interactive compiler export dialog for
vcad_object(wx main loop).The dialog lists every
pyvcad_compilerscompiler, shows which attributes the design provides (authored or computed by converters) and which each compiler needs, and greys out the ones the design cannot feed. Pick a compiler, adjust its validated settings, and export with live progress and cancel. Outputs default to anoutput/folder next to the calling script.- Parameters:
vcad_object (Node) – The design root.
materials (MaterialDefs, optional) – Material definitions for the design. Defaults to
pyvcad.default_materials.
Export opens a three-step wizard for compiling a design without writing
compiler code:
Choose a compiler. The attributes the design provides, then every compiler with the attributes it expects. Compilers the design cannot feed are greyed out.
Settings. What the compiler targets, a link to its guide when one exists, and validated settings with sensible defaults and a size estimate.
Export. Live progress with cancel, then the written files.
This lets a script stay compiler-agnostic: build the design, call
viz.export(root, materials), and choose the output at run time. Outputs
default to an output/ folder next to the calling script.
Mesh patch picker#
A separate picker for choosing a patch of triangles on a surface mesh, for
example the faces a lattice or texture should follow. It returns a
pyvcad.MeshSelection; see Mesh selections for saving and replaying
selections without the GUI, and the Select triangle-mesh patches guide.
- pyvcad_rendering.select_mesh_patch(source, voxel_size=None, initial_selection=None)[source]#
Open the auxiliary picker and return a
pyvcad.MeshSelectionorNone.sourcemay be an existingSurfaceMeshor an OpenVCADNode. Tree inputs require an explicit voxel size because the selected triangle IDs are resolution-specific.- Parameters:
source (SurfaceMesh | Node) – The mesh, or the tree to mesh.
voxel_size (float, optional) – Meshing voxel size in mm. Required for a
Node.initial_selection (MeshSelection, optional) – Triangles to show as selected when the picker opens.
- Returns:
The accepted selection, or None if the picker was closed without one.
- Return type:
MeshSelection | None
- Raises:
RuntimeError – If called while a wx event loop is already running.
- pyvcad_rendering.Select_Mesh_Patch(source, voxel_size=None, initial_selection=None)[source]#
Alias for
select_mesh_patch().