On 27/08/2013 at 10:15, xxxxxxxx wrote:
I'll make you a deal Rick.
I'll show you how to add a registered image to your bitmap button. If you show me how to check when that button is pressed.
OK?
.pyp
#This is an example of how to add an image to a bitmap button for an object plugin using a custom registered icon
#The image should be located in the plugin's res folder
import c4d,os
import c4d.plugins as plugins
from c4d import plugins, utils, bitmaps, gui,documents
class CubeGenerator(plugins.ObjectData) :
cache = None
def Init(self, op) :
return True
def GetVirtualObjects(self, op, hh) :
if not self.cache:
self.cache = c4d.BaseObject(c4d.Ocube)
return self.cache
def Message(self, node, type, data) :
#How the frack do you check if the Bitmap Button was pressed!? >:-<
return True
@ classmethod
def Register(cls) :
BITMAP_ID = 100000 #Be sure to get a unique ID from PluginCafe.com!
buttonimage = bitmaps.BaseBitmap() #We need an instance of BaseBitmap class to use an image
path, fn = os.path.split(__file__)
buttonimage.InitWith(os.path.join(path, "res", "buttonimage.jpg"))#The location where the button image exists
gui.RegisterIcon(BITMAP_ID, buttonimage) #We need to register custom images & icons
plugins.RegisterObjectPlugin( **{
'id': 1000009, #TESTING ID ONLY!!!!!
'str': 'Generator example',
'description': 'Ocubegen',
'info': c4d.OBJECT_GENERATOR,
'icon': buttonimage, #Puts the image in the menu entry
'g': cls,
} )
CubeGenerator.Register()
.res
CONTAINER Ocubegen
{
NAME Ocubegen;
INCLUDE Obase;
GROUP ID_OBJECTPROPERTIES
{
BITMAPBUTTON MY_BITMAP { BORDER; ICONID1 100000; }
BOOL MY_CHECKBOX{}
}
}
.h
#ifndef _OCUBEGEN_H_
#define _OCUBEGEN_H_
enum {
Ocubegen = 10000,
MY_BITMAP,
MY_CHECKBOX
};
#endif
.str
STRINGTABLE Ocubegen
{
Ocubegen "Cube Generator";
MY_BITMAP "Bitmap Button";
MY_CHECKBOX "Enabled";
}
-ScottA