Scene

class dazpy.DazScene(client=None)[source]

Bases: object

High-level proxy for the active DAZ Studio scene (Scene global).

This is the primary entry point for inspecting and manipulating the scene. All methods execute DazScript on the server and return Python objects.

Parameters:

client (DazClient | None) – Optional DazClient to use. A default client connecting to 127.0.0.1:18811 is created when omitted.

Example:

from dazpy import DazScene

scene = DazScene()
print(scene.num_nodes(), "nodes in scene")
figure = scene.find_skeleton_by_label("Genesis 9")
nodes()[source]

Return all top-level and child nodes in the scene.

The returned list contains typed subclass instances: DazSkeleton for figures, DazCamera, DazLight, and DazNode for everything else.

Returns:

Ordered list of scene nodes (same order as DAZ Studio’s scene panel).

Return type:

list[DazNode]

resolve_node(ref)[source]

Resolve a node reference the way users and agents write them, in one call.

ref may be:

  • an elementID (4217 or "4217"),

  • a Parent/Label path (each step a label or name; the child is searched recursively under the parent), or

  • a label or internal name, which must match exactly one node.

Returns:

A proxy bound to the node’s elementID (so later calls can’t drift to a same-named node), typed DazSkeleton, DazCamera, DazLight or DazNode.

Raises:
Return type:

DazNode

set_numeric_properties(operations)[source]

Set many numeric properties across nodes in one call.

Each operation is (node_ref, property_name, value): node_ref as for resolve_node(), property_name matched like DazNode.set_numeric_property() (exact, case-insensitive; locked properties are unlocked). A failing operation doesn’t stop the others; its result carries the error.

freeze_dforce(on=True)[source]

Freeze (bake) or release every dForce modifier in the scene, in one call. Returns how many modifiers were changed.

transfer_utility(source, target, *, binding=False, morphs=False, uvs=False, material_groups=False, face_groups=False, fit_to_figure=False, parent_to_figure=False, merge_hierarchies=False)[source]

Run Studio’s Transfer Utility from source to target, silently.

Raises:

DazError – If doTransfer() reports failure.

content_categories(parent='')[source]

Sub-folders of parent (content-relative) across every content directory, merged by name, with their .duf counts.

content_files(category='')[source]

.duf files in category (content-relative) across every content directory; a name found in several directories is listed once.

strand_hair_nodes()[source]

Every Strand-Based Hair node: label, name, elementID, target figure, whether it has geometry, and its surface labels.

find_nodes(query)[source]

Every node whose label or internal name equals query exactly.

Use it to list same-labelled nodes and pick one by NodeInfo.element_id.

content_path(relative)[source]

Resolve a content-library-relative path to an absolute path.

Searches every configured content directory, as Studio does for asset references (e.g. "Shader Presets/Iray/DAZ Uber/!Iray Uber Base.duf").

Returns:

The absolute path, or None if no content directory has it.

Return type:

str | None

find_node(name)[source]

Find a scene node by its internal name.

Parameters:

name (str) – The getName() string of the node.

Returns:

A DazNode proxy for the node.

Raises:

NodeNotFoundError – If no node with that name exists in the scene.

Return type:

DazNode

find_node_by_label(label)[source]

Find a scene node by its user-visible label.

The returned proxy is anchored to the node’s internal name so it remains stable if the label is later changed.

Parameters:

label (str) – The getLabel() string shown in the Scene panel.

Returns:

A DazNode proxy.

Raises:

NodeNotFoundError – If no node with that label exists.

Return type:

DazNode

num_nodes()[source]

Return the total number of nodes in the scene.

check(camera=None, *, engine=None, resolution=None, allow_crop=False)[source]

Pre-render checks for a render from camera (one Studio script).

Checks that each visible figure (top-level, not fitted to another) is inside the camera’s frame, and that something will light the render. Findings (see CheckFinding):

  • subject_out_of_frame (warning): part of a figure’s bounding box is outside the frame; sides says which edges (a head or feet cut off shows as top / bottom). The box is loose, so an outstretched arm can trigger it with nothing visible cut off.

  • subject_not_in_frame (warning): a figure is entirely out of frame.

  • no_subject_in_frame (error): the scene has figures and the camera sees none of them.

  • no_light (error): no light is on with non-zero intensity, the environment does not light the scene (mode Scene Only, or intensity 0) and the camera headlamp is off. Not checked for the OpenGL engines.

  • camera_not_found (error): no camera has that label.

Parameters:
  • camera (str | None) – Camera label; None checks the active viewport camera (what dazpy.render() renders from by default).

  • engine (str | None) – Engine the render will use ("iray", "filament", "viewport"); default: the active engine.

  • resolution (tuple[int, int] | None) – (width, height) of the render; default: the render settings’ aspect ratio.

  • allow_crop (bool) – Drop the two framing warnings (a deliberate crop).

cameras()[source]

Return all camera nodes in the scene.

lights()[source]

Return all light nodes in the scene.

viewport_camera()[source]

Return the camera the active 3D viewport is looking through.

This is often one of Studio’s built-in view cameras ("Perspective View"), which is not a scene node and so is not in cameras(); ViewportCamera.in_scene says which kind it is.

Returns:

A ViewportCamera snapshot, or None when there is no active 3D viewport (e.g. Studio is running without a main window).

Return type:

ViewportCamera | None

set_viewport_camera(camera)[source]

Look through camera in the active 3D viewport.

camera is a DazCamera, or a label: a scene camera’s, or one of Studio’s built-in view cameras ("Perspective View", "Front View", …), which are not scene nodes.

Returns:

The label of the camera the viewport used before.

Raises:
Return type:

str | None

camera_info()[source]

Every scene camera with position and focal length, in one call.

light_info()[source]

Every scene light with position, flux and on/off state, in one call.

find_camera_by_label(label)[source]

Find a camera by its user-visible label.

Parameters:

label (str) – The label shown in the Scene panel (e.g. "Camera 1"). This is the same value accepted by the camera parameter of render().

Returns:

A DazCamera proxy.

Raises:

NodeNotFoundError – If no camera with that label exists.

Return type:

DazCamera

create_camera(name=None)[source]

Create a new basic camera node and add it to the scene.

Parameters:

name (str | None) – Optional internal name for the new camera. When omitted, DAZ Studio assigns its default name (e.g. "Camera", de-duplicated as "Camera 2" etc.).

Returns:

A DazCamera proxy for the newly created camera.

Return type:

DazCamera

create_light(light_type, name=None)[source]

Create a new light node and add it to the scene.

Parameters:
  • light_type (str) – One of "spot", "point", or "distant".

  • name (str | None) – Optional internal name for the new light. When omitted, DAZ Studio assigns its default name.

Returns:

A DazLight proxy for the newly created light.

Raises:

ValueError – If light_type is not a recognised light type.

Return type:

DazLight

create_group(name, label=None, position=None)[source]

Create an empty group node (DzGroupNode) and add it to the scene.

Use it as a parent for nodes that move together, such as a camera rig.

Parameters:
  • name (str) – Internal name for the new group.

  • label (str | None) – The label shown in the Scene panel (default: name). It is set after the node is added: on DS4 a label set before Scene.addNode does not stick on a scripted node.

  • position (tuple[float, float, float] | None) – Optional world-space position (x, y, z) in cm.

Returns:

A DazNode proxy for the new group, by the name Studio gave it.

Raises:

ValueError – If name is empty.

Return type:

DazNode

find_light_by_label(label)[source]

Find a light by its user-visible label.

Parameters:

label (str) – The label shown in the Scene panel (e.g. "Distant Light 1").

Returns:

A DazLight proxy.

Raises:

NodeNotFoundError – If no light with that label exists.

Return type:

DazLight

skeletons()[source]

Return all skeleton (figure) nodes in the scene.

find_skeleton(name, *, retry_attempts=3, retry_delay=0.15)[source]

Find a skeleton by its internal name.

Parameters:
  • name (str) – Internal name of the skeleton node (e.g. "Genesis9"). To look up by the user-visible label shown in the Scene panel (e.g. "Genesis 9"), use find_skeleton_by_label().

  • retry_attempts (int) – Number of Scene.getSkeletonList() lookups to try before concluding the skeleton is really absent. Scene.getSkeletonList() has been observed to transiently omit a skeleton that is present under load from a burst of other main-thread script calls (see daz-script-server-xtkd) – a momentary miss is retried rather than immediately raised. Set to 1 to disable retrying.

  • retry_delay (float) – Base seconds to sleep between retries (each attempt after the first waits retry_delay * attempt_number).

Returns:

A DazSkeleton proxy.

Raises:

NodeNotFoundError – If no skeleton with that name exists after retry_attempts lookups.

Return type:

DazSkeleton

find_skeleton_by_label(label)[source]

Find a skeleton by its user-visible label.

Parameters:

label (str) – Label shown in the Scene panel.

Returns:

A DazSkeleton proxy.

Raises:

NodeNotFoundError – If no skeleton with that label exists.

Return type:

DazSkeleton

num_skeletons()[source]

Return the total number of skeleton nodes in the scene.

scene_snapshot(skeleton_labels=None)[source]

Return full skeleton and bone metadata for the scene in one HTTP call.

Each entry in the returned list represents one skeleton and contains: name, label, position (the figure node’s world position, {"x", "y", "z"}), and bones — a list of dicts with name, label, parent_name, rotation_order, local_position, world_position, and local_euler.

Pass to build_rig_profiles_from_snapshot() to build solver-ready FigureRigProfile objects without any additional HTTP calls.

Parameters:

skeleton_labels (list[str] | None) – Optional list of skeleton names or labels to include. None returns every skeleton in the scene.

Returns:

List of skeleton snapshot dicts, one per matching skeleton.

Return type:

list[dict]

time_step()[source]

DzTime ticks per timeline frame (Scene.getTimeStep(); 160 at 30 fps).

all_node_transforms()[source]

Return world-space transforms for every node in a single call.

Returns:

A list of dicts, each with keys "name", "label", "element_id", "type" ("lights", "cameras", "bones", "figures", "wearables" – a figure parented to another figure – or "props"), "position" ([x, y, z]), "rotation" ([x, y, z]), and "visible".

Return type:

list[dict]

node_tree()[source]

Return the full scene hierarchy as a nested list of dicts.

Returns:

Root-level nodes, each a dict with "name", "label", and "children" (recursively nested).

Return type:

list[dict]

node_hierarchy(root=None, max_depth=None)[source]

Return the descendant tree rooted at a single node, in one HTTP call.

Unlike node_tree() (every root-level node in the scene), this starts at one named node – typically a figure – and includes a type (DazScript class name) on every entry and an optional recursion-depth limit, which matters for deep skeletons (Genesis figures have 100+ bones).

Parameters:
  • root (str | None) – Display label or internal name of the root node. Searched by label first, then internal name.

  • max_depth (int | None) – Maximum recursion depth. None or 0 means unlimited.

Returns:

{"node": label, "hierarchy": {...}, "total_descendants": int} where hierarchy is {"label", "name", "type", "children": [...]} (children omitted for leaf nodes).

Raises:

NodeNotFoundError – If root cannot be found.

Return type:

dict

overview()[source]

Return a lightweight, top-level snapshot of the scene in one HTTP call.

Root-level figures, all cameras, all lights, the open scene file, and the primary selection – enough to orient an agent without enumerating every node (use nodes() or node_tree() for that).

Returns:

{"scene_file", "selected_node", "figures", "cameras", "lights", "total_nodes"}. figures/cameras/lights are lists of {"name", "label", "type"} (type omitted for cameras). Follower figures (eyelashes, tear surfaces, etc. parented under another figure rather than the scene root) are excluded from figures.

Return type:

dict

selected_nodes()[source]

Return the currently selected nodes.

primary_selection()[source]

Return the primary selected node, or None if nothing is selected.

set_primary_selection(node)[source]

Set the primary selection to node.

Parameters:

node (DazNode) – The node to select.

apply_interaction_recipe(recipe, *, rig_profiles=None, align_limb_targets=False, max_iterations=None, step_degrees=1.0, damping=0.25, tolerance=0.15)[source]

Prepare and apply an interaction recipe against the current scene.

select_all(on=True)[source]

Select or deselect all nodes.

Parameters:

on (bool) – True to select all, False to deselect all.

undo(label)[source]

Return a context manager that groups all enclosed changes into a single undo step.

Changes inside the block are queued and sent as one script when the block ends, so their results are not available until then. See UndoGroup for details.

Parameters:

label (str) – The label shown in DAZ Studio’s Edit > Undo menu.

Returns:

A UndoGroup context manager.

Return type:

UndoGroup

Example:

with scene.undo("Move figure"):
    node.set_position(100, 0, 0)
frame()[source]

Return the current timeline frame number.

set_frame(frame)[source]

Jump to a specific timeline frame.

Parameters:

frame (int) – Zero-based frame number.

load(path, *, replace=False)[source]

Load a scene file, merging it into the current scene by default.

Parameters:
  • path (str) – Absolute path to the .daz or .duf file on the server host.

  • replace (bool) – Clear the current scene first, so the file replaces it. Done as Scene.clear() then a merge rather than DzScene.OpenNew, which can raise a modal “save changes?” prompt that blocks the script server. Unsaved changes are discarded.

save(path)[source]

Save the scene to a file.

Parameters:

path (str) – Absolute destination path on the server host.

save_copy(path)[source]

Save a copy of the scene to path without changing the scene’s current file or dirty state — equivalent to a “Save a Copy As…” operation.

For clean scenes the plugin performs a simple file copy (zero DAZ state change). For scenes with unsaved changes it serialises via Scene.saveScene() and then saves to the original filename again to restore it (the doSave(saveOnly=true) API is compiled out of current DAZ Studio 4.x builds). The plugin copies the original file aside first and puts it back afterwards, so the file on disk keeps its contents and the unsaved changes stay unsaved.

Parameters:

path (str) – Absolute destination path on the server host (e.g. "C:/backups/scene_v2.duf").

Returns:

{"ok": True, "path": str, "source": str, "method": str} where method is "copy" (file copy, no serialisation) or "serialize" / "serialize+restore" (required when the scene has unsaved changes). With "serialize+restore" the result also has "original_preserved": True.

Raises:
Return type:

dict

export_fbx(path, *, selected_only=False, include_figures=True, include_props=False, include_lights=False, include_cameras=False, include_animations=False, embed_textures=True, options=None)[source]

Export the scene to an FBX file via DAZ Studio’s built-in FBX exporter.

This is a plain synchronous call: FBX export is a native DAZ Studio exporter (DzFbxExporter), so there’s no async job to poll.

Parameters:
  • path (str) – Absolute destination path on the DAZ Studio host (should end in .fbx).

  • selected_only (bool) – Export only the selected node(s).

  • include_figures (bool) – Include figures (default True).

  • include_props (bool) – Include prop nodes.

  • include_lights (bool) – Include scene lights.

  • include_cameras (bool) – Include cameras.

  • include_animations (bool) – Include the current animation take.

  • embed_textures (bool) – Embed texture maps into the FBX file (default True).

  • options (dict | None) – Additional raw DzFileIOSettings overrides (e.g. {"Format": "FBX 2014 -- Binary"}), applied on top of the exporter’s own defaults and the named args above. See DzFbxExporter.getDefaultOptions() for the full set of keys.

export_obj(path, *, selected_only=False, ignore_invisible=True, include_normals=False, collect_maps=False, options=None)[source]

Export the scene to an OBJ file via DAZ Studio’s built-in OBJ exporter.

This is a plain synchronous call – see export_fbx() for why this doesn’t follow the USD export module’s async job pattern.

Parameters:
  • path (str) – Absolute destination path on the DAZ Studio host (should end in .obj).

  • selected_only (bool) – Export only the selected node(s).

  • ignore_invisible (bool) – Skip nodes hidden in the viewport (default True, matches the exporter’s own default).

  • include_normals (bool) – Write vertex normals (WriteVN).

  • collect_maps (bool) – Copy referenced texture maps next to the .obj/.mtl instead of referencing their original paths.

  • options (dict | None) – Additional raw DzFileIOSettings overrides, applied on top of the exporter’s own defaults and the named args above. See DzObjExporter.getDefaultOptions() for the full set of keys.

filename()[source]

Return the file path of the currently loaded scene, or an empty string.

needs_save()[source]

Return True if the scene has unsaved changes.

play_range()[source]

Return the playback range as {"start": int, "end": int} (frames).

set_play_range(start, end)[source]

Set the playback range in frames.

Parameters:
  • start (int) – First frame of the play range.

  • end (int) – Last frame of the play range.

anim_range()[source]

Return the animation range as {"start": int, "end": int} (frames).

set_anim_range(start, end)[source]

Set the animation range in frames.

Parameters:
  • start (int) – First frame.

  • end (int) – Last frame.

is_playing()[source]

Return True if the scene is currently playing back.

loop_playback(on)[source]

Enable or disable looping playback.

Parameters:

on (bool) – True to enable looping, False to disable.

undo_last()[source]

Step back one level in DAZ Studio’s undo stack.

Equivalent to pressing Ctrl+Z / Edit > Undo in DAZ Studio. Has no effect if the undo stack is empty.

Note: this steps the global undo stack. To group a series of changes into a single undoable operation use undo() (the context manager).

redo_last()[source]

Step forward one level in DAZ Studio’s undo stack.

Equivalent to pressing Ctrl+Y / Edit > Redo in DAZ Studio. Has no effect if there is nothing to redo.

is_simulating()[source]

Return True if a dForce simulation is currently running.

clear_dforce_simulation()[source]

Discard all cached dForce simulation data for the active engine.

Returns False without touching the engine when no node in the scene has a dForce modifier: clearSimulation() then pops a modal “No objects to clear” dialog that blocks DAZ Studio until a human clicks OK.

run_dforce_simulation(nodes=None, *, memorized_pose=False, wait=True, timeout=300.0)[source]

Run a dForce simulation using the active simulation engine.

Parameters:
  • nodes (list[DazNode] | None) – Optional subset of nodes to simulate via DzSimulationEngine.customSimulate(). None (default) simulates the whole scene via DzSimulationMgr.simulate(), which follows the frame range configured in the Simulation Settings pane.

  • memorized_pose (bool) – If True, sets the active engine’s startFromMemorizedPose global simulation setting before simulating, so pose-based bulge corrections are computed against the engine’s memorized reference pose instead of the figure’s live pose. Mirrors the “Start Bulge from Memorized Pose” checkbox in DAZ Studio’s Simulation Settings pane.

  • wait (bool) – If True (default), block until the simulation finishes, using the async execute-and-poll endpoint since dForce runs can take minutes. If False, submit the job and return immediately.

  • timeout (float) – Maximum seconds to wait when wait is True.

Returns:

None when wait is True (the simulation already finished by the time this call returns). When wait is False, the request_id of the submitted async job — poll it with get_request_status() / get_request_result().

Raises:

ScriptRuntimeError – If the simulation engine reports an error.

Return type:

str | None

Scene checks

DazScene.check() and dazpy.recipe.check() return a CheckReport. See Scene recipes (Pre-render checks) for the finding codes.

class dazpy.CheckReport(findings=())[source]

Bases: object

Result of a scene check. ok is True when there are no errors.

findings: tuple[CheckFinding, ...] = ()
ok: bool
property errors: tuple[CheckFinding, ...]
property warnings: tuple[CheckFinding, ...]
to_dict()[source]
class dazpy.CheckFinding(severity, code, subject, message, camera=None, shot=None, sides=())[source]

Bases: object

One problem found by a scene check.

severity: "error" (the render is almost certainly wrong) or "warning" (worth a look). code: stable identifier. subject: the figure, camera or "lighting" the finding is about. camera: the camera label checked, when the finding is about framing. shot: the recipe shot id (recipe checks only). sides: for subject_out_of_frame, which frame edges the figure crosses ("top", "bottom", "left", "right", "behind" for a figure partly behind the camera).

severity: Literal['error', 'warning']
code: str
subject: str
message: str
camera: str | None = None
shot: str | None = None
sides: tuple[str, ...] = ()
to_dict()[source]