Skeleton & Bones
DazSkeleton
- class dazpy.DazSkeleton(client, identifier)[source]
Bases:
DazNodeProxy for a
DzSkeleton(a rigged figure such as Genesis 9).Extends
DazNodewith bone-access helpers.- bone_names()[source]
Return the internal name of every bone in this skeleton, in one call.
Cheaper than
bones()when only the names are needed, e.g. to pick the bone a figure generation uses for a role (chestUpperon Genesis 3/8,spine4on Genesis 9).
- bone_metadata()[source]
Return bulk metadata for every bone in one HTTP call.
This is the live-facing efficiency path used by the interaction adapter. It avoids one request per bone when building rig profiles.
- find_bone(name)[source]
Find a bone by its internal name.
- Parameters:
name (str) – The
getName()string of the bone. Naming conventions differ by figure generation: Genesis 9 uses snake_case (e.g."r_forearm"); Genesis 3/8 uses"rForearmBend"/"lForearmBend"; Genesis 1/2 uses"rForeArm"/"lForeArm". Usebones()to list every bone name for the loaded figure.- Returns:
A
DazBoneproxy.- Raises:
NodeNotFoundError – If no bone with that name exists.
- Return type:
- find_bone_by_label(label)[source]
Find a bone by its user-visible label.
- Parameters:
label (str) – The
getLabel()string of the bone.- Returns:
A
DazBoneproxy.- Raises:
NodeNotFoundError – If no bone with that label exists.
- Return type:
- bone_rotations()[source]
Return Euler rotations for every bone in one HTTP call.
Equivalent to calling
local_euleron every bone returned bybones(), but rounds-trips only once.
- bone_rotations_quat()[source]
Return local-space quaternion rotations for every bone in one HTTP call.
Equivalent to calling
local_rotationon every bone returned bybones(), but rounds-trips only once. Prefer this overbone_rotations()when the result will be composed with other rotations (e.g. an axis remap viaAxisRemap) — quaternions avoid the per-bone Euler rotation-order ambiguity thatrotation_orderotherwise requires tracking.
- set_bone_rotations(data)[source]
Set Euler rotations for any subset of bones in one HTTP call.
Only the bones named in data are modified; all others are unchanged. Equivalent to calling
set_local_rotation()per bone, but rounds-trips only once.
- set_bone_axes(data)[source]
Set individual rotation axes on any subset of bones in one HTTP call.
Unlike
set_bone_rotations(), which writes all three axes, this writes only the axes named for each bone, so an adjustment like “tilt the chest forward 5 degrees” leaves the chest’s twist and side-bend alone.- Parameters:
data (Mapping[str, Mapping[str, float]]) –
{bone_name: {"x": deg, "y": deg, "z": deg}}; each inner mapping may name any subset of"x","y","z".- Returns:
Names from data that matched no bone (all of them if the skeleton is not in the scene). Bones that matched were written.
- Raises:
ValueError – If an inner mapping names an axis other than x/y/z.
- Return type:
- key_bone_axes(data)[source]
Keyframe individual rotation axes of bones at timeline frames, in one call.
- look_at(point, chain)[source]
Turn a chain of bones toward a world-space point, in one call.
chain lists
(bone_name, weight)from the root of the chain to the tip (e.g. chest, neck, head, eyes). Each bone, in order, turns weight of the way toward the point from where its parents left it, so a final weight of 1.0 aims the last bone exactly (as far as its joint limits allow). The direction is worked out in the bone’s own rotation frame (parent world rotation times the bone’s orientation), so a turned or leaning figure still looks the right way. Only the X (pitch) and Y (yaw) rotations are written; Z (roll) is left alone. Bones whose rest pose faces +Z, as Genesis heads and eyes do, are assumed.- Parameters:
- Returns:
each bone’s rotation as Studio kept it, and the chain bones not on this figure.
- Return type:
LookAtResult- Raises:
ValueError – If a weight is outside
[0, 1].NodeNotFoundError – If the skeleton is not in the scene.
- set_state(bones=None, morphs=None, props=None)[source]
Set bone rotations, morph values, and/or node properties in one call.
Equivalent to calling
set_bone_rotations(),set_morph_values(), and/or repeatedset_property()calls, but round-trips only once. Each argument is independently optional.bones/morphsuse plainsetValue()writes, matchingset_bone_rotations()/set_morph_values()exactly — this method does not change which write path those two use.propsalso uses plainsetValue()(likeset_property()); it is NOT routed throughapply_full()’sDzERCLink-avoidance logic (seedazpy/_pose.py~lines 117-125), so on ERC-driven node properties this can double-apply a controller contribution the same wayset_property()already can.- Parameters:
bones (dict[str, tuple | list] | None) –
{bone_name: (x, y, z)}Euler degrees. Bones not named are unchanged.morphs (dict[str, float] | None) –
{morph_name: float}. Morphs not named are unchanged.props (dict[str, object] | None) –
{property_label: value}node-level properties. Properties not named are unchanged.
- evaluate_pose(rotations, effector_bone_names)[source]
Apply candidate rotations, read effector world positions, then restore.
The figure is left in its original state after this call. Use this to ask “if I posed these bones this way, where would the effectors end up?” without committing anything to the scene.
- Parameters:
- Returns:
{bone_name: (x, y, z)}world-space positions for each requested effector bone. Bones not found in the skeleton are omitted.- Return type:
- evaluate_pose_jacobian(chain_bone_names, effector_bone_name, step_degrees=1.0)[source]
Compute the IK Jacobian for a bone chain server-side in one HTTP call.
For each bone in chain_bone_names and each of its three rotation axes, this perturbs the bone by step_degrees, reads the effector world position, and restores the original rotation. The figure is left unchanged.
- Parameters:
- Returns:
"base_position"—[x, y, z]world position of the effector before any perturbation."columns"— list of[dx, dy, dz]Jacobian columns, one per (bone × axis) pair, ordered asbone0_x, bone0_y, bone0_z, bone1_x, …. Each column is the normalized position change(trial_pos - base_pos) / step_degrees.
Returns
Noneif the effector bone cannot be found.- Return type:
A dict with keys
- morph_values(nonzero_only=False)[source]
Return the current value of every DzMorph modifier in one HTTP call.
- set_morph_values(data)[source]
Set the value of any subset of morphs in one HTTP call.
Only morphs named in data are modified; all others are unchanged.
- hand_to_target(target_point, *, source_anchor='r_hand', max_iterations=12, step_degrees=1.0, damping=0.25, tolerance=0.15)[source]
Align a hand anchor toward a world-space target point.
- foot_to_target(target_point, *, source_anchor='r_foot', max_iterations=12, step_degrees=1.0, damping=0.25, tolerance=0.15)[source]
Align a foot anchor toward a world-space target point.
- bake_bone_rotations(start=None, end=None, bone_names=None)[source]
Bake bone rotation keyframes for every frame in the range.
Scrubs the timeline server-side. For each frame, the current evaluated X/Y/Z rotation of every bone (including IK, constraints, and driven keys) is stamped as an explicit keyframe via
insertKey. After baking, the animation plays back without requiring any of the original drivers.The original frame is restored before the call returns.
- Parameters:
- Returns:
{"frames_baked": int, "bones_baked": int}- Raises:
NodeNotFoundError – If the skeleton is not found.
- Return type:
- bake_morphs(start=None, end=None, morph_names=None)[source]
Bake morph channel keyframes for every frame in the range.
For each frame, the current value of every
DzMorphmodifier is stamped as an explicit keyframe viainsertKey.The original frame is restored before the call returns.
- bake(start=None, end=None, bone_names=None, include_morphs=False, morph_names=None)[source]
Bake bone rotations and optionally morphs in a single HTTP call.
Combines
bake_bone_rotations()andbake_morphs()into one server-side loop so the timeline is only scrubbed once.- Parameters:
start (int | None) – First frame to bake.
None→ play-range start.end (int | None) – Last frame to bake.
None→ play-range end.bone_names (list[str] | None) – Bones to bake.
None→ all bones.include_morphs (bool) – Also bake
DzMorphchannels.morph_names (list[str] | None) – Morphs to bake (only used when include_morphs is
True).None→ all morphs.
- Returns:
{"frames_baked": int, "bones_baked": int, "morphs_baked": int}- Return type:
DazBone
- class dazpy.DazBone(client, identifier)[source]
Bases:
DazNodeProxy for a
DzBone(a single joint within aDazSkeleton).Extends
DazNodewith bone-specific rotation helpers.- property local_euler: tuple[float, float, float] | None
Local-space rotation as an
(x, y, z)tuple of Euler angles in degrees.Reads the same rotation controls written by
set_local_rotation(), so the two are exact inverses.- Returns:
(x, y, z)in degrees, orNoneif the bone cannot be found.
- property local_rotation: dict | None
Local-space rotation as
{"x", "y", "z", "w"}quaternion (read-only).
- get_skeleton()[source]
Return the parent
DazSkeleton, orNone.