Display and Export
show
Render and display one or more objects in the PythonSCAD viewport. This is the primary way to make objects visible.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
obj |
solid, or list of solids | Object(s) to display |
Passing a list of solids implicitly creates a union.
Examples:
export
Export an object to a file. Supports STL, 3MF, OFF, AMF, and other formats based on the file extension.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
obj |
solid or dict | Object to export, or a dict of {"name": solid} for multi-object 3MF |
file |
string | Output file path (format determined by extension) |
Examples:
Multi-object 3MF export
Passing a dict instead of a single solid emits one 3MF part per
entry, all packed into the output file:
- Keys become part names in the 3MF metadata, so they must be
str/ Unicode -- non-string keys are not supported and may error or crash at runtime. Values are the solids. Insertion order is preserved (CPython 3.7+dictsemantics). - 3MF only. For non-3MF extensions, dict values that aren't
recognised as solids are filtered first;
TypeError: This Format can at most export one objectis raised only when more than one recognised value remains. STL / OFF / AMF / etc. therefore still work for a dict that yields zero or one recognised value after filtering. dictonly (includingdictsubclasses). Mapping types that do not subclassdict--collections.UserDict, genericcollections.abc.Mappingimplementations, ... -- are rejected withTypeError: Object not recognized.- Value conversion. Recognised values are
:class:
PyOpenSCADObjectinstances and lists of them (the list is unioned). The sentinels behave specially:NoneandFalseresolve to the built-in empty object andTrueto the full universe -- they are not dropped, they pass through as parts. Other values (numbers, strings, ...) are silently filtered out. If no value is recognised at all,export()raisesTypeError: Object not recognizedrather than writing an empty file.
This is a lower-level form that can be used with
dict(exporter.parts()). For most multi-tool / multi-color models,
prefer exporter.export(single_file="model.3mf"); it computes the
cumulative-difference split and writes the named parts into one 3MF file.
render
Force full geometry evaluation of an object. This computes the exact geometry, which can be useful before export or when preview mode gives incorrect results.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
obj |
solid | — | Object to render |
convexity |
int | 2 |
Maximum number of front/back faces a ray can intersect |
Examples:
OpenSCAD reference: render
projection
Project a 3D object onto the XY plane, producing a 2D shape.
Syntax:
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
obj |
solid | — | 3D object to project |
cut |
bool | False |
If True, only the cross-section at Z=0 is returned; if False, the entire silhouette is projected |
detail |
bool | False |
If True, preserves all the edges during creating the projection, only valid when cut is False |
convexity |
int | 2 |
Convexity for rendering |
Examples:
OpenSCAD reference: projection
group
Group objects together without performing any boolean operation. The children remain separate but are treated as a single node in the CSG tree.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
obj |
solid | Object to group |
Examples:
highlight
Mark an object for highlighting in the preview. The object is rendered in a distinct color (typically translucent red) to aid debugging. Equivalent to the # modifier in OpenSCAD.
Syntax:
Examples:
OpenSCAD reference: Debug Modifier
background
Render an object transparently and exclude it from CSG operations. Useful for showing reference geometry. Equivalent to the % modifier in OpenSCAD.
Syntax:
Examples:
OpenSCAD reference: Background Modifier
only
Show only this object, ignoring everything else in the scene. Equivalent to the ! modifier in OpenSCAD.
Syntax:
Examples:
OpenSCAD reference: Root Modifier