c# process that runs a batch file for blender exporting gets paused/stalled
I hope someone can help me with this problem.
Situation:
I need to export an animation from blender as a sequence it has to be tigger inside of unity as an editor tool. I'm using blenders obj exporter with a python script that's pretty much the same as the example in this blender wiki: https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Wavefront_OBJ
This is the python script i wrote:
import bpy import sys
argv = sys.argv argv = argv[argv.index("--") + 1:] # get all args after "--"
obj_out = argv[0]
bpy.ops.export_scene.obj(filepath=obj_out, axis_forward='-Z', axis_up='Y', use_animation=1, keep_vertex_order=1, use_normals=1, use_materials=0)
in addition to that i wrote the following batch file:
"C:\Program Files\Blender Foundation\Blender\blender.exe" "C:\Users\holgk\Documents\Some Folders\Test.blend" --background --python "C:\Program Files\Blender Foundation\Blender\convert_blend_to_obj.py" -- "C:\Users\holgk\Documents\Some Folders\Test.obj"
My c# code looks like this:
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c \"" + @"C:\blender_export_to_obj.bat" + "\"");
processInfo.CreateNoWindow = false;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit();
When i'm using the window cmd shell everything works as it should. For every frame an obj file is created. But when i'm using my c# app the cmd line is open, blender starts to execute and for the first frames about 12 of 250 everything works as it should and then nothing happens and the app is still waiting for the exit but no new obj files are created.
Before i wrote the batch file i tried to run blender with that python script directly as a process and i had the same problem it started but was "pausing"/"stalling" after a few frames of exporting. I also tested it has a normal c# app and run into the same problem.
I'm guessing that it has to do with my c# process code (because running in the cmd shell does work) but i don't know what i'm doing wrong.