User Data Vector DescID?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/09/2011 at 10:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.6+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Howdy,OK, I know how to set an element of a vector key for a Description Attribute by getting the description ID like this:
// get X pos description ID DescID dscID = DescID(DescLevel(ID_BASEOBJECT_POSITION,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0));
But how do I get the description ID of the X, Y and Z elements of a User Data Vector? It seems like it needs a LONG value to replace the "ID_BASEOBJECT_POSITION" in the above line of code, but what is that ID for the User Data Vector?
The only thing I'm able to get by browsing the User Data descriptions is the DescID like this:
dd->BrowseGetNext(hndl, &dscID, &bc);
... but there doesn't seem to be a function in the DescID class that returns a LONG ID.
So how do I get the LONG ID to use to get the level of the X, Y and Z elements of the User Data Vector so I can set keys?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/09/2011 at 14:19, xxxxxxxx wrote:
Howdy,
Hmmmm, I notice if I drag a User Data to the Command Line, it shows "#ID_USERDATA" and then a number (1, 2, 3, etc.). In the API header "lib_description.h" I see this line:
#define ID_USERDATA 700
So it seems that the LONG ID value I'm trying to get is: ID_USERDATA plus some number.
I thought of just using a loop counter in the browse loop, but then I noticed if you have three User Data attributes (1, 2 and 3) and then you remove number 1, the other two still have their ID's of 2 and 3, so the loop counter idea won't work.
There must be a way of getting that number, because the Command Line is showing it. The question is:
Is that function available to us plugin developers?Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/09/2011 at 17:12, xxxxxxxx wrote:
Howdy,
OK, I can get the number by using:
DescLevel dscLevel = dscID.operator[](1); GePrint("dscLevel.id = "+LongToString(dscLevel.id));
... but neither that ID nor ID_USERDATA plus that ID is the correct description ID needed to set keys for the second level elements of the Vector User Data.
So how can I set keys for the X, Y and Z elements of a Vector User Data?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/09/2011 at 07:52, xxxxxxxx wrote:
Howdy,
OK, never mind I found the answer.
DescLevel dscLevel = dscID.operator[](1); DescID dscIDX = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)); DescID dscIDY = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)); DescID dscIDZ = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0));
It's working now.
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/09/2011 at 13:14, xxxxxxxx wrote:
Hey Dan.
You're talking to yourself.I'm just starting to learn how to use User Data with C++. And the info you posted here might come in handy one day.
But do you happen to know how to get the data values from a vector based UD entry?Here's an example:
DynamicDescription *dd = op->GetDynamicDescription(); if (!dd) return EXECUTIONRESULT_USERBREAK; void *dhandle = dd->BrowseInit(); DescID id; const BaseContainer *bc = NULL; while (dd->BrowseGetNext(dhandle, &id, &bc)) { GeData data; if (op->GetParameter(id, data, DESCFLAGS_GET_0)) { switch (data.GetType()) //data contains the user data data; the data type of the user data { case DA_REAL: GePrint("Real: "+RealToString(data.GetReal())); // Works Fine break; case DA_LONG: GePrint("LONG: "+LongToString(data.GetLong())); // Works Fine break; case DA_VECTOR: GePrint("Vector: Not sure what to put here); //<--How do you get the three vector values? break; } } } dd->BrowseFree(dhandle);
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/09/2011 at 13:37, xxxxxxxx wrote:
Howdy,
Use data.GetVector() to get the vector and then print the three x, y and z components of the vector.
Someone posted this a long time ago:
String VectorToString(const Vector& v) { return "[" + RealToString(v.x) + "," \+ RealToString(v.y) + "," \+ RealToString(v.z) + "]"; }
... along with several other string conversion functions, which I use frequently to print vector values to the console.
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/09/2011 at 14:41, xxxxxxxx wrote:
Thanks.
-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/09/2011 at 02:48, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Howdy,
OK, never mind I found the answer.
DescLevel dscLevel = dscID.operator[](1); DescID dscIDX = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_X,DTYPE_REAL,0)); DescID dscIDY = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_Y,DTYPE_REAL,0)); DescID dscIDZ = DescID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0),DescLevel(dscLevel.id,DTYPE_VECTOR,0),DescLevel(VECTOR_Z,DTYPE_REAL,0));
It's working now.
Adios,
Cactus DanSorry, really hadn't the time to look into this. Great you figured it out on your own.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/09/2011 at 06:08, xxxxxxxx wrote:
Howdy,
Well, my first search was for "Vector User Data" and I just couldn't find anything.
But then, I found this thread when I searched for "DynamicDescription":
https://developers.maxon.net/forum/topic/4264/3815_user-data-in-c&KW=DynamicDescription... which showed me how the ID_USERDATA is used, and the rest was deduced from what I already found out in the documentation.
Adios,
Cactus Dan