THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/04/2008 at 02:40, xxxxxxxx wrote:
I am not sure why it is not working for you without having a look at your source. Here a working example, it's a tag where you can add BOOL description elements with a button.
> \> ///////////////////////////////////////////////////////////// \> // CINEMA 4D SDK // \> ///////////////////////////////////////////////////////////// \> // (c) 1989-2004 MAXON Computer GmbH, all rights reserved // \> ///////////////////////////////////////////////////////////// \> \> // "look at editor camera" expression example \> \> #include "c4d.h" \> #include "c4d_symbols.h" \> #include "tlookatcameraexp.h" \> \> \> // be sure to use a unique ID obtained from www.plugincafe.com \> #define ID_LOOKATCAMERATAG 1001165 //plugin ID \> #define ID_SUBCONTAINER 1022484 //sub-container ID \> \> enum //sub-container element IDs \> { \> LOOKATCAMERAEXP_DESCCOUNT = 2000, //ID for number of added description elements \> LOOKATCAMERAEXP_DESCOFFSET \> }; \> \> class LookAtCamera : public TagData \> { \> public: \> virtual Bool Init(GeListNode \*node); \> \> virtual LONG Execute(PluginTag \*tag, BaseDocument \*doc, BaseObject \*op, BaseThread \*bt, LONG priority, LONG flags); \> virtual Bool GetDDescription(GeListNode \*node, Description \*description,LONG &flags;); \> virtual Bool Message(GeListNode \*node, LONG type, void \*data); \> \> static NodeData \*Alloc(void) { return gNew LookAtCamera; } \> }; \> \> Bool LookAtCamera::Init(GeListNode \*node) \> { \> BaseTag \*tag = (BaseTag\* )node; \> BaseContainer \*data = tag->GetDataInstance(); \> \> BaseContainer subbc; \> subbc.SetLong(LOOKATCAMERAEXP_DESCCOUNT, 0); \> \> data->SetContainer(ID_SUBCONTAINER, subbc); \> \> return TRUE; \> } \> \> \> Bool LookAtCamera::GetDDescription(GeListNode \*node, Description \*description,LONG &flags;) \> { \> if (!description->LoadDescription(ID_LOOKATCAMERATAG)) return FALSE; \> \> BaseTag \*tag = (BaseTag\* )node; \> BaseContainer \*data = tag->GetDataInstance(); \> \> BaseContainer subbc = data->GetContainer(ID_SUBCONTAINER); \> \> LONG desccnt = subbc.GetLong(LOOKATCAMERAEXP_DESCCOUNT); \> LONG i = 0; \> \> for(i=0; i<desccnt; i++) \> { \> BaseContainer bc = GetCustomDataTypeDefault(DTYPE_BOOL); \> \> bc.SetString(DESC_NAME,"Switch"); \> bc.SetString(DESC_SHORT_NAME,"Switch"); \> \> bc.SetLong(DESC_ANIMATE,DESC_ANIMATE_ON); \> bc.SetBool(DESC_REMOVEABLE,FALSE); \> if (!description->SetParameter(DescLevel(LOOKATCAMERAEXP_DESCOFFSET+i,DTYPE_BOOL,0),bc,DescLevel(ID_TAGPROPERTIES))) return FALSE; \> } \> \> flags |= DESCFLAGS_DESC_LOADED; \> \> return TRUE; \> } \> \> Bool LookAtCamera::Message(GeListNode \*node, LONG type, void \*data) \> { \> switch (type) \> { \> case MSG_DESCRIPTION_COMMAND: \> { \> DescriptionCommand \*dc = (DescriptionCommand\* ) data; \> if (dc->id[0].id==ADD_BOOL) \> { \> BaseTag \*tag = (BaseTag\* )node; \> BaseContainer \*data = tag->GetDataInstance(); \> \> BaseContainer subbc = data->GetContainer(ID_SUBCONTAINER); \> LONG desccnt = subbc.GetLong(LOOKATCAMERAEXP_DESCCOUNT)+1; \> subbc.SetLong(LOOKATCAMERAEXP_DESCCOUNT, desccnt); \> data->SetContainer(ID_SUBCONTAINER, subbc); \> } \> } \> } \> \> return TRUE; \> } \> \> LONG LookAtCamera::Execute(PluginTag \*tag, BaseDocument \*doc, BaseObject \*op, BaseThread \*bt, LONG priority, LONG flags) \> { \> return EXECUTION_RESULT_OK; \> } \> \> Bool RegisterLookAtCamera(void) \> { \> // decide by name if the plugin shall be registered - just for user convenience \> String name=GeLoadString(IDS_LOOKATCAMERA); if (!name.Content()) return TRUE; \> return RegisterTagPlugin(ID_LOOKATCAMERATAG,name,TAG_VISIBLE,LookAtCamera::Alloc,"Tlookatcameraexp","lookatcamera.tif",0); \> } \>
> \> CONTAINER Tlookatcameraexp \> { \> NAME Tlookatcameraexp; \> INCLUDE Texpression; \> \> GROUP ID_TAGPROPERTIES \> { \> BUTTON ADD_BOOL { } \> } \> } \>
> \> #ifndef \_Tlookatcameraexp_H\_ \> #define \_Tlookatcameraexp_H\_ \> \> enum \> { \> ADD_BOOL = 1000, \> }; \> \> #endif \>
> \> STRINGTABLE Tlookatcameraexp \> { \> Tlookatcameraexp "Look At Camera Expression"; \> \> ADD_BOOL "Add Switch"; \> } \>
cheers,
Matthias