Hi Kent, thanks for reaching out us.
With regard to your issue, at the moment writing/reading a VolumeObject using the C4DAtom::WriteObject / C4DAtom::ReadObject using an Hyperfile is not supported if the HyperFile object operates on disk.
At the moment a workaround is represented by using a temporary memory file, write into that, write that to disk. To read/write using MemoryFileStruct please visit here.
The following code shows how to read/write VolumeObject from/to memory-located HF.
iferr_scope;
// alloc the VolumeObject to write
AutoAlloc<VolumeObject> volObjWrite;
if (!volObjWrite)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// put some data in the VolumeObject
const maxon::Int gridIndex = 0;
const maxon::Url volumeUrl ("<your path to a vdb>"_s);
const maxon::Volume volume = maxon::VolumeInterface::CreateFromFile(volumeUrl, 1.0, gridIndex) iferr_return;
// insert volume
volObjWrite->SetVolume(volume);
// alloc HF
AutoAlloc<HyperFile> hf;
if (!hf)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// alloc MemoryFileStruct
AutoAlloc<MemoryFileStruct> mfs;
if (!mfs)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// alloc Filename and set to memory
Filename fn;
fn.SetMemoryWriteMode(mfs);
// open HyperFile to write
if (!hf->Open(0, fn, FILEOPEN::WRITE, FILEDIALOG::NONE))
return maxon::UnknownError(MAXON_SOURCE_LOCATION);
// write volume to memory HF
Bool writeRes = volObjWrite->WriteObject(hf);
if (writeRes)
DiagnosticOutput("volume written on HF");
// close written HF
hf->Close();
//... write memory-located HF to disk
//... do your stuff
//...read from disk the memory-located HF
// open HF to read
if (!hf->Open(0, fn, FILEOPEN::READ, FILEDIALOG::NONE))
return maxon::UnknownError(MAXON_SOURCE_LOCATION);
// alloc the VolumeObject to read
AutoAlloc<VolumeObject> volObjRead;
if (!volObjRead)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
// read volume from memory HF
Bool readRes = volObjRead->ReadObject(hf, true);
const maxon::VolumeInterface* volRead = volObjRead->GetVolume();
if (readRes && volRead)
DiagnosticOutput("volume read from HF");
hf->Close();
return maxon::OK;
Best, Riccardo