How to access hair particles vertices

I want to access hair particles vertices

assume I got 10 hair guides each one got 6 vertices
I want to set the guides’ vertices position through python

I’ve found this code to give me coordinates of each hair and keys

for prt in particleSystem.particles:
…# for particles
…loc = prt.location
…# or, for hair
…for hkey in prt.hair_keys
…loc = hkey.co

problem is when I try to change key coordinates,I figured out I must enter particle edit mode to update the data
and if i enter point edit mode(just the normal editing) the data resets again !!

any idea how to update data after modifying it?

Hi,
I met the same problem.
I set the position of hair vertex by
vt = bpy.data.objects[‘Sphere’].prticle_systems[‘ParticleSystem’].particles[0].hair_keys[0]
vt.co = Vector((10,10,10))

print vt.co
will show Vector((10,10,10))

But after switching the mode (object/particle mode), the position will be reset.

well I’ve found a solution

after you create hair particles
enter particles edit mode–>select any brush and click anywhere in the viewport then undo–>after that return to object mode
(do this only once after creating the hair particle system)

after that when you change hair keys data it will change as expected even if you enter any mode

If you watch the Info window when you enter into particles edit mode you will see…

bpy.ops.particle.particle_edit_toggle()

Maybe your code can toggle the edit mode to prevent the manual step?

Hi folks.
Know somebody how select this hair keys?
I can’t find the .select option.

Greetings

you don’t need to select,you can adjust hair key.co directly without problems (as long as you have turned your hair to edit mode)
so steps:
1-create hair
2-enter particles edit mode
3-select any brush and click in empty space
4-enter object mode (2-3-4 are done only once)
6-now you can edit any particle hair key direct from python

No. You can’t change any particles’s hair key directly. it just only can change weight value and key location. that’s all. You can’t reduce the key number or create new key. it’s not ‘any’