Monday, 18 January 2010

I'm patient

No wait - that should read impatient.

I'm going to chronicle my old man leg woes here..
  • Early November: I notice my knee feels like shit when I walk sometimes.
  • Mid November: the problem isn't one of those things that will just go away - but the doctors say to give it a few weeks rest.
  • Mid December: its still there! So I have an X-Ray done (no super powers gained)
  • Jan 6th: X-Ray results come back with sod all, I get referred to a specialist/MRI thing.
  • Jan 18th: After many phone calls, reference numbers and daft NHS passwords I've got an appointment for something - in MID FEBRUARY.
For now, ibuprofen will have to suffice... joy joy happy joy.

Wednesday, 13 January 2010

When being good isn't a good thing...

This post isn't about behaving in school, girls (heh), or your moral alignment. Nope, its about work.
For nearly 5 years I've been at the same company, doing CG. Out of those 5 years I think I have spent at least 2 years working with a certain product that will remain anonymous. Watch this! Its funny! And totally unrelated.



As is common with many products, a mascot is involved - one that is burned into my brains and fills my soul with dread. I actually had a nightmare about it once. Anyway - we inherited this project from another (i assume from mass suicide) now deceased-cg company. We were sent files for the mascot that were incomplete and were forced to build something ourselves. At the time I was busy on another commercial, so we outsourced the work. The result was quite shoddy, but the clients approved it - much to my horror. In fact they liked it so much, they kept asking us to make more and more stuff with it - and of course no one will point out to them how shitty it is...

Being me, I wanted to take a tiny bit of pride in my work and produce something that at least looked decent. At the beginning stages of any commercial related to this product I've always asked if I could rebuild the mascot from scratch, so it would look right - perhaps even good.
Such a luxury has never been granted to me and for two solid years I've had to put up with a sub standard mascot that frequently breaks and generally doesn't work.

But what's this? It's a bit quiet now, so in this downtime I've taken it upon myself to do a little R&D. In just two days I found an excellent solution for the rendering problems we'd been experiencing. The results do take a bit more time to achieve, but at least it won't break. With a bit o' tweaking, painting & re-rigging I could have a new and improved mascot ready to go!
All good RIGHT?

The powers that be, are now saying that if we do show our clients these new developments, we run the risk of getting into their bad books. I understand that when a client approves something, you generally run with it till they ask for changes - but when you're able to deliver a product that is 400% better than what they have already, why the FUCK would they be unhappy with it?
The vibe I'm getting for doing this work is pretty negative..

Is it my fault that they would never give me the go ahead to rebuild their crappy character for their past commercials? Is it my fault that nobody would put their foot down and say it looks shit? Essentially the message I'm getting from those in charge is not to do good work - Keep churning out mediocre crap and keep using shitty assets.

So the lesson today boys and girls, is not to waste your time - stay average.

Tuesday, 5 January 2010

Snow place like home

Unlike the majority of England, I am still not back to work/school. I've actually still got ten days of leave leftover from last year to use up! I think I might take off every Wednesday again.. That's over 2 months of hilarious broken weeks! Well, that's if my work schedule will allow it (it won't).

Two days ago I finished up the first XNA 2d game tutorial. I've now completed a cruddy cannon-points-at-spaceships-and-destroys-them game. It should be noted that I've not touched proper programming for about 5 years, bar a few bits of MEL scripting...which doesn't really count.
Object oriented programming is sort of making sense to me now. Classes are essentially magic structs that can contain everything. I wish our lecturers just said that back at uni.... Or maybe they did and I was just too busy doodling.

Stealth fake-update : this site is useful
http://xnadevelopment.com

So how else have I been wasti- spending my time off?
I have been exploring the underground ruins, the sprawling wastelands and insignificant potholes of Washington DC. Yes...... I've been playing Fallout 3 (yes, I'm late to the party). Despite my best attempts not to loot everything and anyone that crosses my path (in the game), my borderline OCD compels me to collect everything of value. Broken assault rifle? I can fix it up & sell it.. Motorcycle engine? I can fix it up & sell it.. Hockey mask? I can - yeah there's a clear pattern here.
Within the game you're able to carry a defined weight before you become over-encumbered and are reduced to walking at a snail's pace. I often find myself in this state, so what do I do? Drop some excess junk and carry on? NO WAY! I resort to taking strength enhancing drugs OH YEAAAH!


I think if the worst comes to the worst and there was some sort of nuclear holocaust I would have a great career as a scavenger-repairman. Fallout 3 should serially be used as post apocalypse training.

Also, it's snowing! Just got back from the doctor, my knee x-ray came back all clear so they're sending me off to get an MRI scan. Maybe this time I'll gain super powers, or at the very least they'll get to the irking pain in my leg.

Friday, 1 January 2010

Twenty ten (ten). God damn (damn)

A new year is upon us and as false resolutions & hopes run riot amongst us, I sit here awake at 1.04am on the 2nd January wondering how I could be better-er..

To shame future Dave into recognising how lazy/unproductive/unmotivated he is, I shall list a few things I intend on doing this year, which currently seem like good ideas.

  1. Jump onto the indie development bandwagon. Be it a cruddy game or a half assed app it's something I feel is worth doing. At the very least I'll gain some programming experience. I've signed up for a free XNA creator club account and sat through 2 hours of tutorials to get the ball-a-rolling on this 'un.
  2. Start drawing again, as well as developing series/shorts ideas. Keep an actual organised and documented sketchbook...hey..it could be on this blog?!
  3. That leads me to the subject of this blog.... I'll aim to actually keep it updated with stuff that isn't just code stolen from other sites (though there'll be plenty of that).
  4. Leave the country at least twice.
  5. ???
  6. Profit
That is it.
Paper out.

Friday, 18 December 2009

picasa image test

 
Posted by Picasa

Monday, 2 November 2009

namespace editor, stoleded from internetzz

/* This file downloaded from Highend3d.com
''
'' Highend3d.com File Information:
''
'' Script Name: ks_nameSpaceManager
'' Author:
'' Last Updated: May 30, 2008
'' Update/Change this file at:
'' http://Highend3d.com/maya/downloads/mel_scripts/utility_external/renaming/4923.html
''
'' Please do not alter any information above this line
'' it is generated dynamically by Highend3d.com and will
'' be changed automatically on any updates.
*/
//
// ks_NameSpaceManager by Katrin Schmid 2007,
//
//Features:
// View, rename or remove up to 7 levels of namespaces.
// Remove empty namespaces only and select objects in namespavce options.
// Rename and keep in hierarchy or move namespace to root namespace.
// Rename and remove is only possible with unreferenced objects.
// You can apply "Make unique names" after removing namespaces to ensure unique object names

// Install: Put ks_nameSpaceManager.mel in you script directory.
// Start the GUI by typing "ks_nameSpaceManager" in the script editor.
//
// Usage:
// List namespaces, then you can start renaming.
// Apply "Make unique names" after removing namespaces to ensure unique object names
//

string $allrGlobalsNodes[] = `ls -l -type renderGlobals`; //defaultRenderGlobals
catch(`setAttr -type "string" ($allrGlobalsNodes[0] + ".currentRenderer") "mentalRay"`);
global int $gl_debug;

////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////main
////////////////////////////////////////////////////////////////////
global proc ks_nameSpaceManager()
{
global string $gl_frNameSpc;

if (`window -query -exists ks__nSpaceManager`)
deleteUI ks__nSpaceManager;

// Strings declarations
string $title = " ks_NameSpaceManager";
string $sh = "showHelp -absolute \"http://www.lo-motion.de/scripts\"";

//UI-Window
window -wh 400 620 -menuBar true
-title $title
-s 1
ks__nSpaceManager;

// Help menue
menu -label "Help" -helpMenu true;
menuItem -label "About" -c $sh;

// Layout
string $form = `formLayout`;
string $child1 = `columnLayout -adjustableColumn true`;
frameLayout -label "" -li 7 -borderStyle "out" -marginHeight 0 -marginWidth 8 -labelAlign "top";
rowLayout -numberOfColumns 1 -columnAlign1 "left" ; // -columnWidth2 230 300
// column 1
columnLayout -rowSpacing 3 -columnWidth 230 col2; //-columnAttach "both" 5

text -align left -w 200 -fn boldLabelFont -label " Check namespaces:";
// text -align left -w 200 -fn boldLabelFont -label "Check name spaces:" ch_ge_namespaces;
radioButtonGrp -l "" -numberOfRadioButtons 3 -columnWidth2 10 230 -p "col2"
-ct2 "left" "left" -select 1 -vr
-labelArray3 "List name spaces" "Remove empty" "Remove all (unreferenced objects)"
rbg_collNmspces;
// text -label "Rename selected namespace to:";
button -bgc .5 .7 .7 -align "left" -w 155 -l " Check/remove" -c "pa_checkScene()";
// button -align "left" -enable 0 -w 150 -l "add namespace" -c "" bu_addNmspc;

text -align left -w 200 -fn boldLabelFont -label "All namespaces:";
$gl_frNameSpc = `optionMenuGrp -adj 0 -cw 1 4 -enable false -w 170 -cat 1 "left" 0 -cc "" me_nameSpc`;
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l " ";
button -align "left" -enable 0 -w 155 -l " Select objects in namespace" -c "pa_selectObjInNamespaces()" bu_selNmspc;
text -label "";
text -align left -w 200 -fn boldLabelFont -l "Rename selected namespace to:" ;
radioButtonGrp -l "" -numberOfRadioButtons 2 -columnWidth2 1 180 //-p "col3"
-ct2 "left" "left" -select 1 -vr
-labelArray2 "keep namespace hierarchy" "move to root" rbg_hierNmspces;
textField -w 155 tx_renameNmspce;

button -align "left" -enable 0 -w 155 -l "Rename selected namespace" -c "pa_renameNamespace()" bu_renNmspc;
setParent ..;
setParent ..;
setParent ..;
////
frameLayout -label "" -li 7 -borderStyle "out" -marginHeight 7 -marginWidth 10 -labelAlign "bottom";
rowLayout -numberOfColumns 2 -columnWidth2 230 300 -columnAlign1 "left" ;
// column 1
columnLayout -rowSpacing 6 -columnWidth 230 col4; //-columnAttach "both" 5
button -bgc .5 .7 .7 -align "left" -enable 1 -w 155 -l " Rename to unique names" -c "makeUniqueName" bu_uniNm;
setParent ..;
columnLayout -rowSpacing 6 -columnWidth 230 col5; //-columnAttach "both" 5
setParent ..;
setParent ..;
setParent ..;
///
showWindow ks__nSpaceManager;
}

////////////////////////////////////////////////
global proc pa_handleRadio(string $btgrName, int $onOff)
{
//string $btgrName, int $onOff
radioButtonGrp -e -enable1 $onOff -enable2 $onOff $btgrName;
}



//////////////////////////////////////////////////////////////////////////////////////
//////////////////////break connection of given dest attribute
global proc pa_breakConnection(string $destName)
{
global int $gl_debug;
if ($gl_debug)
{
print ("pa_breakConnection(string $destName)");
}

if (`connectionInfo -isDestination $destName`)
{
string $destination = `connectionInfo -getExactDestination $destName`;
string $srcConn[] = `listConnections -s 1 -d 0 -type character $destination`;
if (size($srcConn))
{
string $warnMsg = ("Removed \'"+ $destination +"\' from character \'" + $srcConn[0]+"\'.");
warning($warnMsg);
character -e -rm $srcConn[0] $destination;
}
string $sArr[1] = `ls -l -ro $destination`;

if (size($sArr))
{
string $src = `connectionInfo -sourceFromDestination $destination`;
disconnectAttr $src $destination;
}
else
{
delete -icn $destination;
}
}
}



//////////////////////////////////////////////////////////////////
global proc pa_checkScene()
{
global int $gl_debug;
if ($gl_debug)
{
print ("pa_checkScene()"+"\n");
}

int $nVal=`radioButtonGrp -q -sl rbg_collNmspces`;
if($nVal==1)
{
pa_listNamespaces(1);
}
else if($nVal==2)
{
pa_listNamespaces(0);
}
else if($nVal==3)
{
pa_removeUnrefNamespaces();
}
}


//////////////////////////////////////////////////////////////////
global proc pa_selectObjInNamespaces()
{
global int $gl_debug;
if ($gl_debug)
{
print("pa_selectObjInNamespaces()" +"\n");
}


select -d;
string $nameSpc =`optionMenuGrp -q -v me_nameSpc`;
if (`size($nameSpc)`!=0 && `namespace -exists (":" + $nameSpc)`)
{
namespace -set (":" + $nameSpc);
string $objsNamesp[] =`namespaceInfo -dagPath -ls`;
for ($t = 0; $t < size($objsNamesp); $t++)
{
if (`objExists $objsNamesp[$t]`)
{
select -add $objsNamesp[$t];
}
}
namespace -set ":";
}
}

/*
for ($i = 0; $i < size($nameSpaces); $i++)
{
if ($nameSpaces[$i]!= "UI" && $nameSpaces[$i]!= "shared")
{
// delete empty
namespace -set (":" + $nameSpaces[$i]);
string $objs[]= `namespaceInfo -ls`;
if (`size($objs)`==0 && `namespace -exists (":" + $nameSpaces[$i])`)
{
print ("Removed empty namespace: " + $nameSpaces[$i] +"\n");
namespace -set ":";
catch(`namespace -removeNamespace (":" + $nameSpaces[$i])`);
}
else
{
//level 2
$allNameSpc[`size($allNameSpc)`]= $nameSpaces[$i];
string $level2NameSpaces[]= pa_getNamespaces($nameSpaces[$i]);
}
}
}
*/

//////////////////////////////////////////////////////////////////
global proc string[] pa_getNamespaces(string $nameSpace)
{
global int $gl_debug;
if ($gl_debug)
{
print ("$nameSpace: "+ $nameSpace +"\n");
}


namespace -set (":" + $nameSpace);
string $nSpaces[]=`namespaceInfo -lon`;

for ($t = 0; $t < size($nSpaces); $t++)
{
string $objs[]= `namespaceInfo -dagPath -ls`;
if (`size($objs)`== 0 && `namespace -exists $nameSpace`)
{
print ("Removed empty namespace: " + $nameSpace +"\n");
namespace -removeNamespace (":" + $nameSpace);
string $remove[]={$nameSpace};
stringArrayRemove($remove, $nSpaces);
}
}

return $nSpaces;
}



//namespaceInfo -currentNamespace;
//////////////////////////////////////////////////////////////////
global proc string [] pa_listNamespaces(int $showInMenu)
{
global int $gl_debug;
if ($gl_debug)
{
print("pa_listNamespaces()" +"\n");
}

global string $gl_frNameSpc;
string $allNameSpc[];
string $level2NameSpaces[];
string $level3NameSpaces[];
string $level4NameSpaces[];
string $level5NameSpaces[];
string $level6NameSpaces[];
string $level7NameSpaces[];
int $count=0;

if ($showInMenu == 1)
{
button -e -enable true bu_selNmspc;
button -e -enable true bu_renNmspc;
}
else
{
button -e -enable 0 bu_selNmspc;
button -e -enable 0 bu_renNmspc;
}

//deleteMenueItems
string $menItems[] = `optionMenuGrp -q -itemListLong me_nameSpc`;
for ($t = 0; $t < size($menItems); $t++)
{
deleteUI $menItems[$t];
}

namespace -set ":";
string $nameSpaces[] = `namespaceInfo -lon`;
optionMenuGrp -e -enable true me_nameSpc;

for ($i = 0; $i < size($nameSpaces); $i++)
{
if ($nameSpaces[$i]!= "UI" && $nameSpaces[$i]!= "shared")
{
// delete empty
namespace -set (":" + $nameSpaces[$i]);
string $objs[]= `namespaceInfo -dagPath -ls`;
if (`size($objs)`==0 && $showInMenu == 0 )
{
$count++;
print ("Removed empty namespace: " + $nameSpaces[$i] +"\n");
namespace -set ":";
catch(`namespace -removeNamespace (":" + $nameSpaces[$i])`);
}
else
{
//level 2
$allNameSpc[`size($allNameSpc)`]= $nameSpaces[$i];
$level2NameSpaces= pa_getNamespaces($nameSpaces[$i]);
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $nameSpaces[$i];
}

for ($p = 0; $p < size($level2NameSpaces); $p++)
{
$allNameSpc[`size($allNameSpc)`]= $level2NameSpaces[$p];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level2NameSpaces[$p];
}
}
}
}
}
// level 3
for ($f = 0; $f < size($level2NameSpaces); $f++)
{
// print ("$level2NameSpaces[$f]: " +$level2NameSpaces[$f]+"\n");
$level3NameSpaces= pa_getNamespaces(":" + $level2NameSpaces[$f]);
//print ("$level3NameSpaces:+++++" +"\n");
// print ($level3NameSpaces);

for ($g = 0; $g < size($level3NameSpaces); $g++)
{
$allNameSpc[`size($allNameSpc)`]= $level3NameSpaces[$g];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level3NameSpaces[$g];
}
}
}

// level 4
for ($h = 0; $h < size($level3NameSpaces); $h++)
{
// print ("$level3NameSpaces[$f]:+++++ " +$level3NameSpaces[$h]+"\n");
$level4NameSpaces= pa_getNamespaces(":"+$level3NameSpaces[$h]);

// print ("$level4NameSpaces" +"\n");
print ($level4NameSpaces);

for ($u = 0; $u < size($level4NameSpaces); $u++)
{
$allNameSpc[`size($allNameSpc)`]= $level4NameSpaces[$u];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level4NameSpaces[$u];
}
}
}

// level 5
for ($q = 0; $q < size($level4NameSpaces); $q++)
{
$level5NameSpaces= pa_getNamespaces(":" +$level4NameSpaces[$q]);
for ($v = 0; $v < size($level5NameSpaces); $v++)
{
$allNameSpc[`size($allNameSpc)`]= $level5NameSpaces[$v];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level5NameSpaces[$v];
}
}
}

// level 6
for ($b = 0; $b < size($level5NameSpaces); $b++)
{
$level6NameSpaces= pa_getNamespaces(":" +$level5NameSpaces[$b]);
for ($w = 0; $w < size($level6NameSpaces); $w++)
{
$allNameSpc[`size($allNameSpc)`]= $level6NameSpaces[$w];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level6NameSpaces[$w];
}
}
}

// level 7
for ($a = 0; $a < size($level6NameSpaces); $a++)
{
$level7NameSpaces= pa_getNamespaces(":" +$level6NameSpaces[$a]);
for ($x = 0; $x < size($level7NameSpaces); $x++)
{
$allNameSpc[`size($allNameSpc)`]= $level7NameSpaces[$x];
if ($showInMenu==1)
{
menuItem -p ($gl_frNameSpc + "|OptionMenu") -l $level7NameSpaces[$x];
}
}
}
radioButtonGrp -e -label2 ("Remove empty: " + $count +" removed.") rbg_collNmspces;
return $allNameSpc;
}


///////////////////////////////////////////////////////////////
// move namespace back to root ":"
global proc pa_removeUnrefNamespaces()
{
global int $gl_debug;
if ($gl_debug)
{
print ("pa_removeUnrefNamespaces()" +"\n");
}

int $remCount, $notRem=0;
namespace -set ":";
string $allNmspces[] = pa_listNamespaces(0);
string $refNmspces[];
string $refNames[]= `ls -l -type reference`;

for ($i = 0; $i < size($refNames); $i++)
{
if (`gmatch $refNames[$i] "*sharedReferenceNode*"` == 0 && `gmatch $refNames[$i] "*UNKNOWN_REF_NODE*"`==0)
{
string $selRefFileUnR = `getAttr ($refNames[$i] + ".fileNames[0]")`;
// string $selRefFileUnR = `referenceQuery -unresolvedName -filename $refNames[$i]`;
//print ("$refNmspces[size($refNmspces)]: " + $refNmspces[`size($refNmspces)`] +"\n");
if (`size($selRefFileUnR)` > 0)
{
$refNmspces[`size($refNmspces)`]= `file -q -ns $selRefFileUnR`;
}
}
}

string $unrefNamespaces[] = stringArrayRemove($refNmspces, $allNmspces);

for ($p = `size($unrefNamespaces)`;$p >= 0; $p--)
{
namespace -set ":";
if (`size($unrefNamespaces[$p])`> 0 && `namespace -exists (":"+ $unrefNamespaces[$p])` && $unrefNamespaces[$p]!= ":")
{
catch(`namespace -force -mv (":"+ $unrefNamespaces[$p]) ":"`);
namespace -set (":"+ $unrefNamespaces[$p]);
string $objsNamesp[] =`namespaceInfo -dagPath -ls`;
namespace -set ":";

if (`size($objsNamesp)`==0)
{
catch(`namespace -rm $unrefNamespaces[$p]`);
print ("REMOVED:$unrefNamespaces[$p]: "+ $p+ (" :"+ $unrefNamespaces[$p]) +"\n");
$remCount++;
}
}
else
{
$notRem++;
print ("NOTFOUND: "+ $p+ (" :"+ $unrefNamespaces[$p]) +"\n");
}
}
radioButtonGrp -e -label3 ("Remove all: " + $remCount +" removed, "+ ($notRem-1)+ " not removed.") rbg_collNmspces;
}




///////////////////////////////////////////////////////////////
global proc pa_checkReferences()
{
global int $gl_debug;
if ($gl_debug)
{
print("pa_checkReferences()" +"\n");
}

// getAttr TestspRN.fileNames[0]

string $selRefFileUnR;
string $selRefFile;

//textScrollList -e -enable true -ra ts_refFound;
//textScrollList -e -enable true -ra ts_refNotFound;

RNdeleteUnused;
string $refNames[]= `ls -l -type reference`;

for ($i = 0; $i < size($refNames); $i++)
{

if (`gmatch $refNames[$i] "*sharedReferenceNode*"` == 0 && `gmatch $refNames[$i] "*UNKNOWN_REF_NODE*"`==0)
{
//$selRefFileUnR = `referenceQuery -unresolvedName -filename $refNames[$i]`;
$selRefFileUnR = `getAttr ($refNames[$i] + ".fileNames[0]")`;
if (`size($selRefFileUnR)` > 0)
{
$selRefFile = `referenceQuery -filename $refNames[$i]`;
}
}
else if (`gmatch $refNames[$i] "*UNKNOWN_REF_NODE*"`)
{
$selRefFile ="";
$selRefFileUnR =$refNames[$i];
}
string $bufferPP[];

if (`size($selRefFileUnR)` > 0 && $selRefFile != $selRefFileUnR && `gmatch $refNames[$i] "*sharedReferenceNode*"` == 0)
{
string $dir= `workspace -q -rd`;
// Result: D:/maya/workflow/
int $numTokensPP = `tokenize $selRefFileUnR "//" $bufferPP`;
print ("Found ref: " +($dir + $bufferPP[$numTokensPP-1])+"\n");
//Found ref: D:/maya/workflow/B_data_3D/Testsp.mb

if ((`filetest -f ($dir + $bufferPP[$numTokensPP-1])`) == 1)
{
print ("Found ref: " +($refNames[$i]+":" + $selRefFile)+"\n");
// textScrollList -e -append ($bufferPP[$numTokensPP-1]) ts_refFound;
}
else
{
print ("Missing/ empty ref: " +($selRefFileUnR)+"\n");
}

}
else if (`gmatch $refNames[$i] "*sharedReferenceNode*"` == 0 )
{
if ((`filetest -f ($selRefFile)`) == 1)
{
// textScrollList -e -append ($refNames[$i]+":" + $selRefFile) ts_refFound;
print ("Found ref: " +($refNames[$i]+":" + $selRefFile)+"\n");
}
else
{
// textScrollList -e -append ($refNames[$i] + "c") ts_refNotFound;
print ("Missing ref: " +($selRefFile)+"\n");
}
}
}
}


/////////////////////////////////
global proc pa_renameNamespace()
{
global int $gl_debug;
if ($gl_debug)
{
print(" pa_renameNamespace()" +"\n");
}

int $nVal=`radioButtonGrp -q -sl rbg_hierNmspces`;
string $oldNameSpc =`optionMenuGrp -q -v me_nameSpc`;
string $newName =`textField -q -tx tx_renameNmspce`;
string $clName;
if (isValidString($newName, "([a-zA-Z]+)([a-zA-Z0-9_])*")==0)
{
$clName = substituteAllString($newName, " ", "_");
}
else
{
$clName = $newName;
}

// print ("$oldNameSpc: "+$oldNameSpc+"\n");
// print ("$clName: "+ $clName+"\n");
string $bufferPP[];
int $numTokensPP = `tokenize $oldNameSpc ":" $bufferPP`;
int $nSize= `size($bufferPP[$numTokensPP-1])`;
int $oSize= `size($oldNameSpc)`;
string $oldNamePath = `substring $oldNameSpc 1 ($oSize-$nSize)`;

namespace -set ":";
if (`namespace -exists (":" + $clName)`)
{
$clName= $clName +"1";
}

/////////
if(`size($bufferPP)`> 1 && $nVal==1 && `namespace -exists (":"+ $oldNamePath)`)
{
namespace -add $clName -p (":"+ $oldNamePath);
// print ("t:" +(":"+ $oldNamePath + $clName)+"\n");
if (`namespace -exists (":"+ $oldNamePath + $clName)`)
{
namespace -f -mv $oldNameSpc (":"+ $oldNamePath + $clName);
namespace -rm $oldNameSpc;
}
}
else //if ($nVal==2)
{
namespace -add ($clName) -p ":" ;
if (`namespace -exists (":"+ $oldNameSpc)` && `namespace -exists (":"+ $clName)`)
{
print ("hier: " +(":"+$clName)+"\n");
namespace -f -mv (":"+ $oldNameSpc) (":"+ $clName);
namespace -rm $oldNameSpc;
}
}

pa_listNamespaces(1);
}


////////////////////////////
global proc makeUniqueName()
{
// longNmaeof
global int $gl_debug;
if ($gl_debug)
{
print ("makeUniqueNames: " +"\n");
}

namespace -set ":";

string $allobjs[] = `ls -l -tr -mat -tex`;//-tr
for ($i= 0; $i < size($allobjs); $i++)
{
// print ($i + "$allobjs[$i]: " + $allobjs[$i] +"\n");
int $found=0;
if(`objExists $allobjs[$i]` && $allobjs[$i]!="|front" && $allobjs[$i]!="|persp" && $allobjs[$i]!="|top" && $allobjs[$i]!="|side")
{
string $buffer[];
tokenize $allobjs[$i] "|" $buffer;
string $shortNameI = $buffer[`size($buffer)`-1];
for ($t= 0; $t < size($allobjs); $t++)
{
string $buffer1[];
tokenize $allobjs[$t] "|" $buffer1;
string $shortNameT = $buffer1[`size($buffer1)`-1];

if (`objExists $allobjs[$t]` && $i!=$t && $shortNameI == $shortNameT && `referenceQuery -isNodeReferenced $allobjs[$t]`== 0)
{
int $check[]=`lockNode -q -lock $allobjs[$t]`;
if ($check[0] ==1)
{
lockNode -lock 0 $allobjs[$t];
}
string $newName1 = "";
int $n = 0;
select -r $allobjs[$t];
if ($n = catchQuiet($newName1 = `rename($shortNameT + "#")`))
{
print ("Cannot rename.T +"+$shortNameT+"\n");
}
else
{
print ("Renamed.T "+$shortNameT+"\n");
}
if ($n==0)
{
string $longNewNameI[] =`ls -l -sl`;
$allobjs[$t]= $longNewNameI[0];
}
$found=1;
}
}
}
}
}

reinitialise setup machine menu script

if (`objExists TSM2FKIKSwitch`)
delete TSM2FKIKSwitch;
if (`menu -exists TSM2ControlsMenu`) deleteUI -menu TSM2ControlsMenu;

string $path = `pluginInfo -q -path "TSM2"`;
$path = (dirname($path) + "/TSM2/FKIK.mel");
int $file = `fopen $path "r"`;
string $fkikScript = "";
string $nextLine = `fgetline $file`;
while(size($nextLine) > 0) {
$fkikScript += $nextLine;
$nextLine = `fgetline $file`;
}
fclose $file;
$path = `pluginInfo -q -path "TSM2"`;
$path = (dirname($path) + "/TSM2/TSM2_mirrorPose.mel");
int $file = `fopen $path "r"`;
string $mirrorScript = "";
string $nextLine = `fgetline $file`;
while(size($nextLine) > 0) {
$mirrorScript += $nextLine;
$nextLine = `fgetline $file`;
}
fclose $file;
$mirrorScript += "\n\nTSM2_mirrorPose;";
string $afterScript = "if (`menu -exists TSM2ControlsMenu`) deleteUI -menu TSM2ControlsMenu";
string $beforeScript;
$beforeScript = "doEnableNodeItems false all; doEnableNodeItems true all;\n";
$beforeScript += "menu -to true -label \"TSM Controls\" -parent $gMainWindow TSM2ControlsMenu;";
$beforeScript += ("menuItem -label \"FKIK Switch\" -command \"" + (encodeString($fkikScript)) + "\";");
$beforeScript += ("menuItem -label \"Refresh Rig\" -command \"doEnableNodeItems false all; doEnableNodeItems true all;\";");
$beforeScript += ("menuItem -label \"Mirror Pose\" -command \"" + (encodeString($mirrorScript)) + "\";");
scriptNode -st 2 -bs $beforeScript -as $afterScript -n TSM2FKIKSwitch;
scriptNode -executeBefore TSM2FKIKSwitch;