Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Login

    Vertex Color Tag disappearing when made editable

    Cinema 4D SDK
    2024 c++
    2
    3
    679
    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.
    • D
      d_schmidt
      last edited by

      Hello, I was using a Vertex Color Tag and I noticed that is was disappearing when I made the object it was on editable. I did a bit of testing and it seems like it disappears when it's on a plugin object and not a Cinema object.

      For example, on the "C++ SDK - Plane By Polygons Generator Example" the Vertex Color Tag will vanish, but when on a Cube it stays as it should.

      Before making editable:
      Screenshot 2023-12-20 at 4.18.50 PM.png
      After making editable:
      Screenshot 2023-12-20 at 4.18.59 PM.png

      "C++ SDK - Plane By Polygons Generator Example"'s Vertex Color Tag is gone in the second case.

      The same behavior is happening with my plugin, but the SDK example seems like the clearer case. Any ideas on why this behavior would be happening?

      Dan

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @d_schmidt
        last edited by i_mazlov

        Hi Dan,

        The Make Editable command retrieves the cache of your object via GetVirtualObjects() function, which returns just an ordinary BaseObject*. Hence, it is up to plugin to decide what tags should be added to the returned cache object.

        In case of Plane By Polygons Generator example there's no such a line of code that creates any tags on the returned cache object, hence none of your tags on this object will survive after Make Editable command.

        If you want to keep them, you need to manually copy them over to your returned BaseObject*. This is usually done using CopyTagsTo() function, something that looks like the following:

        BaseObject* MyGenerator::GetVirtualObjects(BaseObject* op, const HierarchyHelp* hh)
        {
            // ... some code
            BaseObject* ret = BaseObject::Alloc(Onull); // or likely Opolygon
            if (!op->CopyTagsTo(ret, true, NOTOK, false, nullptr))
                return BaseObject::Alloc(Onull);
            // ... some code
            return ret;
        }
        

        Note, that here nullptr is used for alias translator for simplicity. Normally, you need to use AliasTrans that would handle tag's dependencies for you.

        You can check the GetVirtualObjects() implementation in the Rounded Tube example. Please note, that in this example the CopyTagsTo() function uses false for the 3rd 'variable' argument, which means that variable tags will not be copied over. If you want to make it work with the Vertex Color tag, you need to use either true or NOTOK, depending if you want to copy over all tags or only variable ones.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 2
        • D
          d_schmidt
          last edited by

          Thanks Ilia! That was exactly what I needed!

          Dan

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