Adding a STATICTEXT element to a Description... changes in C4D 2024?
-
Hi,
sometimes I need to add a STATICTEXT element to a
Description
inGetDDescription()
. 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?
-
Ah, I think I found it already.
In earlier C4D API versions, it was okay to provide an
id
value of0
. Since C4D 2024, we have to provide a proper value. Calling myAddStaticText()
function with anid
other than0
works. -
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 ofSetParameter
?Cheers,
Ferdinand -
@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 of0
. Since C4D 2024, we have to provide a proper value. Calling myAddStaticText()
function with anid
other than0
works.Great to hear! Remember, all IDs up to
1000
in the firstDescLevel
of aDescID
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 -
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
andSetParameter()
does returntrue
.@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 of0
are not working anymore in C4D 2024, here's a question out of curiosity:In
.res
files, it's common practice to useSTATICTEXT {}
to fill up empty space, e.g. in alayerlayout with columns. What ID values does C4D use forSTATICTEXT
elements like this?Cheers,
Frank -
@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 -
@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
-
Hello Frank! It's wonderful to hear from you! Warm greetings from Spain!
-
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.
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 -
Very informative, thank you Ferdinand!