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
    • Login

    Dynamic desription issue

    Cinema 4D SDK
    c++
    2
    4
    193
    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.
    • WickedPW
      WickedP
      last edited by ferdinand

      Hi Folks,

      I've stumped myself. I have a dynamic GetDDescription in an object plugin, which adds some customgui descriptions (customguidata is a BaseContainer, my own registered one). The display works fine and the data is saved/loaded etc with the object.

      I want to remove one of the containers, but bc->RemoveData(id) returns false (as does bc->RemoveIndex(index)). Are we not able to remove data from the underlying container?

      Sudo code:

      BaseNode *node = Get();
      BaseObject *op........
      BaseContainer *bc = op->GetDataInstance();
      if(bc->GetContainerInstance(id) != nullptr)    <-- passes
      {
          bc->RemoveData(id);    <-- returns false
          /* Check container again */
          if(bc->GetContainerInstance(id) != nullptr)    <-- fails
      }
      // The customgui is removed from the AM.
      // Add new item, container reappears along with new one.
      

      Apologies for the lack of code - but it's pretty much as is above. Can someone open my eyes on this?

      Cheers,

      WP.

      wickedp.com

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @WickedP
        last edited by ferdinand

        Hey @WickedP,

        Thank you for reaching out to us. I am a bit confused as to what you are trying to accomplish here. I assume you are inside of NodeData::GetDDescription. You then get the node and try to delete a value from the node representing this NodeData instance. Which Cinema 4D, not very surprisingly, does not allow you to do. Because what you are doing is not any different than this:

        import c4d
        
        data: c4d.BaseContainer = op.GetDataInstance()
        print(data.RemoveData(c4d.ID_BASELIST_NAME)) # A string
        print(data.RemoveData(c4d.ID_USERDATA)) # A container as in your case.
        
        data[100000] = "Bob is your uncle"
        print(data[100000])
        print(data.RemoveData(100000))
        
        False
        False
        Bob is your uncle
        True
        

        You cannot just modify the instance of a data container of a node as you want, as this could cause the container to go out of sync with its description. You can write to existing entries, you can create and delete new entries not reflected in the description, but Cinema 4D won't let you delete data that is still needed.

        When you have a dynamic description, Cinema 4D should do the housekeeping for you when you remove parameters. When you want to reinit a dynamic parameter under the same ID, you can simply overwrite the value.

        Cheers,
        Ferdinand

        PS: I am aware that this is about C++, but Python is quicker and also conveys the issue.

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • WickedPW
          WickedP
          last edited by

          Thanks Ferdinand, I thought it was something like that, but wasn't completely sure. Seems I should keep a count perhaps and just override any previously existing one with a default container again.

          Cheers,

          WP.

          wickedp.com

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @WickedP
            last edited by

            You do not have to do that; I only recommended this for the case when you happen to have to override a dynamic parameter of the same ID with a new GUI/datatype, then you should also set a new default value. But as I said and as you can see here at the Python dynamic description example (in C++ we have a similar one), Cinema 4D will do the bookkeeping for you. Here we read the value of Dynamic REAL 6 at 1106.

            4361ae57-21f3-47d2-87e4-84709bf6f809-image.png

            Once we have modified the description, in this case removed Dynamic REAL 6, Cinema 4D will update the data container for us and remove the data at 1106.

            2712461d-c0c7-4280-96f5-ca9be93dfd8b-image.png

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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