Creating maya hair follicles in script

Anyone figure out a good way to set up curves as maya hair in a clean way through script?

I’m trying to add it to an automated rigging system and the scripts I can find in maya create a bunch of horribly named junk I don’t want, and they don’t even return what the names are for the nodes it creates.

I’m guessing it’s a matter of just creating the nodes and connecting everything the way their built in scripts do, but I wanted to ask if someone knew of any resources I can check out or has any suggestions on the topic.

Thanks in advance.

follicles = mel.eval(‘select -cl;
select -r "’+i+’";
createHair 1 5 10 0 0 0 0 5 0 1 1 1;
$connections = listConnections;
delete listRelatives -p $connections[size($connections)-1];$return = $connections[1]’)
follicleGroup = cmds.listRelativesa(follicles,p=True)
this script will generate 5 follicles for you and will give you a follcile back from which you can search the group it is contained in

maybe this helps?

cheers

Thanks but I ended up just writing my own in pymel so that I had complete control of it. It’s here if anyone wants it as a starting point:

If your using the Create Hair tool, you are making a lot of cleanup work for yourself and your script. If you make a plane and ad a single follicle to it you can see how the nodes are connected. Reverse engineer that and you can create a single follicle using

createNode follicle;

Connect everything:

Connect the mesh shape to the follicle shape: outMesh to inputMesh and worldMatrix to inputWorldMatrix
then connect the shape follicle to the actual follicle: outRotate to rotate and outTranslate to translate.

Sample:

// Create Objects
polyPlane -ch on -o on -w 8 -h 8 -sw 1 -sh 1 -cuv 2 ;
rename "plane";
createNode follicle;
pickWalk -d up;
rename "fcl_01";
// Connect Objects
connectAttr -f planeShape.outMesh fcl_0Shape1.inputMesh;
connectAttr -f planeShape.worldMatrix[0] fcl_0Shape1.inputWorldMatrix;
connectAttr -f fcl_0Shape1.outRotate fcl_01.rotate;
connectAttr -f fcl_0Shape1.outTranslate fcl_01.translate;
// center Object On Plane
setAttr "fcl_0Shape1.parameterU" 0.5;
setAttr "fcl_0Shape1.parameterV" 0.5;