4
$\begingroup$

I would like to run simple python such as

x=5 print(x)

Which is running in the console but where does the code in the text editor output to? Where do *I go If I placed this in the text editor do I go to file>save or text>save? I am having problems saving script in the text editor.

Thanks UPDATE I don't seem to have Window->Toggle System Console system enter image description here

The python console window look like this but doesn't seem to have Toggle System Console enter image description here and also in the python console window enter image description here I presume this is the python console window enter image description here Simple python code enter image description here

But not outputting in the Python console window.

$\endgroup$
0

2 Answers 2

4
$\begingroup$

Text->Save will save the script you were coding in the text editor in the Scripting workspace.

And if you're looking for the output of a print statement with code you ran in the text editor, go to Window->Toggle System Console. The output is there.

$\endgroup$
1
  • $\begingroup$ I don't seem to have Window->Toggle System Console I've updated the question . Thanks $\endgroup$
    – ofey
    Dec 31, 2021 at 21:51
2
$\begingroup$

What happens to the output:

If you enter the code into the Python console window, the output will appear in the console window:

PYTHON INTERACTIVE CONSOLE 3.9.2 (default, Mar  1 2021, 08:18:55) [MSC v.1916 64 bit (AMD64)]

Builtin Modules:       bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports:   from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data

>>> print(5)
5
>>> 

If you enter the code into the text editor and use the 'run' button to execute it, the text will appear in the System console window. How you access the text in the system console window depends on the OS you are using. On Windows 10, Go to the Window menu and select Toggle System Console:

Window menu showing Toggle System Console

The text will appear in that window:

Read prefs: C:\Users\stupi\AppData\Roaming\Blender Foundation\Blender\2.93\config\userpref.blend
5

for example.

How to save the code:

If you want to keep the code in the blend file, then you don't have to do anything. The code will be saved when you save the blend file.

If you want to store the code in a separate python file, then in the text editor go to the Text menu and select Save or Save As:

text editor Text menu showing the save and save as options

To save

$\endgroup$
6
  • $\begingroup$ I forgot to say i'm uing Linux,Ubuntu 21.10 Thanks $\endgroup$
    – ofey
    Dec 31, 2021 at 22:13
  • $\begingroup$ Then instead of using the Window menu to toggle the System console, you would start Blender on the command line in a terminal window. The output would go to that terminal window. See this answer for an example command line. $\endgroup$ Dec 31, 2021 at 22:16
  • $\begingroup$ Hi Marty Fouts starting Blender from the command line sounds like a whole new problem. I see you get Toggle System Console I can't get that. See my original post for screenshots thanks $\endgroup$
    – ofey
    Dec 31, 2021 at 22:36
  • 1
    $\begingroup$ You can only get Toggle System Console on Windows systems. Starting from the command line in Linux isn't that hard. Start a terminal window and then type a blender command as in the answer that several people have mentioned. $\endgroup$ Dec 31, 2021 at 22:38
  • $\begingroup$ Ok II'll try that thanks $\endgroup$
    – ofey
    Dec 31, 2021 at 22:43

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