Canvas
Canvas(
engine='EEVEE',
resolution=(1280, 720),
transparent=False,
template='Molecular Nodes',
)High-level render controller for Blender scenes.
Canvas configures the active Blender scene for Molecular Nodes renders (engine, resolution, transparency, color management), exposes convenient properties for common render settings, and provides helpers to frame objects/views and render stills or animations.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| engine | EEVEE | Cycles | str |
Render engine to use. Accepts an instance of mn.scene.EEVEE or mn.scene.Cycles, or a case-insensitive string: "EEVEE" or "CYCLES". |
"EEVEE" |
| resolution | tuple[int, int] | Output resolution in pixels as (width, height). |
(1280, 720) |
| transparent | bool | When True, renders use a transparent film (alpha background). |
False |
| template | pathlib.Path | str | None | Scene template to initialize. If a string is provided it can be either the name of an installed Blender app template (e.g. "Molecular Nodes"), or a path to a .blend file. If None, the Blender default startup file is used. |
"Molecular Nodes" |
Attributes
| Name | Type | Description |
|---|---|---|
| scene | bpy.types.Scene |
The active Blender scene. |
| camera | molecularnodes.scene.camera.Camera |
Convenience camera controller bound to the active scene camera. |
| engine | EEVEE | Cycles |
The configured render engine object. |
| resolution | tuple[int, int] | Current render resolution in pixels. |
| transparent | bool | Whether the film background is transparent. |
| fps | float | Frames per second for animation output. |
| frame_start | int | Start frame of the scene range. |
| frame_end | int | End frame of the scene range. |
| background | tuple[float, float, float, float] | World background color as RGBA in the range [0, 1]. |
| view_transform | {Standard, 'Khronos PBR Neutral', AgX, Filmic, 'Filmic Log', 'False Color', Raw} |
Active view transform for color management. |
Examples
Create a canvas and render a snapshot with a transparent background::
import molecularnodes as mn
cv = mn.Canvas(engine="CYCLES", resolution=(800, 800), transparent=True)
cv.snapshot("frame.png")
See Also
molecularnodes.scene.engines.EEVEE : Render engine configuration for EEVEE. molecularnodes.scene.engines.Cycles : Render engine configuration for Cycles. molecularnodes.scene.camera.Camera : Camera controller used by Canvas.
Methods
| Name | Description |
|---|---|
| animation | Render an animation of the current scene. |
| clear | Clear all Molecular Nodes entities from the scene. |
| frame_object | Frame an object or MolecularEntity in the active camera view. |
| frame_view | Frame one or more views of Molecular entities. |
| load | Load a .blend file replacing the current scene. |
| scene_reset | Reset the scene from a template or startup file. |
| snapshot | Render an image of the current scene. |
animation
Canvas.animation(path=None, frame_start=None, frame_end=None, render_scale=100)Render an animation of the current scene.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | None | File path to write the rendered animation to. | None |
| frame_start | int | Start frame of the animation. When not specified, current scene’s start frame is used | None |
| frame_end | int | End frame of the animation. When not specified, current scene’s end frame is used | None |
| render_scale | int | Scale of the rendered animation frames with respect to the resolution. | 100 |
clear
Canvas.clear()Clear all Molecular Nodes entities from the scene.
Notes
This does not modify lighting, world, or render settings.
frame_object
Canvas.frame_object(obj, viewpoint=None)Frame an object or MolecularEntity in the active camera view.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| obj | bpy.types.Object | MolecularEntity |
Blender object or Molecular Nodes entity to frame. | required |
| viewpoint | Viewpoints | str |
Viewing direction along a principal axis. One of {“default”, “front”, “back”, “top”, “bottom”, “left”, “right”}. | None |
frame_view
Canvas.frame_view(view, viewpoint=None)Frame one or more views of Molecular entities. Multiple views can be combined using + before passing the result.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| view | list[tuple] | MolecularEntity |
A bounding box represented by 8 three-dimensional vertices [(x, y, z), ...] or an entity from which a view is derived. |
required |
| viewpoint | Viewpoints | str |
Viewing direction along a principal axis. One of {“default”, “front”, “back”, “top”, “bottom”, “left”, “right”}. | None |
load
Canvas.load(path)Load a .blend file replacing the current scene.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | The file path to the .blend file to load. | required |
scene_reset
Canvas.scene_reset(template='Molecular Nodes', engine='EEVEE')Reset the scene from a template or startup file.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| template | pathlib.Path | str | None | Name of an installed Blender app template, a path to a .blend file, or None to use Blender’s default startup file. |
"Molecular Nodes" |
| engine | EEVEE | Cycles | str |
Render engine to configure after loading the template. | "EEVEE" |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If template is not None, not a valid .blend file path, and not a known app template name. |
snapshot
Canvas.snapshot(path=None, frame=None, file_format='PNG')Render an image of the current scene.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | None | File path to write the rendered image to. | None |
| frame | int | Frame number of scene to render. When not specified, current scene’s current_frame is used | None |
| file_format | str | File format of the rendered image. | 'PNG' |