Open Search
    NodeData::GetDParameter() Manual

    About

    NodeData based Cinema API plugin classes can implement NodeData::GetDParameter(). This allows to define the values of parameters accessed with C4DAtom::GetParameter(). This is done to handle data that is not stored in the object's BaseContainer. It is also used to create parameters that depend on the value of other parameters or element properties.

    NodeData::GetDParameter() corresponds to C4DAtom::GetParameter().

    Note
    In most cases, when implementing NodeData::GetDParameter(), one will also need to implement NodeData::SetDParameter(). For example, if the value is stored in a member variable.

    Usage

    NodeData::GetDParameter() is called when the value of a parameter is accessed with C4DAtom::GetParameter(). It is possible to define or change the returned value.

    Bool GetDParameter(const GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags) const
    {
    if (node == nullptr)
    return false;
    // check parameter ID
    switch (id[0].id)
    {
    // This parameter is not stored in the BaseContainer
    case EXAMPLE_GENERATOR_PARAMETER_NOT_BC:
    {
    // set the value from a member variable
    t_data.SetInt32(_value);
    // Parameter retrieved.
    return true;
    }
    }
    return SUPER::GetDParameter(node, id, t_data, flags);
    }
    PyCompilerFlags * flags
    Definition: ast.h:14
    PARAM_GET
    Parameter retrieved.
    Definition: ge_prepass.h:1
    DESCFLAGS_GET
    Definition: ge_prepass.h:3380
    maxon::Bool Bool
    Definition: ge_sys_math.h:46
    Definition: node.h:10
    Note
    Such member variables must also be handled in NodeData::Read(), NodeData::Write(), NodeData::CopyTo() and NodeData::SetDParameter().

    The arguments of the function are:

    Certain cases have to be handled with special functions:

    Further Examples

    // This example of a TagData plugin defines the value of the
    // Tag's parameter by calculating the volume of the host object.
    Bool GetDParameter(const GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags) const
    {
    if (node == nullptr)
    return false;
    // check parameter ID
    switch (id[0].id)
    {
    case EXAMPLE_TAG_VOLUME:
    {
    Float volume = 0.0;
    GeData data;
    const BaseTag* const tag = static_cast<const BaseTag*>(node);
    if (tag != nullptr)
    {
    const BaseObject* const hostObject = tag->GetObject();
    if (hostObject != nullptr)
    {
    // check the object type
    switch (hostObject->GetType())
    {
    // calculate volume of sphere primitive
    case Osphere:
    {
    hostObject->GetParameter(ConstDescID(DescLevel(PRIM_SPHERE_RAD)), data, DESCFLAGS_GET::NONE);
    const Float radius = data.GetFloat();
    volume = (4.0 / 3.0) * maxon::PI * radius * radius * radius;
    break;
    }
    // calculate volume of cylinder primitive
    case Ocylinder:
    {
    hostObject->GetParameter(ConstDescID(DescLevel(PRIM_CYLINDER_RADIUS)), data, DESCFLAGS_GET::NONE);
    const Float radius = data.GetFloat();
    hostObject->GetParameter(ConstDescID(DescLevel(PRIM_CYLINDER_HEIGHT)), data, DESCFLAGS_GET::NONE);
    const Float height = data.GetFloat();
    volume = maxon::PI * radius * radius * height;
    break;
    }
    // etc.
    default: break;
    }
    }
    }
    t_data.SetFloat(volume);
    flags |= DESCFLAGS_GET::PARAM_GET; // don't forget to set this flag
    return true;
    }
    }
    return SUPER::GetDParameter(node, id, t_data, flags);
    }
    NONE
    Definition: asset_browser.h:1
    static constexpr Float64 PI
    floating point constant: PI
    Definition: apibasemath.h:139
    #define Ocylinder
    Cylinder.
    Definition: ge_prepass.h:1129
    #define Osphere
    Sphere.
    Definition: ge_prepass.h:1119
    #define ConstDescID(...)
    Definition: lib_description.h:592
    maxon::Float Float
    Definition: ge_sys_math.h:57
    struct _node node
    @ PRIM_CYLINDER_HEIGHT
    Definition: ocylinder.h:13
    @ PRIM_CYLINDER_RADIUS
    Definition: ocylinder.h:8
    @ PRIM_SPHERE_RAD
    Definition: osphere.h:6

    Further Reading