View Full Version : Automation of Maya Hair constraints

04 April 2006, 08:42 PM
Hi everyone, I'm having a problem automating the creation of hair collision sphere constraints. I have a bunch of poly spheres that I parent constrained to my character, and I want to create collision sphere constraints based off those spheres and connect the attributes so that the collision spheres follow along with the poly spheres. I have this script to do it:

string $hairCurves[] = `listRelatives -children ($hairSystem + "OutputCurves")`;
string $hairConstraints[] = {};

for($obj in $collisionSpheres) {
select $hairCurves;
createHairConstraint 5;
string $hairConstraint[] = `pickWalk -d up`;
connectAttr -f ($obj + ".translate") ($hairConstraint[0] + ".translate");
connectAttr -f ($obj + ".rotate") ($hairConstraint[0] + ".rotate");
connectAttr -f ($obj + ".scale") ($hairConstraint[0] + ".scale");

$hairConstraint[0] = `rename $hairConstraint[0] ($hairSystem + $obj + "Collision")`;
$hairConstraints[`size($hairConstraints)`] = $hairConstraint[0];

The thing is, if I select one sphere to make a collision sphere out of, it works fine and creates the sphere, but if I select multiple spheres, it creates the collision spheres but the dynamic simulation stops working. If I select single spheres manually and run the script, I could create as many of these as I want and the simulation continues to work, but it doesn't for multiple spheres. Why would that be, since in the script I have it set up to operate on individual spheres anyway.

Any help will be appreciated.

04 April 2006, 10:35 PM
seems like I've tried everything. I tried splitting the function out so that it only creates one collision sphere at a time, and then making another function that calls the first function for every obj in the selection list, but it still stops the simulation if there's more than one object selected. I'm thinking it's a bug in Maya, anyone have any experiences with this?

CGTalk Moderation
04 April 2006, 10:35 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.