Dashboard_avatar
Mar 12, 2012
Post id: 309770 Report Item











1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


global string $isolate_original;
global int $remember;
 
// source isolate.mel; isolate;
 
global proc isolate(){
 
global string $isolate_original;
global int $remember;
string $current = `editRenderLayerGlobals -q -currentRenderLayer`;
string $default = "defaultRenderLayer";
string $visPanel[] = `getPanel -vis`;
 
if (size($visPanel)>0)
{
for ($panel in $visPanel)
if (`match "^modelPanel" $panel`=="modelPanel")
{
if ($current!= $default)
{
 
$mode=`modelEditor -q -viewSelected $panel`;
enableIsolateSelect $panel (!`isolateSelect -q -state $panel`);
editRenderLayerGlobals -currentRenderLayer $default;
$isolate_original = $current;
}
else
{
$mode=`modelEditor -q -viewSelected $panel`;
enableIsolateSelect $panel (!`isolateSelect -q -state $panel`);
 
if (size($isolate_original) == 0)
$isolate_original = $default;
 
editRenderLayerGlobals -currentRenderLayer $isolate_original;
}
}
}
}




 


Hi there, 

I've written the above code. As you may know, Maya does not isolate an object when on a Render Layer. As someonw who uses them a lot it is very annoying.

I've attempted to write a script that will toggle back to the defaultRednerLayer, isolate an object and then toggle back to the previous render layer.

Everything is working as expected....however when going back to the defaultRenderLayer, the script still remembers the global string from previous excecution.

Is there a way to clear a global string on a 2nd excecution of a script? Or am I totally doing everything the wrong way and in fact there is possibly a better way to approach this whole thing?

This is beginning to reach the limits of my MEL capability. :(( 

Spawn-1456
Mar 15, 2012
Post id: 309782 Report Item

You could make your global string variable a global string Array with one entry.

Then use the "clear" Mel command to reset it to an empty array. 


 I would put this action first so it would reset the variable before doing the rest of the script

Hope this wiil help. 

Dashboard_avatar
Mar 16, 2012
Post id: 309785 Report Item

Cool idea, thanks Pilou. Seems to work for me now. 

When I meant Isolate selected objects on render layer not working, I meant things like faces which does not work! 












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41


global string $isolate_original[];
 
// source isolate.mel; isolate;
 
global proc isolate(){
 
global string $isolate_original[];
string $current = `editRenderLayerGlobals -q -currentRenderLayer`;
string $default = "defaultRenderLayer";
string $visPanel[] = `getPanel -vis`;
 
if (size($visPanel)>0)
{
for ($panel in $visPanel)
if (`match "^modelPanel" $panel`=="modelPanel")
{
if ($current!= $default)
{
$mode=`modelEditor -q -viewSelected $panel`;
enableIsolateSelect $panel (!`isolateSelect -q -state $panel`);
editRenderLayerGlobals -currentRenderLayer $default;
$isolate_original = { $current };
 
 
}
else
{
$mode=`modelEditor -q -viewSelected $panel`;
enableIsolateSelect $panel (!`isolateSelect -q -state $panel`);
 
if (size($isolate_original[0])==0)
editRenderLayerGlobals -currentRenderLayer $default;
else
editRenderLayerGlobals -currentRenderLayer $isolate_original[0];
 
clear $isolate_original;
}
}
}
}