GUI and Utility Functions
rendervars
Control the camera and viewport settings from your Python script. Useful for setting up specific viewing angles.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
vpd |
float | Viewport distance (camera distance from the object) |
vpf |
float | Field of view angle in degrees |
vpr |
[x, y, z] |
Viewport rotation in degrees |
vpt |
[x, y, z] |
Viewport translation (the point the camera looks at) |
All parameters are optional. Only the ones you provide will be changed.
Examples:
from openscad import *
cube(10, center=True).show()
rendervars(vpd=150, vpr=[55, 0, 25], vpt=[0, 0, 5])
add_menuitem
Add a custom menu item to the PythonSCAD GUI. This function is only available in GUI mode.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
menuname |
string | Name of the menu to add to (e.g. "Tools") |
itemname |
string | Name of the menu item |
callback |
callable | Function to call when the item is clicked |
Examples:
from openscad import *
def my_action():
print("Menu item clicked!")
add_menuitem("Tools", "My Custom Action", my_action)
model
Return the current model object.
Syntax:
Returns: The current model as a solid object.
modelpath
Return the absolute file path of the current script.
Syntax:
Returns: A string with the absolute path to the currently running script file.
Examples:
version
Return the PythonSCAD version as a list.
Syntax:
Returns: A list like [year, month, day].
Examples:
OpenSCAD reference: version
version_num
Return the PythonSCAD version as a single number.
Syntax:
Returns: An integer encoding the version.
marked
Create a marked value for use with F-Rep / libfive. This wraps a numeric value as a libfive data type.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
value |
float | The numeric value to mark |
Returns: A libfive PyData scalar value.
machineconfig
Set machine configuration parameters. This is used to configure machine-specific settings like bed size.
Syntax:
Parameters:
| Parameter | Type | Description |
|---|---|---|
config |
dict | Dictionary of configuration key-value pairs |
Examples: