get all descriptions of a node
-
On 05/08/2015 at 17:59, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 15+
Platform:
Language(s) : C++ ;---------
I want to get all descriptions of any node, hidden or not, my current code works to some extent, but it misses some descriptions!!here is the code:
Bool checkContainers(BaseObject *op) { AutoAlloc<Description> desc; if(!desc) return FALSE; if(!op->GetDescription(desc, DESCFLAGS_DESC_0)) return FALSE; void *bh = NULL; bh = desc->BrowseInit(); if(!bh) return FALSE; const BaseContainer *bc = NULL; DescID id, groupid; GeData data; while(desc->GetNext(bh, &bc, id, groupid)) { const BaseContainer *dbc = desc->GetParameterI(id,NULL); if(dbc) GePrint("Name: "+dbc->GetString(DESC_NAME)); if(op->GetParameter(id, data, DESCFLAGS_GET_0)) { //data is the description data GePrint("Type: "+String::IntToString(data.GetType())); } } desc->BrowseFree(bh); return TRUE; }
Bool checkDynamicContainers(BaseObject *op) { DynamicDescription *userdata = NULL; userdata = op->GetDynamicDescription(); if (userdata) { GePrint("DynamicDescription: " + op->GetName()); void *handle = NULL; handle = userdata->BrowseInit(); LONG cnt = 0; DescID descid; GeData data; const BaseContainer *dbc = NULL; while (userdata->BrowseGetNext(handle, &descid, &dbc)) { GePrint("Name: "+dbc->GetString(DESC_NAME)); if(op->GetParameter(descid, data, DESCFLAGS_GET_0)) { //data is the description data GePrint("Type: "+String::IntToString(data.GetType())); } } userdata->BrowseFree(handle); //userdata found if (cnt > 0) return 1.0; } return TRUE; }
so far when I use this with RayObject->link->""GetUp()/GetCacheParent()"", it works fine to some extent, it gives me all containers that I see in AM.
what I miss here, getting hidden stuff, for example:
BaseObject * cacheParent = rayObject->link->GetCacheParent(); if(cacheParent) { BaseContainer * bc = cacheParent->GetDataInstance(); const Int32 index = bc->GetInt32(BC_ID_MODATAINDEX,NOTOK); if(index != NOTOK) { GePrint("index: "+String::IntToString(index)); } }
this code works if the generated RayObject is from a mograph clone, but here I access the container directly from BC_ID_MODATAINDEX, how to get this container using BrowseInit().... "or any other automated way to get all of these hidden stuff"
-
On 06/08/2015 at 01:45, xxxxxxxx wrote:
Hello,
one must not confuse Descriptions and BaseContainer values.
The parameter description is just that – a definition of a GUI element, created by an object and used by the Attribute Manager to display some GUI. These GUI elements may not be fixed since the Description can be edited in GetDDescription().
Also, a parameter that may be displayed using a Description may not be stored in the BaseContainer since one can use SetDParameter() / GetDParameter().
So it is possible to store a value in an object's BaseContainer without any associated parameter that may or may not be visible in the Attribute Manger. But you can loop through all values that are stored in a given BaseContainer using BrowseContainer.
Best wishes,
Sebastian -
On 06/08/2015 at 02:35, xxxxxxxx wrote:
Hi Sebastian,
thanks a lot for clarifications
I'm getting closer to what I want, but one last thing, how to read the name of the id? "a smart way to access the resource or associated name somewhere"here is what I did so far:
Bool checkContainers(BaseObject *op) { AutoAlloc<Description> desc; if(!desc) return FALSE; if(!op->GetDescription(desc, DESCFLAGS_DESC_0)) return FALSE; void *bh = NULL; bh = desc->BrowseInit(); if(!bh) return FALSE; const BaseContainer *bc = NULL; DescID id, groupid; GeData data; while(desc->GetNext(bh, &bc, id, groupid)) { const BaseContainer *dbc = desc->GetParameterI(id,NULL); if(dbc) GePrint("Name: "+dbc->GetString(DESC_NAME)); if(op->GetParameter(id, data, DESCFLAGS_GET_0)) { //data is the description data GePrint("Type: "+String::IntToString(data.GetType())); } Int32 sub_id; GeData *sub_data = nullptr; BrowseContainer m_dbc(dbc); while(m_dbc.GetNext(&sub_id, &sub_data)) { BaseContainer *m_dbc_bc = sub_data->GetContainer(); if(m_dbc_bc) GePrint("sub Name: "+m_dbc_bc->GetString(DESC_NAME)); GePrint("sub Type: "+String::IntToString(sub_data->GetType())); } } desc->BrowseFree(bh); return TRUE; }
so to summarize, I just need the names of these "sub_data"
-
On 06/08/2015 at 02:53, xxxxxxxx wrote:
We have sample c++ snippet in remotion c++, maybe helps:
{ BaseDocument *doc = GetActiveDocument(); if(!doc) return FALSE; BaseObject *obj = doc->GetActiveObject(); if(!obj) return FALSE; AutoAlloc<Description> desc; if (!desc) return FALSE; if (!obj->GetDescription(desc, DESCFLAGS_DESC_0)) return FALSE; DescID dcid, groupid; void *handle = desc->BrowseInit(); if (!handle) return FALSE; //We will store the description values in this variable GeData gd; const BaseContainer *objBc = NULL; while (desc->GetNext(handle, &objBc, dcid, groupid)) { if (objBc) { const String name = objBc->GetString(DESC_NAME); //The text in the GUI for each Gizmo (like the .str file works in plugins) const String ID = objBc->GetString(DESC_IDENT); //The description's ID# expressed in text form GePrint(name + " " + ID); obj->GetParameter(DescID(dcid), gd, DESCFLAGS_GET_0); //Get all the description values and store them in variable "d" //Now we need to check the "gd" variable for the specific type of data each description can store const Real rValue = gd.GetReal(); const LONG lValue = gd.GetLong(); const String sValue = gd.GetString(); GePrint("RealValue: " +RealToString(rValue) + " , " + "LongValue: " +LongToString(rValue) + " , " + "StringValue: " +sValue); } } desc->BrowseFree(handle); //Free the memory used by the Browse function }
-
On 07/08/2015 at 07:18, xxxxxxxx wrote:
Hello,
what I was actually trying to say was that you can use BrowseContainer to check all values stored in the object's BaseContainer – so also values that don't have a "name".
I'm not sure what exactly you are trying to achieve in your code and why you want to get the subcontainer of the BaseContainer returned by GetParameterI().
Best wishes,
Sebastian -
On 07/08/2015 at 07:41, xxxxxxxx wrote:
Hi Sebastian,
I'm making an attribute system, "consider it xpresso 2" , and I need to access all containers for this.
any suggestions?