Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running python script in Blender

Tags:

python

blender

I installed Blender 2.6 and I'm trying to run a script called drawcar.py (Which uses PyOpenGL)

I looked around the documentation for importing a script and could only access Blender's python console.

How do I run drawcar.py from the Linux terminal with Blender?

like image 451
CyberShot Avatar asked Jul 22 '12 22:07

CyberShot


People also ask

Can you do scripting in Blender?

Most areas of Blender can be scripted, including animation, rendering, import and export, object creation and automating repetitive tasks. To interact with Blender, scripts can make use of the tightly integrated API .

How do I open the Python console in Blender?

Accessing Built-in Python ConsoleBy pressing Shift-F4 in any Blender Editor type (3D View, Timeline etc.,) you can change it to a Console Editor. From the screenshot above, you will notice that apart from the usual hot keys that are used to navigate, by pressing Ctrl-Spacebar you can enable Auto-complete feature.


2 Answers

You can also execute the following code in the python console to execute an external script without opening it up in the text editor:

filename = "/full/path/to/myscript.py" exec(compile(open(filename).read(), filename, 'exec')) 

The above code comes from the following link:

Blender - Tips and Tricks

like image 180
Raunaq Avatar answered Sep 18 '22 14:09

Raunaq


  1. Open a Text Editor view in Blender.
  2. Press Alt + O, or go to Text>Open Text Block and open the .py file
  3. Then simply press Run script :D

P.s. Instead of opening a file in step 2, you can also hit the "+ New" button and create a new script instead.

Note : In newer versions the Run Script button label has been replaced with a Play icon : enter image description here

like image 28
Ertyui Avatar answered Sep 17 '22 14:09

Ertyui