Scene State
- class dazpy.DazSceneState(skeleton_poses, camera_transforms, light_transforms, light_extra, follow_targets=None)[source]
Bases:
objectA full snapshot of scene state, suitable for a save/restore checkpoint.
Captures every skeleton’s complete pose (bone rotations, morphs, and node-level properties – see
DazPose) plus transform and a handful of key properties for every camera and light in the scene. Everything is captured and restored via each property’s raw (pre-ERC) value, so repeated capture/apply cycles are idempotent even for properties driven byDzERCLinkcontrollers (e.g. a “Scale” dial fed by dozens of linked morphs) – seeDazPoseandraw_valuefor why this matters.Skeletons, cameras, and lights are all keyed by their internal name (not display label), since labels are user-editable and not guaranteed unique.
Typical workflow:
from dazpy import DazScene, DazSceneState scene = DazScene() checkpoint = DazSceneState.capture(scene) ... # experimental changes checkpoint.apply(scene)
- classmethod capture(scene)[source]
Capture the current state of every skeleton, camera, and light in scene.
- Parameters:
scene (DazScene) – The scene to capture.
- Returns:
A new
DazSceneState.- Return type:
- apply(scene, *, max_verify_retries=2, verify_tolerance=0.05)[source]
Apply this snapshot’s skeleton poses, camera transforms, and light properties back onto scene in a small, fixed number of HTTP calls.
Nodes that no longer exist in the scene are skipped and reported in
errorsrather than raising – matching the behaviour of the registered-script checkpoint this class replaces.Each skeleton restore is independently verified: after
pose.apply_full(skel)returns, a freshDazPose.capture()is taken and compared against the checkpoint. This guards againstapply_full()reporting success for a restore DAZ Studio’s single-threaded main loop only partially executed under contention (see dpi-mxq) – the HTTP call can return normally even though some bone/morph/prop writes never happened. A skeleton whose read-back doesn’t match is retried (re-runningapply_fulland re-verifying) up to max_verify_retries times before being reported inerrorsinstead ofrestored, so callers never trust an unverified result.- Parameters:
scene (DazScene) – The scene to restore state into.
max_verify_retries (int) – How many additional
apply_fullattempts to make for a skeleton whose read-back doesn’t verify, before giving up on it.verify_tolerance (float) – Per-channel tolerance (degrees for bones, raw value units for morphs/props) allowed between the checkpoint and the read-back before it’s considered a mismatch.
- Returns:
{"restored": [name, ...], "errors": [message, ...]}.- Return type: