Solved Colorize plugin object icon


I'm searching how can I dynamically colorize plugin icon like as the default C4D lights objects. I want to dynamically apply a color tint filter on my plugin object icon.

def Message(self, node, type, data):
      if type == c4d.MSG_GETCUSTOMICON:
          color = node[c4d.MYOBJECT_COLOR]:
          icon = c4d.bitmaps.InitResourceBitmap(PLUGIN_ID)

          """width = icon.GetBw()
          height = icon.GetBh()
          for y in xrange(height) :
            for x in xrange(width) :
                r,g,b = icon.GetPixel(x, y)
                #icon.SetPixel(x, y, r, g, b)"""
          data['bmp'] = icon
          data["w"] = icon.GetBw()
          data["h"] = icon.GetBh()

          data['filled'] = True


Hi there is an example in Github - Plugins - Custom Icon.


Thank you @m_adam, is there examples for previous cinema 4d versions (r19, r20)?

This functionality only exists since R21, for the previous versions, there is this hack that is very not recommended Plugins in plugin OR icons!!!!!.