Just a heads up, in case anybody else has been frustrated by this:
Sometimes when doing a parentConstraint with maintain offset ON, the constrained object will be flipped 180 degrees.
I’ve found, though, that (at least in my test cases) if you apply the parentConstraint to the current selection, instead of explicitly supplying arguments in a script, it works correctly.
Here’s some sample mel code:
// 1) Doing this will end up flipping the pyramid upside down
file -new -f;
createNode transform -n “L_leg_ikCtrl”;
setAttr “.r” -type “double3” 180 0 0 ;
setAttr “.ro” 3;
polyCone -sx 4 -name “L_leg_ikCtrl_cone”;
parent “L_leg_ikCtrl_cone” “L_leg_ikCtrl”;
createNode transform -n “transform2”;
setAttr “.r” -type “double3” -77.853031303165153 12.12112240316919 -87.412239779165134 ;
setAttr “.s” -type “double3” 0.99999987813066582 0.99999970476198963 0.99999976145619462 ;
setAttr “.sh” -type “double3” -3.5036528336529942e-08 -3.2133419985118477e-09 1.1636280827992151e-09 ;
createNode joint -n “L_foot01_skinJnt1” -p “transform2”;
setAttr “.r” -type “double3” -1.3716142063811415e-14 -1.2762596861458585e-14 -5.2677936911739486e-15 ;
setAttr “.ro” 2;
setAttr “.s” -type “double3” 0.9999997615814209 0.9999997615814209 0.99999970197677612 ;
setAttr “.jo” -type “double3” 84.368437919533207 -10.468423747497605 -73.90108294829956 ;
setAttr “.ssc” no;
setAttr “.is” -type “double3” 1 0.99999994039535522 1 ;
setAttr “.bps” -type “matrix” 0 -4.6905289999999997 8.8317010000000007 0 10 0 0 0
0 8.8317010000000007 4.6905289999999997 0 13.9152 9.1014099999999996 -11.1616 1;
parentConstraint -mo L_foot01_skinJnt1 L_leg_ikCtrl;
// 2) Doing this will work correctly, even though the only thing that’s different is that this version is
// using the current selection, as opposed to explicitly supplying the arguments.
file -new -f;
createNode transform -n “L_leg_ikCtrl”;
setAttr “.r” -type “double3” 180 0 0 ;
setAttr “.ro” 3;
polyCone -sx 4 -name “L_leg_ikCtrl_cone”;
parent “L_leg_ikCtrl_cone” “L_leg_ikCtrl”;
createNode transform -n “transform2”;
setAttr “.r” -type “double3” -77.853031303165153 12.12112240316919 -87.412239779165134 ;
setAttr “.s” -type “double3” 0.99999987813066582 0.99999970476198963 0.99999976145619462 ;
setAttr “.sh” -type “double3” -3.5036528336529942e-08 -3.2133419985118477e-09 1.1636280827992151e-09 ;
createNode joint -n “L_foot01_skinJnt1” -p “transform2”;
setAttr “.r” -type “double3” -1.3716142063811415e-14 -1.2762596861458585e-14 -5.2677936911739486e-15 ;
setAttr “.ro” 2;
setAttr “.s” -type “double3” 0.9999997615814209 0.9999997615814209 0.99999970197677612 ;
setAttr “.jo” -type “double3” 84.368437919533207 -10.468423747497605 -73.90108294829956 ;
setAttr “.ssc” no;
setAttr “.is” -type “double3” 1 0.99999994039535522 1 ;
setAttr “.bps” -type “matrix” 0 -4.6905289999999997 8.8317010000000007 0 10 0 0 0
0 8.8317010000000007 4.6905289999999997 0 13.9152 9.1014099999999996 -11.1616 1;
select -r L_foot01_skinJnt1 ;
select -tgl L_leg_ikCtrl_cone ;
parentConstraint -mo -weight 1;