PDA

View Full Version : Urgent ! script to assign rand glue value


BolOWaiN
06-21-2007, 04:41 PM
Hey guys,

Got a huge problem here writing a really simple script to randomly assign a value to the glue strength attribute of ncloth dynamic contraints. I need to at a certain frame assign a value between 0 and 1 and not have it evaluate every frame, ie just once at a certain frame and there are 504 attributes to assign to... Please help!

Ben

trancor
06-21-2007, 05:50 PM
I haven't used nCloth yet, don't know why, just haven't, but I went looking for the glue attribute and couldn't find it, so if my call to the glue node isn't right, change it.


$startFrame=124;
if (frame == $startFrame){
float $rand=rand(0,1);
setAttr "nClothShape1.glue" $rand;
}



Just change the start frame to what ever frame you want.

I don't really understand what you are talking about for the 504 attributes, is that 504 different nCloth objects with teh glue attr you want to set at once on a frame?

BolOWaiN
06-21-2007, 05:57 PM
thanks very much trancor, Yeah, I've got 504 petals and so 504 cloth objects and 504 constraints that each have the glue strength attribute

trancor
06-21-2007, 07:05 PM
OHHH ok, the constraint

then here try this out, you're going to need to fill in for the number in the naming of the petals; asuming you named them with numbers



$startFrame=124;
$constraintStartingNumber=0;
$constraintEndingNumber=504;
$ConstraintNaming="Constraint";
if (frame == $startFrame){
for($x=$constraintStartingNumber; $x<=$constraintEndingNumber; ++$x){
float $rand=rand(0,1);
setAttr ($ConstraintNaming".glue") $rand;
}
}



Starting number - $petalStartingNumber=0;
Last number of the petaling - $petalEndingNumber=504;
Change the name - $petalConstraintNaming="Constraint"; - to your constraint name for the attribute


If your code doesn't work in this mannor, and the constraints aren't right, just say, Ii'll write up a script that will find the constraints for you and list them all in an array using -

string $constraints[] = `ls ("Constraint*")`;


I didn't name things propperly because I don't have maya open and I'm about to go out and play some frisbee, good luck.

BolOWaiN
06-21-2007, 07:57 PM
thanks very much trancor, I will give this a try tomorrow, right now I'm going to bed because it's close on the middle of the night already!

CGTalk Moderation
06-21-2007, 07:57 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.