SOLVED "two-leveled" ID ( [50004,1] ) of a Constraint Tag? C++

Hello.

Language: C++

Can you help me to figure it out?
I understand how to set a simple single-DescLevel parameter like a sphere radius. I've found in manual how to set up more complex double desclevel parameter, like CubeLen.
But what I can`t understand is - how to set parameter like a ID_CA_CONSTRAINT_TAG_CLAMP_TO
of a constraint tag?
Lets say to a ID_CA_CONSTRAINT_TAG_CLAMP_TO_SURFACE?

It is not simple to understand from a manual.

It is just a simple Integer type, and it should be simple to assign value, but it is not simple to get access exact into the parameter.
In Python it has the "two-leveled" ID ( [50004,1] ) and looks as simple as possible:

Constraint[50004,1] = 4

But how to assign it in C++?

Hello @yaya ,

thank you for reaching out to us. The bracket syntax, i.e., overloading object.__getitem__, is a Python specific convenience method. The special flexibilty of Python's parameter syntax and how it does translate to DescID and DescLevel has been discussed multiple times here on the forum, e.g., here. For details on DescID, we would recommend reading our C++ manual for that type. See end of my posting for how your specific case would translate.

Cheers,
Ferdinand

// This example assumes that 50004 is a sub-container of integers ...

const DescLevel firstLevel (50004, DTYPE_SUBCONTAINER, 0);
const DescLevel secondLevel (0, DTYPE_LONG, 0);
const DescID someId = DescID(firstLevel, secondLevel);

// Assuming someNode is a pointer to some C4DAtom
GeData data;
if (!someNode->GetParameter(someId, data, DESCFLAGS_GET::NONE))
    // Do something to deal with failing to retrieve the parameter.
    // ...

// The value of the parameter.
const Int32 someParameterValue = data.GetInt32();

Hello @yaya ,

thank you for reaching out to us. The bracket syntax, i.e., overloading object.__getitem__, is a Python specific convenience method. The special flexibilty of Python's parameter syntax and how it does translate to DescID and DescLevel has been discussed multiple times here on the forum, e.g., here. For details on DescID, we would recommend reading our C++ manual for that type. See end of my posting for how your specific case would translate.

Cheers,
Ferdinand

// This example assumes that 50004 is a sub-container of integers ...

const DescLevel firstLevel (50004, DTYPE_SUBCONTAINER, 0);
const DescLevel secondLevel (0, DTYPE_LONG, 0);
const DescID someId = DescID(firstLevel, secondLevel);

// Assuming someNode is a pointer to some C4DAtom
GeData data;
if (!someNode->GetParameter(someId, data, DESCFLAGS_GET::NONE))
    // Do something to deal with failing to retrieve the parameter.
    // ...

// The value of the parameter.
const Int32 someParameterValue = data.GetInt32();

Hello @ferdinand ,

Thank you for your answer!
I made a search by the forum but have lost your post above because of I sorted topics only for a C++. My bad)
I also read the C++ manual for a DescID and DescLevel and the examples in there. But they are not cover the examples like my above for a [50004,1] - IDs (or maybe I've not found).
For a Python version of my plugin I did not have a problem with understanding the access to the parameters at all. But on C++...
For example I stuck in my mind with figuring out how does the second DescLevel work. But after your explanation above I understand it. The first level DescLevel in your code locates this sub-container: изображение_2021-10-15_181737.png

And next with the codeline:

const DescLevel secondLevel (0, DTYPE_LONG, 0);

we access into the one of this items.

So I've changed your your code into:

const DescLevel secondLevel (1, DTYPE_LONG, 0);

and I got access into the 5004,1 item.

Thank you very much!