Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I ran into an issue with a MEL script I created to make working with cables a bit easier. It works just fine if I run the entire code from the script editor but if i create a shelf button or hot key of Worms() and restart maya, the code seems to break down and the shelf button or hot key stop functioning properly. Is there something im missing in the code to keep it from breaking. I saved the code in 2019/scripts and have tried sourcing it but that also doesnt seem to be fixing anything.
Any help would be appreciated.
global proc Worms()
{
SelectAllPolygonGeometry;
string $polys[] = `ls -sl`;
string $p;
for ($p in $polys)
{
int $mode = `getAttr ($p+".overrideDisplayType")`;
if ($mode==0)
{
setAttr ($p+".overrideEnabled") 1;
setAttr ($p+".overrideDisplayType") 2;
setAttr ($p+".useOutlinerColor") 1;
setAttr ($p+".outlinerColor") 1 0 0;
clearBrush();
strokeRef1();
modelEditor -e -xr true modelPanel4;
select -cl;
}
if ($mode==2)
{
//select -all;
setAttr ($p+".overrideEnabled") 0;
setAttr ($p+".overrideDisplayType") 0;
setAttr ($p+".useOutlinerColor") 0;
setAttr ($p+".outlinerColor") 0 0 0;
opaqueBrush();
strokeRef0();
modelEditor -e -xr false modelPanel4;
select -cl;
}
}
}
/*
proc strokeRef1()
The procedure to select all polygon geometry in the scene and turn reference mode ON.
*/
proc strokeRef1()
{
SelectAllStrokes;
string $strokes[] = `ls -sl`;
string $s;
for ($s in $strokes)
{
int $mode = `getAttr ($s+".overrideDisplayType")`;
if ($mode==0)
{
setAttr ($s+".overrideEnabled") 1;
setAttr ($s+".overrideDisplayType") 2;
setAttr ($s+".useOutlinerColor") 1;
setAttr ($s+".outlinerColor") 1 0 0;
//select -cl;
}
}
}
/*
proc strokeRef0()
The procedure to select all polygon geometry in the scene and turn reference mode OFF.
*/
proc strokeRef0()
{
SelectAllStrokes;
string $strokes[] = `ls -sl`;
string $s;
for ($s in $strokes)
{
int $mode = `getAttr ($s+".overrideDisplayType")`;
if ($mode==2)
{
setAttr ($s+".overrideEnabled") 0;
setAttr ($s+".overrideDisplayType") 0;
setAttr ($s+".useOutlinerColor") 0;
setAttr ($s+".outlinerColor") 0 0 0;
//select -cl;
}
}
}
/*
proc opaque()
The procedure to turn the transparency of the brush in the scene off.
*/
proc opaqueBrush()
{
string $brush[] = `ls -type "brush"`;
string $b;
for ($b in $brush)
{
setAttr ($b + ".transparency1") -type double3 0 0 0;
}
}
/*
proc clear()
The procedure to turn the transparency of the brush in the scene on.
*/
proc clearBrush()
{
string $brush[] = `ls -type "brush"`;
string $b;
for ($b in $brush)
{
setAttr ($b + ".transparency1") -type double3 .5 .5 .5;
}
}
/* To call the command, use the following line*/
Worms();
Solved! Go to Solution.