c4d.modules.character.CAWeightMgr

class c4d.modules.character.CAWeightMgr

Represents the Weight Manager.

New in version R19.

Note

Weight Manager data and settings are per document.
Any change on a document does not affect other open documents.

Static Methods Signatures

List Access

c4d.modules.character.CAWeightMgr.GetJointCount()

Queries the number of joints bound to a weight tag.

c4d.modules.character.CAWeightMgr.GetJointId()

Returns the unique Id of a joint.

c4d.modules.character.CAWeightMgr.GetJointIndex()

Finds a joint’s main (tag) and sub (joint) indices in the joint list.

c4d.modules.character.CAWeightMgr.GetJointObject()

Finds a joint object from its indices or Id in the joint list.

c4d.modules.character.CAWeightMgr.GetMeshObject()

Finds the object owning the weight tag from a tag index in the joint list.

c4d.modules.character.CAWeightMgr.GetTagCount()

Queries the number of weight tags for the passed document doc.

c4d.modules.character.CAWeightMgr.GetTagIndex()

Finds a tag’s index in the joint list.

c4d.modules.character.CAWeightMgr.GetWeightTag()

Finds a weight tag from its index in the joint list.

c4d.modules.character.CAWeightMgr.ValidateJointIndex()

Validates tag and joint indices before access.

Locks

c4d.modules.character.CAWeightMgr.IsJointLocked()

Checks if a joint of the Weight Manager list is locked.

c4d.modules.character.CAWeightMgr.LockAllJoints()

Locks all joints of all tags in the Weight Manager list.

c4d.modules.character.CAWeightMgr.LockSelectedJoints()

Locks selected joints in the Weight Manager list.

c4d.modules.character.CAWeightMgr.UnlockAllJoints()

Unlocks all joints of all tags in the Weight Manager list.

c4d.modules.character.CAWeightMgr.UnlockSelectedJoints()

Unlocks selected joints in the Weight Manager list.

Manager Update

c4d.modules.character.CAWeightMgr.GetAutoWeightAlgoId()

Get the AutoWeightRef algorithm’s id associated with the given index.

c4d.modules.character.CAWeightMgr.GetAutoWeightAlgoIndex()

Get the AutoWeightRef algorithm’s index associated with the given id.

c4d.modules.character.CAWeightMgr.GetAutoWeightDictionary()

Get autoweight dictionary of the Weight Manager.

c4d.modules.character.CAWeightMgr.GetParameter()

Retrieves a parameter of the Weight Manager.

c4d.modules.character.CAWeightMgr.SetAutoWeightDictionary()

Get autoweight dictionary of the Weight Manager.

c4d.modules.character.CAWeightMgr.SetDirty()

Sets the Weight Manager dirty to force an update on the next call to Update().

c4d.modules.character.CAWeightMgr.SetParameter()

Sets a parameters of the Weight Manager.

c4d.modules.character.CAWeightMgr.Update()

Updates the internal weighted object list.

Selection

c4d.modules.character.CAWeightMgr.IsJointSelected()

Checks if a joint of the Weight Manager list is selected.

c4d.modules.character.CAWeightMgr.SelectAllJoints()

Selects all joints of all tags in the Weight Manager list.

c4d.modules.character.CAWeightMgr.SelectJoint()

Selects a joint of the Weight Manager list.

c4d.modules.character.CAWeightMgr.UnselectAllJointListNodes()

Deselects all of the nodes in the Weight Manager joint list. This includes all type of nodes (mesh/tag/folder/joint).

c4d.modules.character.CAWeightMgr.UnselectAllJoints()

Deselects all joints of all tags in the Weight Manager list.

c4d.modules.character.CAWeightMgr.UnselectJoint()

Deselects a joint of the Weight Manager list.

Weighting Functions

c4d.modules.character.CAWeightMgr.ApplyWeightFunction()

Applies the currently selected weighting function to the selected joints (add, smooth, remap etc.).

c4d.modules.character.CAWeightMgr.AutoWeight()

Runs an auto weight algorithm on the selected joints.

c4d.modules.character.CAWeightMgr.BakeWeights()

Bakes the effector weights.

c4d.modules.character.CAWeightMgr.ClearWeights()

Clears all weights on the selected joints.

c4d.modules.character.CAWeightMgr.CopyWeights()

Copies the weights of the selected joints into the weights clipboard.

c4d.modules.character.CAWeightMgr.FlipWeights()

Flips the weights of the selected joints. Each joint is flipped on itself using the local axis specified in Weight Manager container.

c4d.modules.character.CAWeightMgr.MirrorWeights()

Mirrors the weights for the selected joints.

c4d.modules.character.CAWeightMgr.NormalizeWeights()

Applies a normalization on the selected joints.

c4d.modules.character.CAWeightMgr.PasteWeights()

Pastes the copied weights on the selected joints.

c4d.modules.character.CAWeightMgr.SmoothWeights()

Smooths the weights of the selected joints.

Static Methods Documentation

static c4d.modules.character.CAWeightMgr.GetJointCount(doc, tagIdx)

Queries the number of joints bound to a weight tag.

Parameters
Return type

int

Returns

The joints count.

static c4d.modules.character.CAWeightMgr.GetJointId(doc, tag, joint)

Returns the unique Id of a joint.

Note

This Id remains valid even if the joint list changes or if undo/redo is used.

Parameters
Return type

int

Returns

The joint unique Id, or sys.maxsize if not found.

static c4d.modules.character.CAWeightMgr.GetJointIndex(doc, tag, joint)

Finds a joint’s main (tag) and sub (joint) indices in the joint list.

Note

The joint index might not match the joint index on the tag.
It is not recommended to keep indices over time, some operations might change the list ordering or length.
Only the Ids to reference joints can be kept over time.
Parameters
Return type

Tuple[int, int]

Returns

The tag’s index in the joint list, or NOTOK/-1 if not found, and the joint’s index in the joint list, or NOTOK/-1 if not found.

static c4d.modules.character.CAWeightMgr.GetJointObject(doc, tagIdx, jointIdx)

Finds a joint object from its indices or Id in the joint list.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

Optional[c4d.modules.character.CAJointObject]

Returns

The joint object, or None if not found.

static c4d.modules.character.CAWeightMgr.GetMeshObject(doc, tagIdx)

Finds the object owning the weight tag from a tag index in the joint list.

Parameters
Return type

Optional[c4d.BaseObject]

Returns

The mesh object, or None if not found.

static c4d.modules.character.CAWeightMgr.GetTagCount(doc)

Queries the number of weight tags for the passed document doc.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

int

Returns

The weight tags count.

static c4d.modules.character.CAWeightMgr.GetTagIndex(doc, tag)

Finds a tag’s index in the joint list.

Parameters
Return type

int

Returns

The tag’s index in the list, or NOTOK/-1 if not found.

static c4d.modules.character.CAWeightMgr.GetWeightTag(doc, tagIdx)

Finds a weight tag from its index in the joint list.

Parameters
Return type

Optional[c4d.modules.character.CAWeightTag]

Returns

The weight tag, or None if not found.

static c4d.modules.character.CAWeightMgr.ValidateJointIndex(doc, tagIdx, jointIdx)

Validates tag and joint indices before access.

Warning

Call before functions that require tag and joint indices to avoid crashes.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

bool

Returns

True if tag and joint indices are valid, otherwise False.

static c4d.modules.character.CAWeightMgr.IsJointLocked(doc, tagIdx, jointIdx)

Checks if a joint of the Weight Manager list is locked.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

bool

Returns

True if the joint was found and is locked, otherwise False.

static c4d.modules.character.CAWeightMgr.LockAllJoints(doc)

Locks all joints of all tags in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if all joints got locked, otherwise False.

static c4d.modules.character.CAWeightMgr.LockSelectedJoints(doc)

Locks selected joints in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.UnlockAllJoints(doc)

Unlocks all joints of all tags in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.UnlockSelectedJoints(doc)

Unlocks selected joints in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.GetAutoWeightAlgoId(doc, index)

Get the AutoWeightRef algorithm’s id associated with the given index.

New in version R21.

Parameters
Return type

maxon.Id

Returns

The index of the autoweight id.

static c4d.modules.character.CAWeightMgr.GetAutoWeightAlgoIndex(doc, stringId)

Get the AutoWeightRef algorithm’s index associated with the given id.

New in version R21.

Parameters
Return type

int

Returns

The index of the autoweight id.

static c4d.modules.character.CAWeightMgr.GetAutoWeightDictionary(doc, stringId)

Get autoweight dictionary of the Weight Manager.

New in version R21.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • stringId (maxon.Id) – The maxon id of the autoweight algorithm.

Return type

maxon.DataDictionary

Returns

The data dictionary with the autoweight parameters inside.

static c4d.modules.character.CAWeightMgr.GetParameter(doc, id)

Retrieves a parameter of the Weight Manager.

Parameters
Return type

Optional[Any]

Returns

The parameter data, otherwise None if the function failed.

static c4d.modules.character.CAWeightMgr.SetAutoWeightDictionary(doc, dataDictionary, stringId)

Get autoweight dictionary of the Weight Manager.

New in version R21.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • dataDictionary (maxon.The data dictionary with the autoweight parameters inside.) – The data dictionary with the autoweight parameters inside.

  • stringId (maxon.Id) – The maxon id of the autoweight algorithm.

Return type

bool

Returns

True if it worked.

static c4d.modules.character.CAWeightMgr.SetDirty(doc)
Sets the Weight Manager dirty to force an update on the next call to Update().

If the Weight Manager dialog is open or if the Weight Manager is active, the update happens automatically at the next frame.
To force an update after a parameter change, use SetDirty(), then call Update(). Call SetDirty() if a Weight Manager’s parameter was directly modified in its container.

Note

Call c4d.EventAdd() to refresh the Weight Manager UI to show the updated changes.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.SetParameter(doc, id, newValue)
Sets a parameters of the Weight Manager.
Result is the same as setting a parameter on the Weight Manager’s container directly except that SetParameter() allows to specify the document in which to set the parameter.

Warning

Setting parameters directly into the Weight Manager’s container is not recommended.
Doing so requires to make the Weight Manager dirty and to update it manually.

Note

Call c4d.EventAdd() to refresh the Weight Manager UI to show the updated changes.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • id (int) – The ID of the parameter to set.

  • newValue (any) – The parameter data to set.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.Update(doc)
Updates the internal weighted object list.

Call before using other methods of CAWeightMgr if the Weight Manager dialog is closed and if the weight tool is inactive. Any of the two condition is enough to have the update run automatically each frame.
Also call if the weighted object list was changed programmatically. For instance after adding a new tag, performing undo redo, or any reason where an update is needed immediately.

Note

Update has no effect if nothing dirty is detected.
Call c4d.EventAdd() to refresh the Weight Manager UI to show the updated changes.
Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.IsJointSelected(doc, tagIdx, jointIdx)

Checks if a joint of the Weight Manager list is selected.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

bool

Returns

True if the joint was found and is selected, otherwise False.

static c4d.modules.character.CAWeightMgr.SelectAllJoints(doc)

Selects all joints of all tags in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

static c4d.modules.character.CAWeightMgr.SelectJoint(doc, tagIdx, jointIdx)

Selects a joint of the Weight Manager list.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

bool

Returns

True if the joint was selected, otherwise False.

static c4d.modules.character.CAWeightMgr.UnselectAllJointListNodes(doc)

Deselects all of the nodes in the Weight Manager joint list. This includes all type of nodes (mesh/tag/folder/joint).

Note

The CAWeightMgr API does not allow selecting/deselecting mesh and tags at the moment.
As a parent mesh, tag, or folder activates the child joints for painting, call this function to get rid of any mesh/tag that could have been already selected.
Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

static c4d.modules.character.CAWeightMgr.UnselectAllJoints(doc)

Deselects all joints of all tags in the Weight Manager list.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

static c4d.modules.character.CAWeightMgr.UnselectJoint(doc, tagIdx, jointIdx)

Deselects a joint of the Weight Manager list.

Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • tagIdx (int) – The tag’s index in the joint list.

  • jointIdx (int) – The joint’s index in the joint list.

Return type

bool

Returns

True if the joint was deselected, otherwise False.

static c4d.modules.character.CAWeightMgr.ApplyWeightFunction(doc, allPoints=False)
Applies the currently selected weighting function to the selected joints (add, smooth, remap etc.).
Uses the parameters currently set in the Weight Manager’s container for the document.

Note

The point selection is fetched from the actual component mode or from point mode if the document is not in component mode.

Parameters
Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.AutoWeight(doc)
Runs an auto weight algorithm on the selected joints.
Uses the parameters currently set in the Weight Manager’s container for the document.

Changed in version R21: allowNull parameter no more there.

Note

Adds an undo.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.BakeWeights(doc, normalize)
Bakes the effector weights.
Uses the parameters currently set in the Weight Manager’s container for the document.
Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • normalize (bool) – True to normalize after bake operation, otherwise False.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.ClearWeights(doc)

Clears all weights on the selected joints.

Note

Adds an undo.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.CopyWeights(doc)

Copies the weights of the selected joints into the weights clipboard.

Note

Document must be in either point, edge or polygon edit mode.
If no selection is present on the mesh, all the point are copied, otherwise only the selected points are copied.
Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.FlipWeights(doc)

Flips the weights of the selected joints. Each joint is flipped on itself using the local axis specified in Weight Manager container.

Note

Both zero and non zero weights are flipped.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.MirrorWeights(doc)
Mirrors the weights for the selected joints.
Uses the parameters currently set in the Weight Manager’s container for the document.

Note

Adds an undo.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.NormalizeWeights(doc)

Applies a normalization on the selected joints.

Note

Some joints can be locked prior to normalization to avoid touching some joints.

Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.PasteWeights(doc, merge)
Pastes the copied weights on the selected joints.
Uses the parameters currently set in the Weight Manager’s container for the document.
Parameters
  • doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

  • merge (bool) –

    True to merge with target weights, False to replace target weights:
    True adds the source weights to the target weights. For instance, source point with null weight does not affect the final result.
    False replaces all the target weights with the source weights including null source weights. For instance, all target weights are lost and replaced with source weights.

Return type

bool

Returns

True if successful, otherwise False.

static c4d.modules.character.CAWeightMgr.SmoothWeights(doc)
Smooths the weights of the selected joints.
Uses the parameters currently set in the Weight Manager’s container for the document.
Parameters

doc (c4d.documents.BaseDocument) – The document for the Weight Manager.

Return type

bool

Returns

True if successful, otherwise True.