4
$\begingroup$

Can we know, with python, if the system console of blender is open? I know that we can open or close it with this function:

bpy.ops.wm.console_toggle()

But it doesn't return the 'state' of the system console like open or closed (True,False).

I want to be sure that the console is open when i execute one of my script.

$\endgroup$
  • $\begingroup$ I see there is a toggle() command but what about explicitly open() or close()?. If you have those you should be able to do a Boolean evaluation. what parameter can you pass to toggle? $\endgroup$ – user320 Oct 3 '13 at 15:16
  • $\begingroup$ This function doesn't accept any parameters and return just a {'FINISHED'}. It just open the console if it's close and vice versa. $\endgroup$ – lucblender Oct 3 '13 at 17:02
2
$\begingroup$

Short Answer: You cannot

First, bpy.ops.wm.console_toggle() is available only on Windows. And I admit, it is a work around. Other OSs run without a console. If you want a console, you must start blender from a terminal on Linux and Mac.

The I/O steam redirect blender.exe > out.txt should work. (but I haven't test it)

If you realy want to communicate with user, you should use a dialog box: http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Interface

error message or save it in a log file. Those methods should work on any system.

P.S.

On C code side, the function returns the current status, and you can query the status.

$\endgroup$
  • 3
    $\begingroup$ I can confirm streaming blender in linux works. $\endgroup$ – Kirbinator Oct 4 '13 at 20:30

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.