Script: Unlock OverrideColor

Error: The attribute 'Control.overrideColor' is locked or connected and cannot be modified.

This is an error shown in MAYA when we try to change the color of a control object( Nurbs or Polygons ) using the Drawing Overrides feature in the Attribute Editor
of a Rig.
Though its not that common that we get this error but if u do then here is the solution.

Mel Window:


Script:

global proc colorOverrideUI()

{

if(`window -exists colorOverride` )
deleteUI colorOverride;

window -title "Unlock OverrideColor" -width 280 colorOverride;
columnLayout myColumn1;

separator -style "none" -h 15 sep_1;
colorIndexSliderGrp -label "Select Color" -min 2 -max 24 -value 17 mycolorIndexSliderGrp;

separator -style "none" -h 15 sep_2;

button -label "GO" -width 425 -command co mybutton;

separator -style "none" -h 10 sep_3;

text -align "left" -label " Note: Use this Script only when there is an error during Drawing Overrides.\n\n Example - ' The attribute 'Control_L_FK_ElbowShape.overrideColor' is locked or \n connected and cannot be modified. '. \n\n Rakesh K Karkera \n tylerdurtan@gmail.com" mytext;

separator -style "none" -h 10 sep_4;

showWindow colorOverride;
}


global proc co()
{
int $color_slider=`colorIndexSliderGrp -q -value mycolorIndexSliderGrp`;
$color = $color_slider-1;

string $list[]=`ls -sl`;

string $shape[];
string $layer[];
string $colorNode;

for ($node in $list)
{

$shape = `listRelatives -f -s $node`;

if (size($shape) == 0)
{

$colorNode = $node;
}
else
{

$colorNode = $shape[0];

}

}

$layer = `listConnections -t displayLayer $colorNode`;


if (size($layer) != 0)
{
disconnectAttr ($layer[0] + ".drawInfo") ($colorNode + ".drawOverride");

setAttr ($colorNode + ".overrideEnabled") 1;
setAttr ($colorNode + ".overrideColor") $color;
}
print "Color override complete.";
}

How To Use: Select the control object, then select the color from the Color Slider and hit "GO".

When To Use: Use this script only when there is an error as it repairs the override connections by breaking it. This script does not work when there is no error.

1 comment:

  1. Thank men, This works for me. I was getting down looking for solutions.

    ReplyDelete