BitmapButton in Desc causes Message AttributeError



  • On 26/08/2013 at 16:34, xxxxxxxx wrote:

    I want to include a BitmapButton in my Object plugin description. Because DescriptionGetBitmap is not implemented in Python, I've used the RegisterIcon method as described in other posts here.

    But I still get errors in the console like "AttributeError: Parameter value not accessible (object unknown in Python)" whenever I override NodeData:Message - even if I just override it and immediately return True.

    Is there any way to get around this, or do I have to choose between eliminating the BitmapButton or writing a bunch of junk into the console?



  • On 27/08/2013 at 00:12, xxxxxxxx wrote:

    I am not sure if this is related, but BaseContainers return that exception when you do try
    to access a DTYPE_BUTTON or DTPYE_FILENAME DescLevel. I did stumble over that while 
    trying to iterating over BaseShader containers. I cannot offer a solution except for stepping 
    over these problematic ids, but my point is - the problem could be quite fundamental.



  • 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



  • On 27/08/2013 at 11:40, xxxxxxxx wrote:

    Thanks Scott - I got that far - but do you not get an AttributeError each time the overridden Message method is called?

    That's my problem - presumably because DescGetBitmap isn't implemented. Wondering if there's a way around that.

    I hadn't even got so far as detecting clicks.



  • On 27/08/2013 at 11:53, xxxxxxxx wrote:

    No. I get no errors with the code I posted.
    I'm using R13 BTW. Not sure if that makes any difference or not.

    -ScottA

    Edit- I noticed that if I add the GetDEnabling() method to my plugin I get that error Rick.
    Not sure why. But that method seems to clash with using a bitmap button for some reason.



  • On 27/08/2013 at 15:59, xxxxxxxx wrote:

    Ah - thanks. For some reason it wasn't happening when I removed Message but it also isn't happening if I leave Message and remove GetDEnabling. Hmm.

    So here's my part of the deal:

      
        def Init(self, op) :   
            self.InitAttr(host=op, type=bool, id=[c4d.MY_BITMAP])   
            return True       
      
        def Message(self, node, type, data) :   
           
            if type == c4d.MSG_DESCRIPTION_COMMAND:   
                if data['id'][0].id == c4d.MY_BITMAP:   
                   print "BUTTON PRESSED"   
              
            return True   
    


  • On 27/08/2013 at 16:39, xxxxxxxx wrote:

    Hmmm. Strange.
    Are you really getting a return from that Message() code?
    I found the same code snippet in the python docs. But it does not work in my plugin.
    That code only works for a standard button for me...Not on a bitmap button.

    If it's working for you. I'm wondering if it's because I'm using R13?

    -ScottA



  • On 28/08/2013 at 14:28, xxxxxxxx wrote:

    Just checked - it's not working in R13, but it does work in R14 and up.



  • On 28/08/2013 at 15:20, xxxxxxxx wrote:

    OK.
    Thanks for checking on it Rick.

    -ScottA


Log in to reply