# Toggle image plane visibility?

**URL:** https://forum.highend3d.com/t/toggle-image-plane-visibility/5813
**Category:** Maya
**Tags:** mel
**Created:** [September 26, 2002, 9:16am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813 "2002-09-26T09:16:39Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 26, 2002, 9:16am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/1 "2002-09-26T09:16:39Z")

</div>

Hello mel guru, or any other mel users... ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)  
I was wondering how I could get the image to toggle between the position "none" to "Rgb"..  
I understand the principle stuff..like I have to get the current window then the image plane but how can i check to see if the current camera as an image plane and if yes it make its visibility to none or Rgb...  
I'm almost there but stuck..  
someone can help.?

cheers and thanks for all

---

<div class="post-metadata">

### Author: ![user\_deleted](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/u/35a633/32.png) [@user\_deleted](https://forum.highend3d.com/u/user_deleted)
#### Post date: [September 26, 2002, 9:53am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/2 "2002-09-26T09:53:49Z")

</div>

To list Image planes connected to camera - perspSHape should be your camera shape node:  
listConnections -source 1 -type imagePlane perspShape;

To set display mode to none:  
setAttr imagePlane1.displayMode 0;

To set display mode to none:  
setAttr imagePlane1.displayMode 2;

hope it helps

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 26, 2002, 1:16pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/3 "2002-09-26T13:16:02Z")

</div>

thanks a lot I'll try to go with that if I can figure out the rest..

many thanks

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 26, 2002, 2:24pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/4 "2002-09-26T14:24:37Z")

</div>

well thanks but I guess I'm still stuck cause I don't know how to use that..it seems that the listSelection only list it but to use the setAttr I need to select it don't I..?  
(I know I suck in mel)..progrmming really isn't my stuff..but I understand the need of learning so that's what I'm doing..

thanks a lot for the help.

---

<div class="post-metadata">

### Author: ![user\_deleted](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/u/35a633/32.png) [@user\_deleted](https://forum.highend3d.com/u/user_deleted)
#### Post date: [September 26, 2002, 3:13pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/5 "2002-09-26T15:13:54Z")

</div>

I don't know if you have a specific use for the imageplane, but theMaya UI is often quicker with a texturemapped plane parented under the camera - and this would be easily hidden/unhidden....

just an idea

---

<div class="post-metadata">

### Author: ![deane](https://forum.highend3d.com/user_avatar/forum.highend3d.com/deane/32/58795_2.png) [@deane](https://forum.highend3d.com/u/deane)
#### Post date: [September 26, 2002, 5:03pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/6 "2002-09-26T17:03:00Z")

</div>

Here is a mel I wrote to do just that:  
//Start mel script code  
//==========================  
/\* Image Plane Toggle

* * *

## Toggles the visibility of all Image Planes in your scene

* * *

Any bugs or problems, send them to  
[mhovland@midwaygames.com](mailto:mhovland@midwaygames.com)

* * *

\*/  
//Start of IP\_Toggle Script

global proc mh\_IP\_Toggle()  
{  
 // INTERFACE STUFF//  
 //kill the window if it exists already

if (`window -exists iptWindow`)   
 {   
 deleteUI -window iptWindow;   
 }

```
//define the window
```

string $iptWin = `window -title "Image Plane Toggle"	-widthHeight 210 105	-tlc 150 150	-sizeable false iptWindow`;

```
//column layout for the window							
```

columnLayout;

```
//define some buttons							
```

button  
 -label "Hide Image Planes"  
 -width 200  
 -height 25  
 -command "hideEm"  
 hideBtn;

button   
 -label "Show Image Planes"  
 -width 200  
 -height 25  
 -command "showEm"  
 showBtn;

```
//END INTERFACE STUFF//
```

showWindow $iptWin;  
}

//Some procedures for the buttons to do  
global proc hideEm()   
 {   
 string $ipHideIndex;   
 string $ipHideVar[] = `ls -type imagePlane`;

```
if (size($ipHideVar) == 0)

	error ("==No Image Planes in your Scene==");

	for ($ipHideIndex in $ipHideVar) 
	{ 
		setAttr ($ipHideIndex+".displayMode") 0; 
	} 
}
```

global proc showEm()   
 {   
 string $ipShowIndex;   
 string $ipShowVar[] = `ls -type imagePlane`;

```
if (size($ipShowVar) == 0)

	error ("==No Image Planes in your Scene==");

	for ($ipShowIndex in $ipShowVar) 
	{ 

		setAttr ($ipShowIndex+".displayMode") 3; 
	}

}
//End button procedures
```

//================================  
//end mel script code

This is one of my first scripts with an interface, so it may not be the best implimentation, but it works just fine.

Use it all you want, if you make adjustments to it, send them back my way.

Enjoy,

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 27, 2002, 6:12am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/7 "2002-09-27T06:12:29Z")

</div>

Ok I wasn't expected that much..but this is great I'm gonna start looking at it to figure some stuff out ..

thanks a lot guys..

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 27, 2002, 7:11am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/8 "2002-09-27T07:11:12Z")

</div>

Ok thanks to you guys i understood few thing,  
now I went quickly to make my toogle  
and i end up with that..  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
string $ipHideIndex;   
string $ipHideVar[] = `ls -type imagePlane`;

if (size($ipHideVar) == 0)

error ("==No Image Planes in your Scene==");

for ($ipHideIndex in $ipHideVar)   
{   
if ($ipHideIndex+"diplayMode" ==3)  
{  
setAttr ($ipHideIndex+".displayMode") 0;   
}   
else  
{  
setAttr ($ipHideIndex+".displayMode") 3;  
}  
}  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

So it worked but ONLY THE FIRST TIME I USED IT !!!!

now I don't get it, it doesn't work at all anymore but doesn't do any errors...so a little help again if you can

thanks so much, I'm learnig a lot

---

<div class="post-metadata">

### Author: ![latrommi\_suineg](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/l/e99b99/32.png) [@latrommi\_suineg](https://forum.highend3d.com/u/latrommi_suineg)
#### Post date: [September 27, 2002, 12:03pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/9 "2002-09-27T12:03:18Z")

</div>

i dont know if its a help... but generally i specify the rendering camera from the start and call it renCamera... which means that i can capture a command from the script editor and create a hot key for it...

in the past ive made a toggle alpha (of image plane) with a seperate 50% alpha switch which would allow for semi trans view...

its hardly code but its quicker than sourcing a script...

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [September 30, 2002, 8:03am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/10 "2002-09-30T08:03:20Z")

</div>

thanks for the tip, but I was very curious about the particular problem I have in the above post...

anyone ???

thanks anyway everybody

cheers

---

<div class="post-metadata">

### Author: ![campbell](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@campbell](https://forum.highend3d.com/u/campbell)
#### Post date: [October 2, 2002, 2:36pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/11 "2002-10-02T14:36:41Z")

</div>

cant directly read/write attributes with MEL scripting, you mostly can in the context of an expression node however.

so you gotta collect the attribute value for comparison:

if (`getAttr ($node+".attri")` == x)

not sure why your syntax was parsed, but that it was meant that it would do the else... even tho it lacks the capacity to resolve whether the conditional ever were true. dunno.

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [October 3, 2002, 7:26am UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/12 "2002-10-03T07:26:35Z")

</div>

Ok thanks a lot I'll try that...  
Still it's weird for me that it only works once...

cheers

---

<div class="post-metadata">

### Author: ![thematt](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@thematt](https://forum.highend3d.com/u/thematt)
#### Post date: [October 3, 2002, 12:36pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/13 "2002-10-03T12:36:44Z")

</div>

Ok I tried,  
It works great thanks a lot here's the code in case somebody is intrested...  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

global proc hideImagePlane()  
{  
string $ipHideIndex;   
string $ipHideVar[] = `ls -type imagePlane`;

if (size($ipHideVar) == 0)

error ("==No Image Planes in your Scene==");

for ($ipHideIndex in $ipHideVar)   
{  
if (`getAttr ($ipHideIndex+".displayMode")`==3)   
{   
setAttr ($ipHideIndex+".displayMode") 0;   
}   
else if (`getAttr ($ipHideIndex+".displayMode")`==0)   
{   
setAttr ($ipHideIndex+".displayMode") 3;   
}   
}   
};  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

thanks so much everybody..

cheers

---

<div class="post-metadata">

### Author: ![mreyepoke](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@mreyepoke](https://forum.highend3d.com/u/mreyepoke)
#### Post date: [October 13, 2002, 4:18pm UTC](https://forum.highend3d.com/t/toggle-image-plane-visibility/5813/14 "2002-10-13T16:18:32Z")

</div>

This is the command I have for my hotKey:

$currentPanel = `getPanel -withFocus`;  
$state = `modelEditor -q -cameras $currentPanel`;  
modelEditor -edit -cameras (!$state) $currentPanel;

I found it somewhere. The interesting part it the $state. I found it really elegant, if 0 make it 1, if 1 make it 0. I used it for all my model panel hotkeys, wireframe on shaded, xray, etc.

You could use it in your proc if you query .visibility instead of .displayMode. That is what the -cameras flag above is doing. The attribute needs to be a boolean, 0 or 1.
