Page MenuHome

save_as_mainfile loses mesh datablock when issued in a pre-render event
Closed, ResolvedPublic


Hi All,

Using Windows XP64 Blender 26.4 RC2 r50890 64bit.

I am working on a way to use the blenderplayer as an alternate render engine.
The blendplayer only reads BLEND file.
The only way to make a BLEND file is with Blender.

The blendplayer will not render an extruded font objects but it will render mesh objects so I wrote a convert script.
Font->Mesh and placed it in the pre_render event.

When a Render is issued via F12 the code converts a Font object to a Mesh object.
A new object is then created as a type mesh with the new mesh datablock, and linked to the scene.
The old Font object is unlinked from the scene.
So I have swapped one object for another in a pre_render event.
At this point my scene is exactly as I want it, my Font object is a mesh object that the blenderplayer will be able to display for screenshot rendering.
I issue a bpy.ops.wm.save_as_mainfile(filepath=render_filename, check_existing=False, copy=True) with render_filename being a valid file name.
The new BLEND file appears on the disk at the location.
But when I open the new BLEND file instead of the expected mesh object I see an Empty. There is a data lost message in the console after the scene loads.

It seems to me that the save_as_main file detected my new object creation, but not the mesh datablock. Because it lost the data it created an Empty.

Kind of weird.

I have setup the above described workflow as a self registering script in the attached BLEND file.
Open the BLEND file and press F12.
Look in the console.
Open the resulting file to see the Empty instead of the mesh.

Also, when you press F12 observe the outliner and you will see that, for a moment, the Font object is converted to a Mesh object icon.

Event Timeline

Atomic (atomic) edited a custom field.Oct 2 2012, 7:10 PM

Fix in svn, thanks for the report.

Brecht Van Lommel (brecht) changed the task status from Unknown Status to Resolved.Oct 5 2012, 2:18 PM