Sub topic 1
Objects and their data: what you are actually editing
This chapter explains the split between an object in your Blender scene and the mesh data that gives it shape. Knowing this split tells you which mode to use for each change.
Prerequisites
You should have Blender open with the default startup scene. You should be comfortable orbiting, panning, and zooming the viewport, selecting objects, and using Move, Rotate, and Scale. You should also know that a 3D mesh is built from vertices, edges, and faces.
Objects and their data
An object is the item listed in the Outliner, such as the default Cube. The object stores its location, rotation, and scale. It also references its data, which is the mesh holding the vertices, edges, and faces. Two objects can share one mesh, so a change to that mesh appears in both.
What an interaction mode is
An interaction mode determines which part of an object your tools act on. You switch modes from the mode menu in the 3D Viewport header or with the Tab key. The active mode decides whether a change affects the object or its mesh data.
Object Mode: working with whole objects
Object Mode treats each object as one unit. Moving, rotating, or scaling in this mode changes the object's properties, not its mesh. This script moves the object and then changes one vertex of its mesh:
import bpy
obj = bpy.context.active_object
if obj is not None and obj.type == 'MESH':
bpy.ops.object.mode_set(mode='OBJECT')
obj.location.x += 2.0 # changes the object
obj.data.vertices[0].co.z += 1.0 # changes the mesh data
print(obj.mode, obj.location.x)Edit Mode: working with mesh geometry
Edit Mode lets you change the vertices, edges, and faces of the mesh data. Blender keeps the edited geometry in an edit copy until you leave Edit Mode. A script that edits the geometry must use BMesh, and it must run while the object is in Edit Mode:
import bpy
import bmesh
obj = bpy.context.edit_object
if obj is not None and obj.type == 'MESH':
bm = bmesh.from_edit_mesh(obj.data)
for vert in bm.verts:
if vert.select:
vert.co.z += 1.0
bmesh.update_edit_mesh(obj.data)Exercise
In Object Mode, does changing obj.location alter the object or its mesh data?
Show answer
It alters the object. Location belongs to the object, so the mesh vertices stay where they are.