7
$\begingroup$

I'm using a simple script to create and render a scene and when I run the script from command-line as blender --background --python hello.py it prints lots of lines like:

Fra:1 Mem:7.99M (19.13M, Peak 27.65M) | Scene, Part 243-256
Fra:1 Mem:7.99M (19.16M, Peak 27.65M) | Scene, Part 244-256
Fra:1 Mem:7.99M (19.16M, Peak 27.65M) | Scene, Part 245-256
Fra:1 Mem:7.99M (19.16M, Peak 27.65M) | Scene, Part 246-256
Fra:1 Mem:7.99M (19.13M, Peak 27.65M) | Scene, Part 247-256
Fra:1 Mem:7.99M (19.13M, Peak 27.65M) | Scene, Part 248-256
Fra:1 Mem:7.99M (19.16M, Peak 27.65M) | Scene, Part 249-256

Please, does anyone know how to render silently, i.e. not verbose? --verbose 0 didn't help...

$\endgroup$
  • $\begingroup$ No that is the normal rendering output. What OS and how does it interfere with what you want to do? there may be a way to get a result you can work with. $\endgroup$ – sambler Apr 18 '15 at 15:12
  • $\begingroup$ @sambler The script also prints to stdio so it's a bit hard to read (OS X). $\endgroup$ – Ecir Hana Apr 18 '15 at 22:27
6
$\begingroup$

You can redirect stdout to nul:

blender --background --python hello.py 1> nul

In the script use import sys and one of the following to print to stderr:

  • print("blah blah", file = sys.stderr)
  • or sys.stderr.write("blah blah")
  • or sys.stdout = sys.stderr at the start of the script and later print("blah blah")
$\endgroup$
  • $\begingroup$ @EcirHana does this solution work for you ? $\endgroup$ – Chebhou Apr 27 '15 at 17:40
  • $\begingroup$ I can't use sterr instead of sysout. Is there any other option? $\endgroup$ – Madlaina Kalunder Jun 13 '16 at 12:03
  • 1
    $\begingroup$ Awesome, thanks! Is it possible to still have some sort of progress report when calling bpy.ops.render.render(animation = True)? Maybe like a nice status bar or something? I know, i'm spoiled. But that'd be rad! :) $\endgroup$ – NeoTheThird Mar 10 '17 at 17:57
1
$\begingroup$

In addition to @Chebhou's answer above, I also added this to my ~/.bash_profile file:

alias blender='/Applications/Blender/blender.app/Contents/MacOS/blender'
function blender-python() {
    if [ "$1" == "-q" ] || [ "$1" == "--quiet" ] ; then
        blender "$2" --background --python "$3" 1> /dev/null
    else
        blender "$1" --background --python "$2" 1
    fi
}

This way I can call blender-python from the command line and, if I specify -q then it runs silently but if not it prints as usual. (The 1> /dev/null redirects the output of stdout to the /dev/null dump instead of printing.)

Quiet output does require adding sys.stdout = sys.stderr above in the Python script, though.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.