Regular API function

simWriteCustomDataBlock / sim.writeCustomDataBlock

Description Adds or removes custom data to be stored and saved together with an object, or the scene. If the tag name starts with the string "@tmp", then the data will not be saved during a scene or model save operation. The data can also be saved globally for the application (for the current CoppeliaSim session). See also sim.readCustomDataBlock and the data packing/unpacking functions. If you wish to store a reference to another object, have a look at sim.setReferencedHandles.
C synopsis simInt simWriteCustomDataBlock(simInt objectHandle,const simChar* tagName,const simChar* data,simInt dataSize)
C parameters
objectHandle: handle of the object where you want to store your data, or sim_handle_scene if you wish to store the data with the scene, or sim_handle_app if you wish to store the data with the application's current session.
tagName: a string that identifies the data. An empty string will remove all custom data blocks.
data: your custom data. If nullptr, the current data under the specified dataName will be removed.
dataSize: the size of your custom data

The data will be copied to an internal buffer inside of the object or scene, and next time a scene or model is saved, will also be saved. The data buffer can be released after this call.
C return value
-1 if operation was not successful
Lua synopsis sim.writeCustomDataBlock(int objectHandle,string tagName,string data)
Lua parameters
Similar to the C-function counterpart.
Lua return values