I'm trying to get the positions of the hair vertices and looked at how some plugins do it. It's usually something like this, using the co_hair function:

import bpy

ps = obj.particle_systems[0]
strands = len(ps.particles)
if ps.settings.child_type == 'NONE': 
    start_id, count = (0, strands)
    start_id, count = (strands, len(ps.child_particles))
length = 2 ** ps.settings.display_step + 1
for particle_idx in range(start_id, start_id + count):
    for step in range(length):
        e = ps.co_hair(obj, particle_no=particle_idx, step=step)

Yet when i try this, i only get empty vectors:

<Vector (0.0000, 0.0000, 0.0000)>
<Vector (0.0000, 0.0000, 0.0000)>

What am i doing wrong?


1 Answer 1


If you just need the position of hair data, you should use particles instead of co_hair:

import bpy

for particle in bpy.context.active_object.particle_systems[0].particles:
    # to access each segments
    #for fiber_point in particle.hair_keys:
    #    print(fiber_point.co_local)

Noted that co_local is in its local coordinate system, relative to the emitting face.

co_hair is for cache hair data. It maybe relates to the cache system of Hair Dynamics.


You must log in to answer this question.

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