How to run the python script in the Blender 2.77 text editor

For the python learner Blender is one of the real deal to show our python programming skill, today I have take a look at this cool Blender’s Text Editor which we can directly type in the python code and run it to see the outcome in the Blender’s 3D View Editor.

Blender’s Text Editor is where we will write our python script and run it before we actually create a Blender addon and install it in Blender. To use the Text Editor all we need to do is to click on the 3d cube button on the bottom of our 3D View window and then replace the 3D View Window with the Text Editor window, make sure we have two windows open so we can see the python script’s outcome from another 3D View window.

Open Text Editor
Open Text Editor

Next click on the New button bellow the Text Editor window to create a new Text Editor.

Click New
Click New

Now we can start to enter the python script into that new text editor, lets input below script into the text editor and see the outcome by ourself.

import bpy

scene = bpy.context.scene
material ="PKHG")
material.diffuse_color = (0.7,0.0,0.5)
material.diffuse_fresnel = 3.0
material.darkness = 0.3
material.diffuse_intensity = 0.5
material.diffuse_intensity = 0.7
material.diffuse_toon_size = 3.0
for obj in scene.objects:
    obj.rotation_euler = (0.785398, 0.785398, 0.785398)
    obj.active_material = material

Next click on the Run Script button at the bottom of the editor and see the outcome as follow on the other 3D View window.

The selected object
The selected object

Basically what that above script does is to rotate the selected color cube in an angle and includes various other settings into the selected cube.

If you are interested in Blender programming then Blender Documentation is where you can find all the Blender functions that you can use in your python program. Besides that, this blog will also show article regarding how to write a python program which we can use in Blender from time to time so make sure you bookmarked this blog (I don’t collect email from you, only bookmark my blog and return for more interesting articles if you want to).