Selecting a specific vertex

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Posts: 4
Joined: Sat Apr 07, 2012 10:25 pm
Location: Saint Anthony, ID

Selecting a specific vertex

Postby CallMeMisterX » Sat Aug 11, 2012 8:24 pm

Hello, I have been searching and can't seem to find how to select specific vertices of a mesh.

What I'm trying to do:
I am first adding a cylinder primitive with end fill set to "TRIFAN". Once this is completed, I want to then be able to select the center vertex in order to move it downward, effectively creating a pin/point. The problem is finding a way to select the center vertex in order to reposition it and pull this off. Any help is greatly appreciated.

Posts: 21
Joined: Wed Dec 07, 2011 4:42 pm

Possible solution

Postby damix » Mon Aug 13, 2012 11:38 pm

Hello CallMeMisterX,

if your problem is finding the center top vertex, I think you can safely assume it is always vertex at index 1. I tried with various cylinders, with odd and even sides and it always selected the top vertex in the center of the triangle fan. If you are interested in the center bottom vertex, use index 0 in place of 1.

Code: Select all

import bpy

bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
mesh =['Cylinder'].data
mesh.vertices[1].co.z += 0.25

If you actually want to select vertices, here I have some code adapted from in order to work on current Blender release 2.63.

Code: Select all

import bpy

o =['Cylinder'] = o
bpy.ops.object.mode_set(mode='EDIT', toggle=False)

sel_mode = bpy.context.tool_settings.mesh_select_mode
bpy.context.tool_settings.mesh_select_mode = [True, False, False]
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

mesh =
mesh.vertices[1].select = True
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.context.tool_settings.mesh_select_mode = sel_mode

Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests