Dynamic desription issue
-
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.
-
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 thisNodeData
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,
FerdinandPS: I am aware that this is about C++, but Python is quicker and also conveys the issue.
-
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.
-
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
.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
.Cheers,
Ferdinand