On 20/10/2016 at 09:39, xxxxxxxx wrote:
I still can not figure out how to use C4DAtom.Read(). It appaers that writing the node is easy, but how
do your read it back in? The snippet below doesn't work. Although the Read() method returns True, the
material doesn't reflect the same properties as the one that I wrote (ie. I changed the name and added
a shader to the color channel).
import c4d mat = doc.GetActiveMaterial() # Write the material into the MemoryFileStruct mem = c4d.storage.MemoryFileStruct() mem.SetMemoryWriteMode() hf = c4d.storage.HyperFile() hf.Open(0, mem, c4d.FILEOPEN_WRITE, c4d.FILEDIALOG_NONE) mat.Write(hf) # Read the material from the MemoryFileStruct. data, size = mem.GetData() mem = c4d.storage.MemoryFileStruct() mem.SetMemoryReadMode(data, size) hf = c4d.storage.HyperFile() hf.Open(0, mem, c4d.FILEOPEN_READ, c4d.FILEDIALOG_NONE) mat = c4d.BaseMaterial(c4d.Mmaterial) result = mat.Read(hf, c4d.Mmaterial, 0) # << What to do here? print(result) print(mat) print(mat.GetFirstShader())
Any help would be very much appreciated.