On 29/08/2014 at 05:36, xxxxxxxx wrote:

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

I have an object generator plugin and using the GetDDescription override to insert a BitmapButton into the plugins AM..

This is working when using existing icon IDs ( Osphere and Ocube ) but what id like to do is use my own bitmap images instead.  Im aware that one option is to register unique icon ids for these, but i see that BitmapButtonCustomGui has a ->SetImage() method to allocate a BaseBitmap..

The problem is im not instantiating my BitmapButton im just creating the BaseContainer for it inside GetDDescription and adding it to the resource container.  How can i then use SetImage() to apply a bitmap to it?

Or do i have to register them as icons and if so where do i do that?

Here`s roughly the code i have:

Bool MyPlugin::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags)
	if (!description->LoadDescription(node->GetType())) return FALSE;
	BaseContainer *props = description->GetParameterI(DescLevel(ID_MYGROUP), NULL);  //Get existing Group from my static resource
	if (props)
		BaseContainer bbutn;
		bbutn= GetCustomDataTypeDefault(DTYPE_BUTTON);
		bbutn.SetLong(BITMAPBUTTON_ICONID1, Osphere);   //Existing icon ID for testing
		bbutn.SetLong(BITMAPBUTTON_ICONID2, Ocube);     //Existing icon ID for testing
		description->SetParameter(DescLevel(MYPLUGIN_BBUTN, DESC_CUSTOMGUI, 0), bbutn, DescLevel(ID_MYGROUP));  //Shove the new description basecontainer into the resource
	return SUPER::GetDDescription(node, description, flags);

On 29/08/2014 at 10:04, xxxxxxxx wrote:

It might be possible to use SetImage() for this.  But I don't know how to do that.
I do know how to register your icon though.

Generic ObjectData plugin Example:

//This is how to register a custom icon   
//Then use it in the GetDDescription() method to create a dynamically created bitmapbutton with your icon on it  
Bool MyObject::GetDDescription(GeListNode *node, Description *description, DESCFLAGS_DESC &flags)  
  if (!description || !node) return FALSE;   
  //Loads the gui stuff from the .res file in case we want to use them  
  if (!description->LoadDescription(node->GetType())) return FALSE;  
  //We will load the BitmapButton GUI into the first description level(much like loading UD entries into levels)  
  DescID did = DescLevel(1, DTYPE_NONE, 0);  
  BaseContainer settings;  
  settings.SetString(DESC_NAME,"My Button");  
  settings.SetBool(BITMAPBUTTON_BUTTON, TRUE);  
  settings.SetLong(DESC_GUIOPEN, TRUE);  
  settings.SetBool(BITMAPBUTTON_BUTTON,  TRUE);  
  settings.SetBool(BITMAPBUTTON_TOGGLE,  TRUE);  
  settings.SetLong(BITMAPBUTTON_ICONID1, 200000000);  //Uses a custom icon we registered in the register() method  
  settings.SetLong(BITMAPBUTTON_ICONID2, Ocube);      //Uses the cube icon that C4D already registered for us  
  if(!description->SetParameter(did,settings,DescLevel(ID_OBJECTPROPERTIES))) return FALSE;  
  return SUPER::GetDDescription(node, description, flags);  
Bool RegisterMyObject(void)  
  Filename fn = GeGetPluginPath()+"res"+"myicon.tif";  
  AutoAlloc<BaseBitmap> bmp;  
  if(IMAGERESULT_OK != bmp->Init(fn)) return FALSE;  
  //Register our custom icon image with c4d so we can use it like the other icons  
  //NOTE:The ID# 200000000 is for testing purposes only!!...Be sure to get a proper one from    
  RegisterIcon(200000000, bmp, 0*32, 0, 32, 32, ICONFLAG_COPY);                                                           
  return RegisterObjectPlugin(PLUGIN_ID, GeLoadString(IDS_MYOBJECT), OBJECT_GENERATOR|OBJECT_ISSPLINE|OBJECT_CALL_ADDEXECUTION, MyObject::Alloc, "MyObject", AutoBitmap("MyIcon.tif"), 0);  


On 29/08/2014 at 15:08, xxxxxxxx wrote:

Thanks much for that Scott, got it.

The docs say that when using the RegisterIcon() function, if the optional x/y/width/height/copy arent specified that it will use the full bitmap.  What i found was that it didnt work at all unless i specified the bitmap size  - in my case RegisterIcon(2000000000, bmp, 0*128, 0, 128, 64, ICONFLAG_COPY).  Maybe it was just the COPY flag that got it working though, not sure..  What is the 0*32 bit about for the x-position btw?

On 29/08/2014 at 17:31, xxxxxxxx wrote:

Sorry about that. Just ignore it and use 128 (or whatever  size you want) .
When I cut and paste from my notes sometimes I miss little things like that.
I was probably doing dynamic sizing with the code at one point and forgot to change it.