Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Register
    • Login

    MSG_GETCUSTOMICON: Bitmap in IconData always empty

    Cinema 4D SDK
    s22 c++ classic api
    3
    5
    710
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • fwilleke80F
      fwilleke80
      last edited by fwilleke80

      Hello,

      I want to change the icon of my plugin object, depending on settings in the BaseContainer. It should be the normal icon of the object, with a little overlay in the corner. Sounds easy, and 'm sure I have done this years ago. But now, I can't get it to work.

      The icon is set up with RegisterIcon during the register call. This works fine, the object does have the correct icon in the object manager.

      Bool RegisterMyObject()
      {
      	extern BaseBitmap * g_myIcons;
      	if (!RegisterIcon(ID_MYOBJECT, g_myIcons, 64, 0, 64, 64))
      		return false;
      	
      	maxon::String name = GeLoadString(IDS_MYOBJECT);
      	return RegisterObjectPlugin(ID_MYOBJECT, name, OBJECT_GENERATOR, MyObject::Alloc, "omyobject", AutoBitmap(ID_MYOBJECT), 0);
      }
      

      Now I want to change the icon, so in MyObject::Message(), I do:

      Bool MyObject::Message(GeListNode *node, Int32 type, void *data)
      {
      	switch (type)
      	{
      		case MSG_GETCUSTOMICON:
      		{
      			GetCustomIconData* const cid = static_cast<GetCustomIconData*>(data);
      			if (!cid)
      				return false;
      
      			// Let's see if the icon bitmap is there
      			BaseBitmap *iconBmp = cid->dat->bmp;
      			BaseBitmap *iconBmp2 = cid->dat->GetClonePart();
      
      			// What are the set flags?
      			ICONDATAFLAGS  iconDataFlags = cid->dat->flags;
      
      			break;
      		}
      	}
      
      	return SUPER::Message(node, type, data);
      }
      

      Strangely, iconBmpas well as iconBmp2 are correctly allocated, but are 0x0 pixels in size, and contain only black.
      iconDataFlags is ICONDATAFLAGS::NONE.

      Is that normal? I would have expected the bitmap to contain the icon of the object.

      I also tried, just for a test, to simply write into the bitmap by copying an existing icon of another object (that icon was also registered with RegisterIcon()😞

      	BaseBitmap *originalIcon = AutoBitmap(ID_SOMEOTHEROBJECT);
      	originalIcon->CopyTo(cid->dat->bmp);
      	cid->filled = true;
      

      But that simply makes my object's icon vanish, and now the object has no icon.

      Also interesting, if I try to show any of the bitmaps (cid->dat->bmp, or cid->dat->GetClonePart(), or originalIcon) in the Picture Viewer with ShowBitmap(), I always get a 0x0 pixel black bitmap. Why is it empty? And why doesn't even the originalIcon work?

      Thanks for tips & advice!

      Cheers,
      Frank

      www.frankwilleke.de
      Only asking personal code questions here.

      1 Reply Last reply Reply Quote 0
      • P
        PluginStudent
        last edited by

        According to the documentation, you can use GetIcon().

        See NodeData::Message() Manual.

        1 Reply Last reply Reply Quote 0
        • fwilleke80F
          fwilleke80
          last edited by

          Hi,

          thanks, I'll try that, too.

          Still, I really wonder why using AutoBitmap(ID_MYOBJECT) works when passing an icon the RegisterObjectPlugin(), but when I display the bitmap (or any bitmap from the IconData) in the Picture Viewer, it's 0 pixels in size.

          Cheers,
          Frank

          www.frankwilleke.de
          Only asking personal code questions here.

          1 Reply Last reply Reply Quote 0
          • fwilleke80F
            fwilleke80
            last edited by

            Ah, GetIcon() seems to do something. I'll go with that!
            Thanks!

            www.frankwilleke.de
            Only asking personal code questions here.

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by

              Hi Frank, sorry for coming late to the party, the API changed within the R21 where by default the icon is not more filled because it's up to you to fill it with what you need.

              Just in case for other people, not interested in C++ (since the manual is pretty obvious) there is a Python example in

              Where you can have custom icons, you can find an example of how to achieve custom icon within Python in py-custom_icon_r21.pyp.

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • First post
                Last post