Hey @a_block,
Thank you for reaching out to us. This is the section of code that throws your error:

This code at this location is unique to 2023.2
in prior versions that code was at a substantially different line number in the same file, and in the current beta build the file btree_container.cpp
does not exist anymore, and the function containing this code has moved to another file and shrunken from 129 lines of code to 14 (sic!) lines of code. I.e., things are in motion here.
The method is concerned with copying data between two data containers. The error is being raised when two GeData
which shall be copied carry the same pointer value DContainer
.
Without your concrete code, I cannot do much more than guess what is going wrong there for you. I also gave the function SetWorldPluginData
and its reading counterpart GetWorldPluginData
a spin, without having any problems. See end of the posting for my code.
Cheers,
Ferdinand
Result for running the script four times in a row in a Cinema 4D installation where the script has never run before. I ran the code successfully both with:
- 2023.2.0 (Build 2023.CL399467.56383) Win
- 2023.2.1 (Build 2023.CL401745.844493561) Win
----------------------------------------------------------------------------------------------------
key = 1000, value = 42
key = 1001, value = 3.1415
key = 1002, value = <c4d.SplineData object at 0x000002575F960A40>
key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu('
----------------------------------------------------------------------------------------------------
key = 1000, value = 42
key = 1001, value = 3.1415
key = 1002, value = <c4d.SplineData object at 0x000002575F944740>
key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu('
key = 1292, value = "K`'2%0[oIjWgg^^trE{j"
----------------------------------------------------------------------------------------------------
key = 1000, value = 42
key = 1001, value = 3.1415
key = 1002, value = <c4d.SplineData object at 0x000002575F94A940>
key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu('
key = 1292, value = "K`'2%0[oIjWgg^^trE{j"
key = 1850, value = 'l7#z*a=%nAyaNJH2aCoQ'
----------------------------------------------------------------------------------------------------
key = 1000, value = 42
key = 1001, value = 3.1415
key = 1002, value = <c4d.SplineData object at 0x000002575F947540>
key = 1413, value = '.Djlq;_u;v<-\\T:5+Uu('
key = 1292, value = "K`'2%0[oIjWgg^^trE{j"
key = 1850, value = 'l7#z*a=%nAyaNJH2aCoQ'
key = 1041, value = 'ZESmFH}bp-KQo3jth)*A'
Code:
"""Demonstrates the usage of #GetWorldPluginData and #SetWorldPluginData to read and write data
persistently from/into the application data container.
Run this script multiple times in a row in the script manager to see data accumulate under the
ID ID_PLUGIN_SETPLUGINDATA.
"""
import c4d
import random
doc: c4d.documents.BaseDocument
op: c4d.BaseObject | None
# It is obviously important that you store data under a unique plugin ID.
ID_PLUGIN_SETPLUGINDATA: int = 1061159
def main() -> None:
"""Writes and reads data under the ID #ID_PLUGIN_SETPLUGINDATA into the application data
container.
"""
data: c4d.BaseContainer = c4d.BaseContainer(ID_PLUGIN_SETPLUGINDATA)
# Write data with both the __setitem__ Python interface and the native C++ methods.
data[1000] = 42
data.SetFloat(1001, 3.1415)
# Since the bug seems to be related to GeData, write custom data type data. If I had to guess,
# your problem likely is stemming from something like this. Maybe you are trying to write the
# same custom data type instance twice or something like that, which results then in the failed
# pointer comparison? You could try using a copy constructor then to copy data.
spline: c4d.SplineData = c4d.SplineData()
spline.MakeSinSpline(36)
data.SetData(1002, spline)
# Write data at a random location so that we can test the container merging.
data[random.randint(1003, 2000)] = "".join((chr (random.randint(33, 126)) for _ in range(20)))
# Write the data, the last argument #add sounds a bit like it could be the triggering factor,
# as it determines if #data is merged with the container at #ID_PLUGIN_SETPLUGINDATA or
# overwrites it. But both #True and #False work fine for me.
if not c4d.plugins.SetWorldPluginData(ID_PLUGIN_SETPLUGINDATA, data, add=True):
raise RuntimeError(f"Could not store plugin data under id: {ID_PLUGIN_SETPLUGINDATA}.")
# Read the data back.
_data: c4d.BaseContainer = c4d.plugins.GetWorldPluginData(ID_PLUGIN_SETPLUGINDATA)
if not _data:
raise RuntimeError(f"Could not read plugin data under id: {ID_PLUGIN_SETPLUGINDATA}.")
print("\n", "-" * 100)
for key, value in _data:
print(f"{key = }, {value = }")
if __name__ == '__main__':
main()