DescriptionCommand

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 19/04/2012 at 22:43, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Hi Folks,
I'm trying to get a customgui button to action another tag's button. I can get it to work if my button is a normal DTYPE_BUTTON but it won't work for a CUSTOMGUI_BUTTON. The following is being called from the obj's Command() :

  
DescriptionCommand *dc_button = (DescriptionCommand* )data;  
LONG Button = dc_button->id[0].id;  
switch (Button)  
{  
case ID_TAB_CUSTOM_BUTTONS:   
BaseTag *Record = obj->GetTag(Tsticktexture);  
DescriptionCommand dc;  
dc.id = DescID(DescLevel(1001));  
Record->Message(MSG_DESCRIPTION_COMMAND, &dc);  
break;  
}  

What's the trick I'm missing here?
WP.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/04/2012 at 09:20, xxxxxxxx wrote:

Most of the code you posted seems to work fine in my own ResBased Dialog plugin.
This is the code I pasted into my plugin:

Bool myDialog::Command(LONG id,const BaseContainer &msg)  
{  
  switch (id)   
   {  
  
      case 10001:  
     GePrint("Custom GUI Button Was Pressed");  
  
     BaseObject *obj = doc->GetActiveObject();   
          BaseTag *Record = obj->GetTag(Tsticktexture);      //Get the stick texture tag   
          DescriptionCommand dc;                             //Create a description variable to hold the id of the tag's button  
          dc.id = DescID(DescLevel(STICKTEXTURETAG_RECORD)); //Get the tag's Record button id and assign it to "dc.id"  
          Record->Message(MSG_DESCRIPTION_COMMAND, &dc);     //Execute that button command  
          break;  
    }  
  
  
  return TRUE;  
}

Case 10001 is a customGUI bitmap button in my plugin. And the stick texture tag's record button seems to execute properly for me when that customGUI button is clicked.

Here's a link to my plugin(without the sticktexturetag code added). Maybe it will help you'll find the problem in your files:
https://sites.google.com/site/scottayersmedia/ResBasedDialog_C%2B%2B.zip

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/04/2012 at 20:47, xxxxxxxx wrote:

I've just realised I'm calling this from Message() and not the Command(). Would that make any difference?

Bool PLUGINOBJECT::Message(GeListNode *node, LONG type, void *data)  
{  
 switch (type)   // PRESS BUTTON COMMANDS  
 {  
   case MSG_DESCRIPTION_COMMAND:  
{  
 DescriptionCommand *dc_Custom = (DescriptionCommand* )data;  
 LONG Custom_Button = dc_Custom->id[0].id;  
 switch (Custom_Button)  
 {  
 case ID_TAB_CUSTOM_BUTTONS:          // ID No. 2004  
          GePrint("Custom button pressed...");  
 break;  
 }  
}  
 }  
 return TRUE;  
}

I put in a print to console instead for testing - but it won't print to console either. Here's my description element (just in case!) :

cid = DescLevel(ID_TAB_CUSTOM_BUTTONS, DTYPE_BUTTON, 0);  
if (!id_One || cid.IsPartOf(*id_One,NULL))  
{  
BaseContainer locked = GetCustomDataTypeDefault(CUSTOMGUI_BITMAPBUTTON);  
//locked.GetCustomDataType( DTYPE_BUTTON, CUSTOMGUI_BITMAPBUTTON);  
locked.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_BITMAPBUTTON);  
locked.SetBool(BITMAPBUTTON_BUTTON, TRUE);  
locked.SetLong(BITMAPBUTTON_BORDER, BORDER_NONE);  
locked.SetLong(BITMAPBUTTON_ICONID1, 1028324);  
locked.SetString(DESC_NAME, "");  
locked.SetString(DESC_SHORT_NAME, "");  
if (!description->SetParameter(cid, locked, DescLevel(ID_TAB_ONE_GRP_CUSTOM_BUTTONS))) return TRUE;  
}

I wonder if this has something to do with me not using a res file for the layouts? Surely not?
 
WP.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/04/2012 at 21:44, xxxxxxxx wrote:

For some reason I was thinking that you were making a dialog type plugin.
What kind of plugin are you making?

For dialog plugins. Buttons are set up in the CreateLayout()method using either a .res file or the built-in Add() functions. Or a mixture of both.
Then they are executed in the Command() method.

For the other kinds of plugins. Buttons are set up and executed in the Message() method.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 20/04/2012 at 21:48, xxxxxxxx wrote:

Hi there Scott - thanks for your persistance!
 
My apologies - I should have made it a bit clearer in my original post. It's an object plugin, and I was initially trying to get it to press a tag's button from a tag that's sitting on that object (the sticktexture tag). I can get this to work with just a normal DTYPE_BUTTON but not with a customgui button.
 
So to be clear - it's an object plugin, and I was trying to press a custom button through the Mesage() method.
 
WP.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 09:12, xxxxxxxx wrote:

I've never tried to use customgui like that with an object plugin. But I have created custom bitmap buttons on tags.
I used GetD&SetDParameter() methods to make them work.
But I have no idea if this applies at all to what you're trying to do.

...The class  
class SimpleTag : public TagData  
{  
  INSTANCEOF(SimpleTag,TagData)  
  
  public:  
  virtual Bool Message(GeListNode *node, LONG type, void *t_data);  
  virtual Bool Init(GeListNode *node);  
  virtual Bool GetDDescription(GeListNode *node, Description *description,DESCFLAGS_DESC &flags);      
  virtual Bool GetDParameter(GeListNode *node, const DescID &id,GeData &t_data,DESCFLAGS_GET &flags);  
  virtual Bool SetDParameter(GeListNode *node, const DescID &id,const GeData &t_data,DESCFLAGS_SET &flags);  
  virtual EXECUTIONRESULT Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags);          
  static NodeData *Alloc(void) { return gNew SimpleTag; }  
};  
  
  
...The GetD method  
Bool SimpleTag::GetDParameter(GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags) //Used to get the decriptions data   
{  
  
  switch(id[0].id)  //Get the id's in the tag  
  {  
    case TEST_BUTTON:  
       {  
         LONG dirty = 0;  
         BitmapButtonStruct bbs(static_cast<BaseObject*>(node), id, dirty); //The tag is the op, 'TEST_BUTTON' is the id, 'dirty' is the dirty option value  
         t_data = GeData(CUSTOMDATATYPE_BITMAPBUTTON, bbs);  
         flags |= DESCFLAGS_GET_PARAM_GET;  
         break;  
       }  
  }  
  
  return SUPER::GetDParameter(node, id, t_data, flags);  
}  
  
  
...The SetD method  
Bool SimpleTag::SetDParameter(GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags) //Used to change the decriptions data  
{  
  switch(id[0].id)                          //Get the id's in the tag  
  {  
    case TEST_BUTTON:                       //If the id is 'TEST_BUTTON' from the .res file  
     GePrint("Custom Button Pressed");  //Do this  
         break;  
  }  
  
  return SUPER::SetDParameter(node, id, t_data, flags);  
}  
  
  
...The Message method  
Bool SimpleTag::Message(GeListNode *node, LONG type, void *data)  
{  
  
//Bunch of stuff here  
  
////////////// This code loads an image for the bitmap button in the AM /////////////////////////      
  if (type == MSG_DESCRIPTION_GETBITMAP)  
   {  
     DescriptionGetBitmap *dgb = static_cast<DescriptionGetBitmap*>(data);//Create a variable to hold one of the tag's descriptions  
     AutoAlloc<BaseBitmap> bm;                                            //Create an instance of the BaseBitmap calss  
     Filename fn = GeGetPluginPath()+"res"+"myicon.tif";                  //Get the file path  
     String image = fn.GetString();                                       //Get the string name of the file path   
     bm->Init(fn);                                                        //Initialize the BaseBitmap instance  
     dgb->bmp = bm.Release();                                                                                                       
   }  
//////////////////////////////////////////////////////////////////////////////////////////////////  
  
  
//Continue on with other stuff  
  
  
  tag->SetDirty(DIRTYFLAGS_DATA); //Used to update a Tag's AM GUI items  
  return TRUE;  
}

That's about all the help I can offer on this.
I still don't understand a lot about customgui stuff myself. And the C++ SDK is very lacking in that area.

I always use a .res file when making non-dialog based plugins.
I have no idea what problems not using them might, or might not, cause.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 21/04/2012 at 21:55, xxxxxxxx wrote:

Well that's interesting. It works when you're got the Get/SetDParameter() functions there. Why would they run customgui like this and not through the Message() function I wonder? Wouldn't it have been better to have kept buttons in the one area?
 
There needs to be more info/examples available on the customgui stuff. It's too hit and miss as it is.
 
Anyway - the customgui button is working now. For anyone else reading this you need to have the Get/SetDParameter() functions setup with a message() like switch in there.
 
Thanks again Scott. Very much appreciated.
 
WP.