6
$\begingroup$

I thought that the following code (which I found here) would save all the terminal output from the function bpy.ops.render.render() into the variable output:

import bpy, sys, io

old_stdout = sys.stdout
render_output = io.StringIO()
sys.stdout = render_output
bpy.ops.render.render( write_still=True )
sys.stdout = old_stdout

But I still get output to the terminal (Saved: /tmp/a.png Time: 00:00.99 (Saving: 00:00.01)) and render_output.getvalue() returns an empty string. Why is that?

I also tested this method with bpy.ops.mesh.remove_doubles() and it successfully redirects the output.

$\endgroup$
1
  • $\begingroup$ Were you able to solve the issue? I am facing it also. Could you share? $\endgroup$
    – Noname
    Sep 19 at 11:38

1 Answer 1

3
$\begingroup$

It might have worked, if the bpy.ops.render.render() operator was outputting that information through Python. However, since that code is written in C (blender\source\blender\editors\render\render_internal.c), it doesn't care that you've reassigned sys.out in Python.

$\endgroup$
1
  • $\begingroup$ Could you please let me know if there is any solution to the problem? $\endgroup$
    – Noname
    Sep 19 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .