Inserting Description Elements via Code..
-
On 15/08/2014 at 04:40, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi,I
m trying to figure out how to insert a Description element to my objectdata plugin via code. I already have various plugin options showing up via the res files etc and so am trying to basically grab the nodedata
s Description container and insert a new Real parameter into it ( in such a way that it will show up in the attributes along with everything else when the plugin is launched ).At the moment i am using Description->SetParameter() to achieve this by inserting a new BaseContainer that has been given test values for DESC_NAME, DESC_SHORT_NAME and DESC_UNIT but it isn`t showing up in the attributes manager.
I think it may be something to do with creating proper DESC_ID
s or something. Either that or i am going about this in completely the wrong way! Which is possible as it
s a bit like wandering around in the dark trying to figure this stuff out without proper examples..Here
s the code i have which although the if statement is returning
it is done, it isn
t displaying the parameters as mentioned:Bool MyPlugin::Init(GeListNode *node) { AutoAlloc<Description> desc; node->GetDescription(desc, DESCFLAGS_DESC_0); BaseContainer *descBC = desc->GetParameterI(MYPLUGIN_OBJECTWIDTH, NULL); // This returns an existing parameter successfully BaseContainer newBC = BaseContainer(); newBC.SetString(DESC_NAME, "My Description Param"); newBC.SetString(DESC_SHORT_NAME, "My Description Param"); newBC.SetLong(DESC_UNIT, DESC_UNIT_REAL); if (desc->SetParameter(MYPLUGIN_NEWPARAMETER, newBC, DESCID_ROOT)) { GePrint("it is done"); } else { GePrint("it is not done"); } return TRUE; }
-
On 15/08/2014 at 05:45, xxxxxxxx wrote:
Howdy,
You need to do that in the NodeData::GetDDescription() function. Do a search for GetDDescription here on plugin cafe and you'll find plenty of examples.
Adios,
Cactus Dan -
On 15/08/2014 at 06:09, xxxxxxxx wrote:
Also, it is necessary that you include the Datatype ID in the Description ID you use for SetParameter().
-
On 15/08/2014 at 07:38, xxxxxxxx wrote:
Very much appreciated guys, thank you.
RE the Datatype ID Niklas - do you mean i`d create a DescID with my parameter ID, then insert the Datatype ID into that - using say DescID->PushId() ?
Maybe like this?
DescID MYPLUGIN_NEWPARAMETER = DescID(MYPLUGIN_NEWPARAMETER); MYPLUGIN_NEWPARAMETER.PushId(DESC_UNIT_REAL); desc->SetParameter(MYPLUGIN_NEWPARAMETER, newBC, DESCID_ROOT);
I`m probably confusing things for myself
-
On 15/08/2014 at 07:55, xxxxxxxx wrote:
Nope, like this
DescID descId(DescLevel(MYPLUGIN_NEWPARAMETER, DA_REAL, 0));
DESC_UNIT_REAL is not a datatype ID. If you create a Floating-point parameter, use DA_REAL,
for an Integer parameter DA_LONG, for SplineData CUSTOMDATATYPE_SPLINE, etc.Best,
-NIKLAS -
On 15/08/2014 at 10:05, xxxxxxxx wrote:
Okay - thanks for that, much appreciated.