CAWeightTag Manual


The CAWeightTag class represents a weight tag. A weight tag stores weights that define the influence a joint object has on a deformed mesh. The class is defined in the lib_ca.h header file.

CAWeightTag objects are an instance of Tweights.


A CAWeightTag tag can be accessed like any other tag, see BaseTag and VariableTag Manual.

// This example accesses the selected weight tag
// and prints the names of weighted joints.
// get weight tag
BaseTag* const tag = doc->GetActiveTag();
if (tag == nullptr || !tag->IsInstanceOf(Tweights))
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
CAWeightTag* const weightTag = static_cast<CAWeightTag*>(tag);
// loop through all joints
const Int32 jointCount = weightTag->GetJointCount();
for (Int32 i = 0; i < jointCount; ++i)
const BaseObject* const joint = weightTag->GetJoint(i, doc);
if (joint == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
ApplicationOutput("Joint: " + joint->GetName());
Py_ssize_t i
Definition: abstract.h:645
String GetName() const
Definition: c4d_baselist.h:2363
Definition: c4d_baseobject.h:225
Definition: c4d_basetag.h:48
Bool IsInstanceOf(Int32 id) const
Definition: c4d_baselist.h:1418
Definition: lib_ca.h:179
Int32 GetJointCount()
BaseObject * GetJoint(Int32 index, BaseDocument *doc)
maxon::Int32 Int32
Definition: ge_sys_math.h:60
Definition: memoryallocationbase.h:67
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#define Tweights
Definition: ge_prepass.h:1424
const char * doc
Definition: pyerrors.h:226


CAWeightTag instances are created with the usual tools, see Entity Creation and Destruction Manual (Classic).

// This example creates a new CAWeightTag
// and adds it to the given polygon object.
CAWeightTag* const weightTag = CAWeightTag::Alloc();
if (weightTag == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
static CAWeightTag * Alloc()
Definition: lib_ca.h:192


Standard parameters on a CAWeightTag can be edited with C4DAtom::GetParameter() and C4DAtom::SetParameter(). The parameter IDs are defined in tcaweight.h.


A CAWeightTag manages a list of references to various joint objects.

// This example adds all selected joint objects to the given weight tag.
if (objects == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// get selected objects
doc->GetActiveObjects(objects, GETACTIVEOBJECTFLAGS::CHILDREN);
// loop through all objects
const Int32 objectCount = objects->GetCount();
for (Int32 i = 0; i < objectCount; ++i)
C4DAtom* const atom = objects->GetIndex(i);
BaseObject* const baseObject = static_cast<BaseObject*>(atom);
if (baseObject == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// only add joint objects
if (baseObject->IsInstanceOf(Ojoint))
Definition: ge_autoptr.h:37
Definition: c4d_baselist.h:1377
Int32 AddJoint(BaseObject *op)
#define atom
Definition: graminit.h:72
Child objects are added to the selection too, provided they are selected. Otherwise only the topmost ...
#define Ojoint
Definition: ge_prepass.h:1081

For each joint the reset (or rest) state is stored:

The JointRestState structure has these members:

// This example loops through all joints known by the given weight tag
// and prints the rest state length to the console.
// loop through all joints
const Int32 jointCount = weightTag->GetJointCount();
for (Int32 i = 0; i < jointCount; ++i)
const JointRestState state = weightTag->GetJointRestState(i);
const Float length = state.m_Len;
JointRestState GetJointRestState(Int32 index)
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
Definition: c4d_string.h:529
maxon::Float Float
Definition: ge_sys_math.h:66
PyWideStringList Py_ssize_t length
Definition: initconfig.h:448
Definition: lib_ca.h:109
Definition: grammar.h:37


A CAWeightTag stores weights for each point and joint.

The order of weight values does not correspond to the point order.
// This example loads the weights stored for the given joint
// and prints them to the console window.
// check if any weights are stored
const Int32 weightCount = weightTag->GetWeightCount(jointIndex);
if (weightCount == 0)
const Int32 pointCount = polyObject->GetPointCount();
// allocate memory
weights.Resize(pointCount) iferr_return;
// load weights
Float32* const handle = weights.GetFirst();
weightTag->GetWeightMap(jointIndex, handle, pointCount);
// print weights
for (Int32 weightIndex = 0; weightIndex < pointCount; ++weightIndex)
const Float32 weight = weights[weightIndex];
void GetWeightMap(Int32 index, Float32 *map, Int32 cnt, Bool includeEffectors=false)
Int32 GetWeightCount(Int32 index)
Definition: basearray.h:412
Definition: basearray.h:1326
Definition: basearray.h:1369
maxon::Float32 Float32
Definition: ge_sys_math.h:68
#define iferr_return
Definition: resultbase.h:1465
// This example loops through all points to receive weights for each point.
// loop through all points
const Int32 pointCount = polyObject->GetPointCount();
for (Int32 pointIndex = 0; pointIndex < pointCount; ++pointIndex)
const Float weight = weightTag->GetWeight(jointIndex, pointIndex);
ApplicationOutput("Point " + String::IntToString(pointIndex) + " : " + String::FloatToString(weight));
Float GetWeight(Int32 index, Int32 pntindex)
static String IntToString(Int32 v)
Definition: c4d_string.h:495



CAWeightTag offers these functions:

// This example moves a joint and its rest state
// and updates the rest state data.
// update rest state = + Vector(0, 100.0, 0);
state.m_oMi = ~state.m_oMg;
weightTag->SetJointRestState(1, state);
// update joint object position
BaseObject* const joint = weightTag->GetJoint(1, doc);
if (joint)
// calculate states
void SetMg(const Matrix &m)
Definition: c4d_baseobject.h:488
void CalculateBoneStates(Int32 index)
void SetJointRestState(Int32 index, const JointRestState &state)
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:145
#define NOTOK
Definition: ge_sys_math.h:267

Further Reading