5
$\begingroup$

I am having a problem trying to set the active vertex in blender. I have a list of vertices but I cannot set the active vertex. I am able to retrieve the active vertex through select_history of the bmesh, but I cannot set it, says its not writable

#get bmesh
bm=bmesh.from_edit_mesh(bpy.context.active_object.data)

#print active vert
print(bm.select_history.active)

#if I do something like this, error not writable
bm.select_history.active = bm.verts[5]
$\endgroup$

1 Answer 1

6
$\begingroup$

You can add elements to the bmesh history. The last added element is automatically set as active element. Here is a small code example:

import bpy
import bmesh

me = bpy.context.edit_object.data

#get bmesh (Object needs to be in Edit mode)
bm=bmesh.from_edit_mesh(me)

bm.select_history.add(bm.verts[5])

#print active vert:
print(bm.select_history.active)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .