hello,
1 - what kind of strange name ?
2 -
you can store the data itself in the tag and than with the function read and write store them in the Scenefine
I'm using a file on the disk on this example but that should work with the HyperFile link provide by the read and write functions.
Be aware that HyperFile.WriteMemory is storing byte sequences that will be platform dependent.
import c4d
from c4d import gui
# Welcome to the world of Python
import os
# Main function
def main():
path = c4d.storage.LoadDialog(c4d.FILESELECTTYPE_SCENES, flags=c4d.FILESELECT_DIRECTORY)
path = os.path.join(path, "prout.txt")
# using a MemoryFileStructure to store a document
mfs = c4d.storage.MemoryFileStruct()
mfs.SetMemoryWriteMode()
newdoc = c4d.documents.IsolateObjects(doc , [op])
# Save the document to the MemoryFileStructure
c4d.documents.SaveDocument(newdoc, mfs, c4d.SAVEDOCUMENTFLAGS_NONE, c4d.FORMAT_C4DEXPORT)
#Retrieve the data and store it somewhere, could be self.myData
myData = mfs.GetData()
#Save the data to a hyperfile
myFile = c4d.storage.HyperFile()
if not myFile.Open(0, path, c4d.FILEOPEN_WRITE, c4d.FILEDIALOG_NONE):
raise RuntimeError("Failed to open the HyperFile in write mode.")
# Store the size
myFile.WriteInt32(myData[1])
# Store the data itself
if myFile.WriteMemory(myData[0]) is False:
raise ValueError("can't write the file")
myFile.Close()
# Read the data from the HF
if not myFile.Open(0, path, c4d.FILEOPEN_READ, c4d.FILEDIALOG_NONE):
raise RuntimeError("Failed to open the HyperFile in read mode.")
size = myFile.ReadInt32()
data = myFile.ReadMemory()
myFile.Close()
#Set the MFS
mfs2 = c4d.storage.MemoryFileStruct()
mfs2.SetMemoryReadMode(data,size)
c4d.documents.MergeDocument(doc, mfs2, c4d.SCENEFILTER_OBJECTS)
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()
Once again, be aware of where you are modifying the scene (on main thread and not elsewhere)
by the way, are you going to use c++ or python at the end ? (just for the tags of this thread)
Cheers,
Manuel