def to_bytes(self): """Serialize the model to a string of bytes.""" bufsize = mjlib.mj_sizeModel(self.ptr) buf = ctypes.create_string_buffer(bufsize) mjlib.mj_saveModel(self.ptr, None, buf, bufsize) return buf.raw
def save_binary(self, binary_path): """Saves the MjModel instance to a binary file.""" mjlib.mj_saveModel(self.ptr, util.to_binary_string(binary_path), None, 0)