PDA

View Full Version : can't access Attr in Block of Code?


DangerAhead
08-16-2005, 11:12 PM
I'm trying to connect the weight attr of a point constraint to a locator's Attribute.
Neither setDrivenKeyframe or connectAttr are working.
I'm using a function to create the pointConstraint, Then trying to connect it to the locator.
but the error keeps telling me the attribute doesn't exist.

Cut and Paste Into Script Editor and see if you can figure out why it ain't workin`


// two objects to try out
polyCube -n pCube1;
polyCube -n pCube2;

// locator to control point constraint
spaceLocator;
string $sel[] = `ls -sl`;
rename $sel[0] specialtyController;


global proc gmConstrainToLocator (string $constrained, string $locName, string $spec){

select -cl;
string $constraintName[] = `pointConstraint -offset 0 0 0 -weight 0 $locName $constrained`;

select -cl;

addAttr -ln $spec -at double -min 0 -max 1 -dv 0 specialtyController;
setAttr -e -keyable true ("specialtyController." + $spec);

// SET DRIVEN KEY = not working
setDrivenKeyframe -dv 0 -v 0 -itt "flat" -ott "flat" -cd ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "WO");
setDrivenKeyframe -dv 1 -v 1 -itt "flat" -ott "flat" -cd ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "WO");

// CONNECT ATTR = not working
//connectAttr -f ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "WO");

// MANUAL ATTEMPT = not working
// connectAttr -f specialtyController.LGT pCube1_pointConstraint1.pCube2W0;


}

gmConstrainToLocator("pCube1", "pCube2", "abc");

john_homer
08-16-2005, 11:21 PM
to connect to a constraint its w (for weight) then a NUMBER (for index)

you had "W" then the letter "O" rather than the number "0"...

they look the same.. remember its an index.. if you had constrained it to 2 things, the next would be ($constraintName[0] + "." + "whatEverYouConstrainedTo" + "W1")

the below works, I just changed letters for numbers...

.j

// two objects to try out
polyCube -n pCube1;
polyCube -n pCube2;

// locator to control point constraint
spaceLocator;
string $sel[] = `ls -sl`;
rename $sel[0] specialtyController;


global proc gmConstrainToLocator (string $constrained, string $locName, string $spec){

select -cl;
string $constraintName[] = `pointConstraint -offset 0 0 0 -weight 0 $locName $constrained`;

select -cl;

addAttr -ln $spec -at double -min 0 -max 1 -dv 0 specialtyController;
setAttr -e -keyable true ("specialtyController." + $spec);

// SET DRIVEN KEY = not working
setDrivenKeyframe -dv 0 -v 0 -itt "flat" -ott "flat" -cd ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "W0");
setDrivenKeyframe -dv 1 -v 1 -itt "flat" -ott "flat" -cd ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "W0");

// CONNECT ATTR = not working
//connectAttr -f ("specialtyController." + $spec) ($constraintName[0] + "." + $locName + "W0");

// MANUAL ATTEMPT = not working
// connectAttr -f specialtyController.LGT pCube1_pointConstraint1.pCube2W0;


}

gmConstrainToLocator("pCube1", "pCube2", "abc");

DangerAhead
08-16-2005, 11:35 PM
Homer rocks again.

In Navajo you would be called "Oho Agilla" (sp?). Which means "Eagle Eye".

I think it's Navajo. Could be Spanish.

Thanks. I was pulling my hair out. I knew it should've been a zero, but I must have typed an "O".

If you're ever in SF, I'll buy you 2 beers!

CGTalk Moderation
08-16-2005, 11: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.