11
$\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$
2
  • $\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, 2015 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, 2015 at 22:27

3 Answers 3

10
$\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$
3
  • $\begingroup$ @EcirHana does this solution work for you ? $\endgroup$
    – Chebhou
    Apr 27, 2015 at 17:40
  • $\begingroup$ I can't use sterr instead of sysout. Is there any other option? $\endgroup$ Jun 13, 2016 at 12:03
  • 2
    $\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$ Mar 10, 2017 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$
1
$\begingroup$

If you need to print your lines on blender but not the blenders so much of outputs, you can use add your-command |grep "#".

"#" is a keyword You can use you own keyword for this that you can add at the beginning of statements you want to be printed.

$\endgroup$
3
  • $\begingroup$ But this prints only after full execution of the script. Is there a way to print while the script is being executed? $\endgroup$ Apr 16, 2023 at 12:26
  • $\begingroup$ I beleive the linux piping | works on the go. as soon as the output from the previous command is available, it will be fed to the next as input, that is grep here in our case $\endgroup$ Apr 17, 2023 at 13:11
  • $\begingroup$ atleast the grep piping is not working on the go. Does it for you? $\endgroup$ Apr 18, 2023 at 5:31

You must log in to answer this question.

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