save_as_mainfile loses mesh datablock when issued in a pre-render event #32734

Closed
opened 2012-10-02 19:10:26 +02:00 by Atomic · 4 comments

%%%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.%%%

%%%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.%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%Fix in svn, thanks for the report.%%%

%%%Fix in svn, thanks for the report.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Added subscriber: @JonasEschenburg

Added subscriber: @JonasEschenburg
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#32734
No description provided.