cloning
link-mesh-array.py
link-mesh.py

mesh fabrication
staircase.py
triangle-donut.py
vertexAccumulator.py
randomSquareArray.py
meshFromBathymetry.py
cylinders-from-list-of-radii.py
binary-image-to-mesh.py
sphere-minecraft-schematic.py
spikify.py
add-to-mesh.py
mobius-strip.py
split-copy-mesh.py

fabricating other objects
create-text.py
text-from-file.py
create-camera.py
create-bezier.py
helix-bezier.py

material slots
cube-copy-blue.py
cube-turns-red.py
red-blue-per-object.py

animation and fcurves
csv-to-fcurve-loc-rot.py
csv-to-fcurve.py
pop-in-material.py
spike-wiggle-2.py
spike-wiggle.py
sweep-animate-size.py
animate-cycles-lamp-strength.py

incorporating python libraries
exec-text-library.py
exec-external-python.py
import-python.py

constraints
camera-track-object.py
text-track-camera.py

shape keys
explore-shape-keys.py
shape-key-fin.py
docking-tube.py

animating curve bevel
data-graph.py

drivers
scan-drivers.py
copy-drivers.py
driver-fin.py
driver-multi-chain.py

UV layers
barber-pole.py
expand-uv-to-fit.py
uv-from-geometry-cubic.py
flip-texture-v-coordinate.py

modifiers
hook-modifier-curve.py
rounded-prisms.py
make-tile.py
remove-action-modifiers.py

NLAs
explore-NLAs.py
spinning-frogs.py

video sequence editor (VSE)
create-vse-image-strips.py
slide-show.py
vse-strip-gap.py

images and textures
image-on-mesh.py
image-to-material-node.py
load-image-texture.py
texture-one-cube-face.py
condense-duplicate-images.py

analytic geometry
animate-random-spin.py
camera-cone-exp-2.py
camera-cone-exp.py
compute-circle-center.py
dihedral-angle-from-xy.py
extrude-edge-along-custom-axis.py
orientation-matrix.py
two-spheres.py
bezier-interpolate.py
rotate-to-match.py

node trees
change-diffuse-to-emission-node.py

etc
add-plane-from-selected-vertices.py
adjust-all-materials.py
all-nodes-cycles-materials.py
bit_shift.py
bone-orientation-demo.py
cannonball-packing.py
comb.py
convert-quaternion-keyframes-to-euler.py
copy-location-from-vertex-group.py
create-cycles-material.py
demonstrate-decomposition-instability.py
dump-point-cache.py
dump-screen-layout-info.py
expand-nla-strips.py
explore-edge-bevel-weight.py
find-action-users.py
find-green-rectangle.py
find-new-objects.py
fix-scene-layers.py
generate-makefile.py
link-external-data-blocks.py
list-referenced-files.py
material-readout.py
movie-card-stack.py
movies-on-faces.py
next-file-name.py
object-font-from-regular-font.py
operator-mesh-gridify.py
particle-animator.py
particle_loop.py
pose-match.py
pose-sequence-to-fbx.py
prepare-texture-bake.py
raining-physics.py
random-pebble-material.py
reverse-keyframes.py
scale-parallelogram.py
screenshot-sequence.py
select-objects-in-modifiers.py
select-vertices.py
shift-layers.py
snapshot-keyframes-as-mesh.py
sphere-project-texture.py
squish-mesh-axis.py
subdivide-fcurve.py
thicken-texture.py
transform-selected.py
voronoi-madness.py

import bpy
import math
from mathutils import Vector


def debug_dump(k, particle):
    hk = particle.hair_keys[k]
    return "%s\t%s\t%s\t%s\n%s" % (hk.co_local, hk.co,
                               particle.prev_location, particle.location,
                                   (hk.co - particle.prev_location))


def comb1(obj):
    ps = obj.particle_systems[0]
    dx =10
    dy = 10
    for i in range(dx):
        for j in range(dy):
            idx = i*10+j
            particle = ps.particles[idx]
            dz = len(particle.hair_keys)
            loc = ( (i/dx-0.5)* 7, (j/dy-0.5)*7, 0)
            particle.hair_keys[0].co_local = (0,0,0)
            loc = particle.hair_keys[0].co
            particle.location = loc
            particle.prev_location = loc
            for k in range(dz):
                print(particle.hair_keys[k].co_local)
                x =  k*0.1*i
                r = math.pi*dy/(1+j+1)
                theta = k /r
                y =  (1-math.cos(theta))*r
                z = math.sin(theta)*r
                particle.hair_keys[k].co_local = (x,y,z)
                print(debug_dump(k, particle))
          #      particle.hair_keys[k].co = particle.location + Vector( [x,y,z] )
          #      print(debug_dump(k, particle))
                #particle.hair_keys[k].co_local = (x,y,z)
                #print(debug_dump(k, particle))

def bary(verts, w):
    rval = verts[0]*w[0]
    for i in range(1,len(verts)):
        rval = rval + verts[i]*w[i]
    return rval


def bary2(obj, particle):
    mesh = obj.data
    fuv = particle.fuv
    return bary([mesh.vertices[i].co for i in mesh.polygons[0].vertices], fuv)


def comb2(obj):
    ps = obj.particle_systems[0]

    for p in ps.particles:
        p.fuv = [0.1, 0.9,0,0]
        p.location = bary2(obj, p)

    dx =5
    dy = 5
    for i in range(dx):
        for j in range(dy):
            idx = i*dx+j
            particle = ps.particles[idx]
            dz = len(particle.hair_keys)
            # this next bit does not work unless your blender has hacked DNA.  The fuv property is not normally available
            uv = [ i / (dx-1) , j/(dy-1)]
            particle.fuv = (uv[0]*uv[1], (1-uv[0])*uv[1], (1-uv[0])*(1-uv[1]), uv[0]*(1-uv[1]))
            loc = bary2(obj, particle)

            print(particle.fuv, loc)
            particle.location = loc
            particle.prev_location = loc
            slant = 0.5*(i-2)
            for k in range(dz):
                print(particle.hair_keys[k].co_local)
                x =  k*slant
                curvature = 3*(j-2)/dy
                if (curvature!=0):
                    r = math.pi/(curvature)
                    theta = k /r
                    y =  (1-math.cos(theta))*r
                    z = math.sin(theta)*r
                else:
                    y = 0
                    z=k
                particle.hair_keys[k].co_local = (x,y,z)
                print(debug_dump(k, particle))
          #      particle.hair_keys[k].co = particle.location + Vector( [x,y,z] )
          #      print(debug_dump(k, particle))
                #particle.hair_keys[k].co_local = (x,y,z)
                #print(debug_dump(k, particle))


def investigate1(obj):

    ps = obj.particle_systems[0]

    particle = ps.particles[-1]

    hk = particle.hair_keys[1]
    debug_dump(1, particle)

    hk.co_local = (0,0,0)
    print(debug_dump(1, particle))
    hk.co_local = (1,0,0)
    print(debug_dump(1, particle))
    hk.co_local = (0,1,0)
    print(debug_dump(1, particle))
    hk.co_local = (0,0,1)
    print(debug_dump(1, particle))

obj = bpy.data.objects['Plane']
print(obj)
comb2(obj)
#investigate1(obj)

Blender python API quick-start

Syntax highlighting by Pygments.