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

    Adding a STATICTEXT element to a Description... changes in C4D 2024?

    Cinema 4D SDK
    2024 c++
    3
    10
    1.4k
    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

      Hi,

      sometimes I need to add a STATICTEXT element to a Description in GetDDescription(). I have this function that I've been using for many years now, and that works fine in R20 - C4D 2023. However, in C4D 2024, calling it does not do anything.

      maxon::Bool AddStaticText(Description* const description, const DescID* const singleId, const DescID& groupid, const maxon::Int32 id = 0, const maxon::String& name = ""_s)
      {
      	if (!description)
      		return false;
      
      	const DescID descId = CreateDescID(DescLevel(id, DTYPE_STATICTEXT, 0));
      	if (MAXON_LIKELY(!singleId || id.IsPartOf(*singleId, nullptr)))
      	{
      		BaseContainer bc = GetCustomDataTypeDefault(DTYPE_STATICTEXT);
      		bc.SetString(DESC_NAME, name);
      		bc.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);
      		bc.SetBool(DESC_REMOVEABLE, false);
      		return description->SetParameter(descId, bc, groupid);
      	}
      	return true;
      }
      

      I call it like this:

      Bool MyObject::GetDDescription(const GeListNode* node, Description* description, DESCFLAGS_DESC& flags) const
      {
      	if (!node || !description)
      		return false;
      
      	if (!description->LoadDescription(node->GetType()))
      		return false;
      	flags |= DESCFLAGS_DESC::LOADED;
      
      	const DescID* const singleid = description->GetSingleDescID();
      	if (!AddStaticText(description, singleid, MYOBJECT_SOMEGROUP))
      		return false;
      
      	return SUPER::GetDDescription(node, description, flags);
      }
      

      Why does this not work anymore in C4D 2024?

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

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

        Ah, I think I found it already.

        In earlier C4D API versions, it was okay to provide an id value of 0. Since C4D 2024, we have to provide a proper value. Calling my AddStaticText() function with an id other than 0 works.

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

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

          Hey @fwilleke80,

          Thank you for reaching out to us. Your code looks fine, so I do not see at a glance what is going wrong. Have you stepped through your code, to check how it behaves; does it go into the MAXON_LIKELY, what is the return value of SetParameter?

          Cheers,
          Ferdinand

          MAXON SDK Specialist
          developers.maxon.net

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

            @fwilleke80 said in Adding a STATICTEXT element to a Description... changes in C4D 2024?:

            Ah, I think I found it already.

            In earlier C4D API versions, it was okay to provide an id value of 0. Since C4D 2024, we have to provide a proper value. Calling my AddStaticText() function with an id other than 0 works.

            Great to hear! Remember, all IDs up to 1000 in the first DescLevel of a DescID are reserved for Cinema 4D. There is a good chance that you overwrite important data, brick a scene, when you write into that range.

            Cheers,
            ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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

              Hi Ferdinand,

              @ferdinand said in Adding a STATICTEXT element to a Description... changes in C4D 2024?:

              Have you stepped through your code, to check how it behaves; does it go into the MAXON_LIKELY, what is the return value of SetParameter?

              Yes, I have. And it does go into the MAXON_LIKELY and SetParameter() does return true.

              @ferdinand said in Adding a STATICTEXT element to a Description... changes in C4D 2024?:

              Remember, all IDs up to 1000 in the first DescLevel of a DescID are reserved for Cinema 4D. There is a good chance that you overwrite important data, brick a scene, when you write into that range.

              Thanks! Yes, I know that. Using IDs far above 1000 🙂

              So, knowing that STATICTEXT IDs of 0 are not working anymore in C4D 2024, here's a question out of curiosity:

              In .res files, it's common practice to use STATICTEXT {} to fill up empty space, e.g. in a layer layout with columns. What ID values does C4D use for STATICTEXT elements like this?

              Cheers,
              Frank

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

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

                @fwilleke80 said in Adding a STATICTEXT element to a Description... changes in C4D 2024?:

                In .res files, it's common practice to use STATICTEXT {} to fill up empty space, e.g. in a layer with columns. What ID values does C4D use for STATICTEXT elements like this?

                Good question, I will ask Pablo, because I have no idea 🙂

                Cheers,
                Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

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

                  @ferdinand said in Adding a STATICTEXT element to a Description... changes in C4D 2024?:

                  Good question, I will ask Pablo

                  Thanks! And say hello to him from me 🙂

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

                  ferdinandF 1 Reply Last reply Reply Quote 1
                  • P
                    pablo
                    last edited by

                    Hello Frank! It's wonderful to hear from you! Warm greetings from Spain!

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

                      Hello @fwilleke80,

                      Pablo found out that such IDs are generated when the description is parsed and elements without an ID get then assigned an ID based on a global variable which is incremented after each usage. You can see its definition below.

                      c90ecf10-0f06-4fe2-8324-06c5dff7bc21-image.png

                      As you can see, the address space starts out at 2^29. So if you somewhat want to emulate that, you could pick IDs starting out at 2^30 (and would be still well below the overflow threshold of (2^32)/2).

                      Cheers,
                      Ferdinand

                      MAXON SDK Specialist
                      developers.maxon.net

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

                        Very informative, thank you Ferdinand!

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

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