Tuesday 21 December 2010

ZOMG SAUCE PLOX!!!!!1!!!!111!!

proc sc_gui()
{
string $selection[] = (`ls -selection`);
if (`window -exists "sc_gui"`) deleteUI "sc_gui";
window -w 150 -h 300 -t "My Tool Set" -maximizeButton false -minimizeButton false sc_gui;
print "Selected: ";
print ($selection);
columnLayout;
button -l "Select Hierachy" -w 150 -c "sc_hi";
separator -style "double" -w 150;
button -l "Create Locator" -w 150 -c "sc_locator";
separator -style "double" -w 150;
button -l "Toggle Rotation Axes" -w 150 -c "sc_axes";
separator -style "double" -w 150;
button -l "Rename Selected" -w 150 -c "sc_Rename";
separator -style "double" -w 150;
button -label "Convention" -w 150 -command "sc_Convention";
separator -style "double" -w 150;
button -label "Create Box Curve" -w 150 -command "sc_curveBox";
separator -style "double" -w 150;
button -label "Create Joint Curve" -w 150 -command "sc_curveJoint";
separator -style "double" -w 150;
button -label "Character Nodes" -w 150 -command "sc_grpNodes";
separator -style "double" -w 150;
button -label "Vertex Joints" -w 150 -command "sc_vertJoint";
separator -style "double" -w 150;
button -label "Hyper Shader" -w 150 -command "sc_hypershader_gui";
showWindow "sc_gui";
}
proc sc_Convention()
{
if (`window -exists "sc_Convention"`) deleteUI "sc_Convention";
window -w 150 -h 300 -t "GUI" -maximizeButton false -minimizeButton false sc_Convention;
columnLayout -adj 1;
text -w 150 -al "left" -fn "boldLabelFont" -l "Prefix";
textField -width 150 sc_preffix;
text -w 150 -al "left" -fn "boldLabelFont" -l "Sufix";
textField -width 150 -text `date -format "DDMMYY"` sc_suffix;
button -l "Apply" -w 150 -c "sc_Convention_win";
showWindow "sc_Convention";
}
proc sc_Convention_win()
{
string $marker = "nc_";
string $prefix = `textField -q -text sc_preffix`;
string $sufix = `textField -q -text sc_suffix`;
string $selection[] = (`ls -selection`);
if (size($prefix) == 0 || size($prefix) < 1 )
{
print "\nNo Prefix defined\n";
}
else
{
print "\nPREFIX: ";
print ($prefix + "\n");
}
if (size($selection) == 0 || size($selection) < 1 )
{
print "No Objest selected\n";
}
else
{
for ($items in $selection)
{
print ($items + "\n");
string $matches = (`match $marker $items`);
print ($matches + "\n");
if ( $matches == $marker)
{
print "false \n ";
}
else
{
rename $items ("nc_" + $prefix + "_" + $items + "_" + $sufix);
}
}
}
string $selection[] = (`ls -selection`);
print "Selected:\n";
print $selection "\n";
}
proc sc_Rename()
{
if (`window -exists "rnm_win"`) deleteUI "rnm_win";
window -w 600 -h 300 -t "Rename" -maximizeButton false -minimizeButton false rnm_win;
columnLayout -adj 1;
string $sel[] = `ls -sl`;
for ($each in $sel)
{
nameField -o $each;
}
showWindow rnm_win;
}
proc sc_locator()
{
string $locator[] = `spaceLocator`;
string $Rename = `rename $locator "loc"`;
}
proc sc_hi()
{
select -hi;
}
proc sc_axes()
{
ToggleLocalRotationAxes;
}
proc sc_curveBox()
{
string $boxCurve = `curve -d 1 -p -4.810877 4.810877 4.810877 -p 4.810877 4.810877 4.810877 -p 4.810877 4.810877 -4.810877 -p -4.810877 4.810877 -4.810877 -p -4.810877 4.810877 4.810877 -p -4.810877 -4.810877 4.810877 -p 4.810877 -4.810877 4.810877 -p 4.810877 -4.810877 -4.810877 -p 4.810877 4.810877 -4.810877 -p 4.810877 4.810877 4.810877 -p 4.810877 -4.810877 4.810877 -p 4.810877 -4.810877 -4.810877 -p -4.810877 -4.810877 -4.810877 -p -4.810877 4.810877 -4.810877 -p -4.810877 -4.810877 -4.810877 -p -4.810877 -4.810877 4.810877 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15` ;
select $boxCurve;
string $RenameCurve = `rename $boxCurve "boxCurve01"`;
}
proc sc_curveJoint()
{
string $circleCurve1[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
string $circleCurve2[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
string $circleCurve3[] = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1`;
rotate -r -os 90 0 0 $circleCurve2[0];
rotate -r -os 0 0 90 $circleCurve3[0];
select $circleCurve2[0];
select -add $circleCurve3[0];
makeIdentity -apply 1 -t 1 -r 1 -s 1;
string $relativeCurve2[] = `listRelatives -shapes $circleCurve2[0]`;
string $relativeCurve3[] = `listRelatives -shapes $circleCurve3[0]`;
parent -r -s $relativeCurve2[0] $circleCurve1[0];
parent -r -shape $relativeCurve3[0] $circleCurve1[0];
select $circleCurve2[0];
select -add $circleCurve3[0];
doDelete;
string $RenameCurve = `rename $circleCurve1[0] "jointCurve01"`;
select $RenameCurve;
}
proc sc_vertJoint()
{
string $selVert[] = `ls -sl -fl`;
for ($verts in $selVert)
{
select $verts;
//cluster on each vert
string $cluster[] = `newCluster "-relative -envelope 1"`;
//clear selection
select -cl;
//create joint
string $newJoint = `joint`;
//point constrain
string $pointConstrain[] = `pointConstraint -offset 0 0 0 -weight 1 $cluster $newJoint`;
//query the constraint
string $findConstraint[] = `listRelatives -typ pointConstraint $newJoint`;
//select and delete constraint
select $findConstraint[0];
doDelete;
//delete the cluster
select -replace $cluster;
doDelete;
}
}
proc sc_grpNodes()
{
group -em -w -n charNode01;
group -em -w -n globalMove01;
group -em -w -n joints01;
group -em -w -n iks01;
group -em -w -n controlObjects01;
group -em -w -n to_transform01;
group -em -w -n trns_toShow01;
group -em -w -n trns_toHide01;
group -em -w -n model01;
group -em -w -n blendShapes01;
group -em -w -n extraNodes01;
group -em -w -n xtra_toShow01;
group -em -w -n xtra_toHide01;
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.tx";
setAttr -lock true -keyable false -channelBox false "charNode01.tx";
setAttr -lock true -keyable false -channelBox false "joints01.tx";
setAttr -lock true -keyable false -channelBox false "iks01.tx";
setAttr -lock true -keyable false -channelBox false "controlObjects01.tx";
setAttr -lock true -keyable false -channelBox false "to_transform01.tx";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.tx";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.tx";
setAttr -lock true -keyable false -channelBox false "model01.tx";
setAttr -lock true -keyable false -channelBox false "blendShapes01.tx";
setAttr -lock true -keyable false -channelBox false "extraNodes01.tx";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.tx";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.ty";
setAttr -lock true -keyable false -channelBox false "charNode01.ty";
setAttr -lock true -keyable false -channelBox false "joints01.ty";
setAttr -lock true -keyable false -channelBox false "iks01.ty";
setAttr -lock true -keyable false -channelBox false "controlObjects01.ty";
setAttr -lock true -keyable false -channelBox false "to_transform01.ty";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.ty";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.ty";
setAttr -lock true -keyable false -channelBox false "model01.ty";
setAttr -lock true -keyable false -channelBox false "blendShapes01.ty";
setAttr -lock true -keyable false -channelBox false "extraNodes01.ty";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.ty";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.tz";
setAttr -lock true -keyable false -channelBox false "charNode01.tz";
setAttr -lock true -keyable false -channelBox false "joints01.tz";
setAttr -lock true -keyable false -channelBox false "iks01.tz";
setAttr -lock true -keyable false -channelBox false "controlObjects01.tz";
setAttr -lock true -keyable false -channelBox false "to_transform01.tz";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.tz";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.tz";
setAttr -lock true -keyable false -channelBox false "model01.tz";
setAttr -lock true -keyable false -channelBox false "blendShapes01.tz";
setAttr -lock true -keyable false -channelBox false "extraNodes01.tz";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.tz";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.rx";
setAttr -lock true -keyable false -channelBox false "charNode01.rx";
setAttr -lock true -keyable false -channelBox false "joints01.rx";
setAttr -lock true -keyable false -channelBox false "iks01.rx";
setAttr -lock true -keyable false -channelBox false "controlObjects01.rx";
setAttr -lock true -keyable false -channelBox false "to_transform01.rx";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.rx";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.rx";
setAttr -lock true -keyable false -channelBox false "model01.rx";
setAttr -lock true -keyable false -channelBox false "blendShapes01.rx";
setAttr -lock true -keyable false -channelBox false "extraNodes01.rx";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.rx";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.ry";
setAttr -lock true -keyable false -channelBox false "charNode01.ry";
setAttr -lock true -keyable false -channelBox false "joints01.ry";
setAttr -lock true -keyable false -channelBox false "iks01.ry";
setAttr -lock true -keyable false -channelBox false "controlObjects01.ry";
setAttr -lock true -keyable false -channelBox false "to_transform01.ry";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.ry";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.ry";
setAttr -lock true -keyable false -channelBox false "model01.ry";
setAttr -lock true -keyable false -channelBox false "blendShapes01.ry";
setAttr -lock true -keyable false -channelBox false "extraNodes01.ry";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.ry";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.rz";
setAttr -lock true -keyable false -channelBox false "charNode01.rz";
setAttr -lock true -keyable false -channelBox false "joints01.rz";
setAttr -lock true -keyable false -channelBox false "iks01.rz";
setAttr -lock true -keyable false -channelBox false "controlObjects01.rz";
setAttr -lock true -keyable false -channelBox false "to_transform01.rz";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.rz";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.rz";
setAttr -lock true -keyable false -channelBox false "model01.rz";
setAttr -lock true -keyable false -channelBox false "blendShapes01.rz";
setAttr -lock true -keyable false -channelBox false "extraNodes01.rz";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.rz";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.sx";
setAttr -lock true -keyable false -channelBox false "charNode01.sx";
setAttr -lock true -keyable false -channelBox false "joints01.sx";
setAttr -lock true -keyable false -channelBox false "iks01.sx";
setAttr -lock true -keyable false -channelBox false "controlObjects01.sx";
setAttr -lock true -keyable false -channelBox false "to_transform01.sx";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.sx";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.sx";
setAttr -lock true -keyable false -channelBox false "model01.sx";
setAttr -lock true -keyable false -channelBox false "blendShapes01.sx";
setAttr -lock true -keyable false -channelBox false "extraNodes01.sx";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.sx";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.sy";
setAttr -lock true -keyable false -channelBox false "charNode01.sy";
setAttr -lock true -keyable false -channelBox false "joints01.sy";
setAttr -lock true -keyable false -channelBox false "iks01.sy";
setAttr -lock true -keyable false -channelBox false "controlObjects01.sy";
setAttr -lock true -keyable false -channelBox false "to_transform01.sy";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.sy";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.sy";
setAttr -lock true -keyable false -channelBox false "model01.sy";
setAttr -lock true -keyable false -channelBox false "blendShapes01.sy";
setAttr -lock true -keyable false -channelBox false "extraNodes01.sy";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.sy";
setAttr -lock true -keyable false -channelBox false "xtra_toHide01.sz";
setAttr -lock true -keyable false -channelBox false "charNode01.sz";
setAttr -lock true -keyable false -channelBox false "joints01.sz";
setAttr -lock true -keyable false -channelBox false "iks01.sz";
setAttr -lock true -keyable false -channelBox false "controlObjects01.sz";
setAttr -lock true -keyable false -channelBox false "to_transform01.sz";
setAttr -lock true -keyable false -channelBox false "trns_toShow01.sz";
setAttr -lock true -keyable false -channelBox false "trns_toHide01.sz";
setAttr -lock true -keyable false -channelBox false "model01.sz";
setAttr -lock true -keyable false -channelBox false "blendShapes01.sz";
setAttr -lock true -keyable false -channelBox false "extraNodes01.sz";
setAttr -lock true -keyable false -channelBox false "xtra_toShow01.sz";
setAttr -lock true -keyable false -channelBox false "globalMove01.visibility";
select -r trns_toShow01;
select -tgl trns_toHide01;
select -tgl to_transform01;
parent;
select -r joints01;
select -tgl iks01;
select -tgl controlObjects01;
select -tgl to_transform01;
select -tgl globalMove01;
parent;
select -r xtra_toShow01;
select -tgl xtra_toHide01;
select -tgl extraNodes01;
parent;
select -r globalMove01;
select -tgl model01;
select -tgl blendShapes01;
select -tgl extraNodes01;
select -tgl charNode01;
parent;
select -cl;
}
proc sc_hypershader_gui()
{
string $selection[] = (`ls -selection`);
if (`window -exists "sc_hyper"`) deleteUI "sc_hyper";
window -w 150 -h 300 -t "Hyper shade tools" -maximizeButton false -minimizeButton true sc_hyper;
columnLayout;
button -l "Clear Graph" -w 150 -c "sc_hyperClear";
separator -style "double" -w 150;
button -l "Add Selected" -w 150 -c "sc_hyperAdd";
separator -style "double" -w 150;
button -l "Remove Selected" -w 150 -c "sc_hyperRemove";
separator -style "double" -w 150;
showWindow "sc_hyper";
HypershadeWindow;
hyperShadePanelMenuCommand("hyperShadePanel1", "toggleRenderCreateBar");
hyperShadePanelMenuCommand("hyperShadePanel1", "showBottomTabsOnly");
}
proc sc_hyperClear()
{
hyperShadePanelGraphCommand("hyperShadePanel1", "clearGraph");
}
proc sc_hyperAdd()
{
hyperShadePanelGraphCommand("hyperShadePanel1", "addSelected");
}
proc sc_hyperRemove()
{
hyperShadePanelGraphCommand("hyperShadePanel1", "removeSelected");
}
sc_gui()

3 comments:

  1. It needs work, like rearranging the buttons grouping them up into seperate windows, but it works for now.

    ReplyDelete
  2. Impressive man!
    I'm writing my plugin at the minute.
    I'm just wondering:
    if (size($prefix) == 0 || size($prefix) < 1 )
    Is the the or bit (||...) absolutely necessary?
    I'm not criticising. I'm genuinely asking. Cause I thought both conditions would come to the result at any time and if I'm wrong . I'm doing it wrong.

    ReplyDelete
  3. yeah as far the only way ive been able to get it to work, although as soon as its working i didnt look at it any further, georg helped me to write that section, i dunno if if (size($prefix) < 0) would work or not.

    ReplyDelete