Saturday, November 10, 2012

Python Interpreter

This entry will be the starting point for any and all Python Scripting in Blender.  What's nice is that Blender also installs a full fledged Python interpreter/compiler so you can test regular python scripts (not just Blender ones) in this environment.

Blender has a view dedicated to Python Scripting which can be found by [Ctrl + Left] or by selecting Scripting from the drop down menu at the top.  The scripting view looks like the image below.





When coding, it is always helpful to be able to view our programs output.  The output console can be opened (in the Windows version) with a command under the Help menu called Toggle System Console.

Clicking on this will bring up the following window separate from Blender.  Note, that if you close this window (with the X), you will close Blender.  So if you just want to hide it but keep Blender open, use the command in the Help menu.

Now to create your first Python script, simply click on Text, and Create Text Block.

Now in the big upper left window pane, you can type your Python code.  When you press the Run Script button [Alt + P], the script will run, and the output (if there is any) will be displayed on the console window.

If you want to save your Python script, simply click Text > Save As or [Shift+Ctrl+Alt+s]

No comments:

Post a Comment