Christopher Topalian
Python
Scripting
in
[Link]
Blender
for
Humans
by
Christopher Topalian
Copyright 2021
All Rights Reserved
College of Scripting Music & Science [Link]
Christopher Topalian
DEDICATED
TO
GOD THE FATHER
College of Scripting Music & Science [Link]
Christopher Topalian
Screen Layout - Scripting
Left
Click
Here Left Click
Scripting
[Link]
College of Scripting Music & Science
We open the application Blender.
We then click on the Layout button.
We choose Scripting as the layout.
This makes it easy for us to script.
College of Scripting Music & Science [Link]
Christopher Topalian
Console
Left Click
Window
[Link]
Left Click
Toggle System Console
College of Scripting Music & Science
College of Scripting Music & Science
We use this Console to show
Results of our Scripting and
any Error Messages
College of Scripting Music & Science [Link]
Christopher Topalian
New Script
[Link]
College of Scripting Music & Science
Left Click
New
We make a New Script by clicking the
button that is named New.
This creates an new script.
We can then type our code into it.
College of Scripting Music & Science [Link]
Christopher Topalian
We Type in our first Code
To Hold
Type Make Ctrl +
[Link]
this code Bigger Mouse
Font Wheel
Forwards
College of Scripting Music & Science
Run Script
Left Click
Run Script
College of Scripting Music & Science
Next Page Shows the Result ->
We type the code
print('Hi Everyone')
and then we press the Run Script button.
College of Scripting Music & Science [Link]
Christopher Topalian
Result of Our Script in Console
College of Scripting Music & Science
[Link]
Result of our Python Code
SHOWN in the
Blender System CONSOLE
We use this Console to show
results of our scripting and to
show any error messages.
In Blender, the Window Menu
allows us to
Toggle System Console.
College of Scripting Music & Science [Link]
Christopher Topalian
Rename ourScript & Save As
College of Scripting Music & Science
2
3
[Link]
Left Click
Text Left Click
Save As
1 Type
ourScript
We Type in the name section ourScript
We then choose the Text Menu.
We choose Save As.
Now our Script is saved in blender.
College of Scripting Music & Science [Link]
Christopher Topalian
Info Window
Info window
College of Scripting Music & Science
[Link]
Put Mouse On Horizontal Line
Hold Left Mouse Button
and Drag Downwards
College of Scripting Music & Science
We show the Info Window by dragging
the Horizontal Line downward.
This window provides useful data.
College of Scripting Music & Science [Link]
Christopher Topalian
Show All OBJECTS in Scene
College of Scripting Music & Science
[Link]
Type this
code
Left Click Run Script
Run Script
Result Shown in Console Window
College of Scripting Music & Science [Link]
Christopher Topalian
Show All OBJECTS in Scene
import bpy
ourList = list([Link])
[Link]
print(ourList)
Result
[[Link]['Camera'],
[Link]['Cube'],
[Link]['Lamp']]
We have 3 objects in our Scene
College of Scripting Music & Science [Link]
Christopher Topalian
We Have 3 Objects in Our Scene
College of Scripting Music & Science
Lamp
Cube
name
Cube
[Link]
Camera
Location Scale
Rotation
Our Blender Scene is very simple.
It has a Camera,
a Lamp
and a Cube.
We can name these objects
anything we want!
Notice, that Objects have
Location, Rotation and Scale
College of Scripting Music & Science [Link]
Christopher Topalian
Refer to Object by NAME
import bpy
ourObject = [Link]['Cube']
print(ourObject)
[Link]
Returns the TYPE, which is a
bpy_struct, and that it is
an Object named "Cube"
College of Scripting Music & Science [Link]
Christopher Topalian
Refer to Object by NAME
import bpy
ourObject = [Link]['Lamp']
print(ourObject)
[Link]
Returns the TYPE, which is a
bpy_struct, and that it is
an Object named "Lamp"
College of Scripting Music & Science [Link]
Christopher Topalian
Refer to Object by NAME
import bpy
ourObject = [Link]['Camera']
print(ourObject)
[Link]
Returns the TYPE, which is a
bpy_struct, and that it is
an Object named "Camera"
College of Scripting Music & Science [Link]
Christopher Topalian
Get Location of Object by Name
[Link]
College of Scripting Music & Science
College of Scripting Music & Science [Link]
Christopher Topalian
Get Location of Object by Name
import bpy
ourObject = [Link]['Cube']
print([Link])
[Link]
Returns the Vector Location
of Our Cube, which is located
at <0.0000, 0.0000, 0.0000>
College of Scripting Music & Science [Link]
Christopher Topalian
Hovering Over Elements for Info
College of Scripting Music & Science
Hover the
Mouse Arrow
[Link]
Here
Location of the object.
Python: [Link]
[Link]["Cube"].location[0]
Hover Tips
Hover the Mouse Arrow over buttons and
other elements in Blender to be shown
the Python scripting reference.
College of Scripting Music & Science [Link]
Christopher Topalian
Get Scale of Object by Name
[Link]
College of Scripting Music & Science
Returns the Vector Scale
of Our Cube, which is
<0.0000, 0.0000, 0.0000>
College of Scripting Music & Science [Link]
Christopher Topalian
Get Scale of Object by Name
import bpy
ourObject = [Link]['Cube']
print([Link])
[Link]
Returns the Vector Scale
of Our Cube, which is
<0.0000, 0.0000, 0.0000>
College of Scripting Music & Science [Link]
Christopher Topalian
Hovering Over Elements for Info
Hover
[Link]
Mouse Arrow
Here
Scaling of the Object.
Python: [Link]
[Link]["Cube"].scale[0]
Hover Tips Show Python Reference
College of Scripting Music & Science [Link]
Christopher Topalian
Get Rotation of Object by Name
[Link]
College of Scripting Music & Science
Returns the Euler Rotation
of Our Cube, which is
<Euler (x=0.0000, y=0.0000,
z=0.0000), order='XYZ'>
College of Scripting Music & Science [Link]
Christopher Topalian
Get Rotation of Object by Name
import bpy
ourObject = [Link]['Cube']
print(ourObject.rotation_euler)
[Link]
Returns the Euler Rotation
of Our Cube, which is
<Euler (x=0.0000, y=0.0000,
z=0.0000), order='XYZ'>
College of Scripting Music & Science [Link]
Christopher Topalian
Hovering Over Elements for Info
Hover
Mouse
[Link]
Arrow
Here
Rotation in Eulers.
Radians: 0.000000
Python: Object.rotation_euler
[Link]["Cube"].rotation_euler[0]
Hover Tips Show Python Reference
College of Scripting Music & Science [Link]
Christopher Topalian
Get Name of Current Scene
College of Scripting Music & Science
[Link]
Returns the Scene name
of Our Current Scene,
which is named Scene
College of Scripting Music & Science [Link]
Christopher Topalian
Get Name of Current Scene
import bpy
ourScene = [Link]['Scene'].name
print(ourScene)
[Link]
Returns the Scene name
of Our Current Scene,
which is Scene
College of Scripting Music & Science [Link]
Christopher Topalian
Hovering Over Elements for Info
[Link]
Hover
Mouse Arrow
Here
Scene data-block, consisting in objects &
defining time and render related settings.
Value: Scene
Python: [Link]
[Link]["Scene"].name
Hover Tips Show Python Reference
Remember, that Blender shows us the
Python reference when we hover our
mouse arrow over an element.
College of Scripting Music & Science [Link]
Christopher Topalian
Set Location of Object
import bpy
ourObject = [Link]['Cube']
[Link] = (5.0, 0.0, 0.0)
[Link]
print([Link])
Moves object to vector location.
This script moves the object named
Cube to the location specified,
X position of 5.0
Y position of 0.0
Z position of 0.0
College of Scripting Music & Science [Link]
Christopher Topalian
DEDICATED
TO
GOD THE FATHER
Presented by the
College of Scripting
Music & Science
We have taught over 2 million people
how to program computers, for free,
since March of 2007!
[Link]/ScriptingCollege
[Link]/ChristopherTopalian
[Link]
[Link]
Christopher Topalian Copyright 2007-2021
All Rights Reserved. All content here is protected.
College of Scripting Music & Science [Link]