Using Custom Channel Group/Items
-
On 06/03/2013 at 15:19, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 14
Platform: Windows ; Mac OSX ;
Language(s) : C++ ;---------
I'm trying to understand how to create a new custom group (and string sub item) for a material instance via the C++ API.The idea is that I either create the correct structure if the custom group does not already exist, or update the parameters if it does.
I'm using the following code to create the hierarchy of a read-only string as per the docs (of which I have to admit that I only partially understand the intricacies of it) :
DynamicDescription* dd = pMaterial->GetDynamicDescription();
BaseContainer groupContainer;
dd->FillDefaultContainer(groupContainer, DTYPE_GROUP, "New Group");DescID groupID = dd->Alloc(groupContainer);
dd->Set(groupID, groupContainer, pMaterial);BaseContainer stringContainer;
dd->FillDefaultContainer(stringContainer, DTYPE_STRING, "New String");
GeData dataID;
dataID.SetCustomDataType(CUSTOMDATATYPE_DESCID, groupID);GeData dataIDStaticText;
dataIDStaticText.SetLong(CUSTOMGUI_STATICTEXT);stringContainer.SetData(DESC_PARENTGROUP, dataID);
stringContainer.SetData(DESC_CUSTOMGUI, dataIDStaticText);
DescID stringID = dd->Alloc(stringContainer);
dd->Set(stringID, stringContainer, pMaterial);But how do I now actually set the string user value I've created? I'm obviously missing something particularly obvious here
I thought it might be through stringContainer.SetString( ... ) call, but I don't know what ID to pass in the first parameter if that is the call to use - I'm assuming it's hidden somewhere in the stringID DescID structure perhaps ....
Going from here, how would I then later see if this string entry exists (so to skip the generation of the hierarchy) and extract the static text from it?
Thanks for any help you may be able to give - always greatly appreciated!
-
On 07/03/2013 at 01:01, xxxxxxxx wrote:
Hi Simon,
Originally posted by xxxxxxxx
But how do I now actually set the string user value I've created? I'm obviously missing something particularly obvious here
I thought it might be through stringContainer.SetString( ... ) call, but I don't know what ID to pass in the first parameter if that is the call to use - I'm assuming it's hidden somewhere in the stringID DescID structure perhaps ....
Going from here, how would I then later see if this string entry exists (so to skip the generation of the hierarchy) and extract the static text from it?
To set the string user data you just have to use SetParameter() just like a standard parameter except its ID is stored at the ID_USERDATA main-level.
But in your code the custom data IDs are built by CINEMA so you can just do:pMaterial->SetParameter(stringID, "String", DESCFLAGS_SET_0);
You can reversely get the custom string parameter value with GetParameter().
To see if it exists, see DynamicDescription::Find() and DynamicDescription::Browse*() methods.