# Transparency Toggle

**URL:** https://forum.highend3d.com/t/transparency-toggle/3360
**Category:** Maya
**Tags:** mel
**Created:** [January 25, 2006, 1:05pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360 "2006-01-25T13:05:17Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 25, 2006, 1:05pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/1 "2006-01-25T13:05:17Z")

</div>

Im having problems with a transparency toggle.  
Its based in an existing one for maya 6.0.

string $objectSelected[] = `ls -sl`;

string $shaderQuery;

$shaderQuery = `hyperShade -o $objectSelected[0]`;

setAttr ($shaderQuery+".transparency") -type double3 .5 .5 .5;

select -r $objectSelected[0];

But im having problems with the query, i want a query that can return the name of the material of the selected object, and then change the transparency values someone can help me with this?  
I think the -o flag is wrong but i dont know what flag i can use to retrieve the name of the material.

Thanks in advance,

Miguel

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 25, 2006, 2:01pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/2 "2006-01-25T14:01:12Z")

</div>

Do you want something like an x-ray-view on selected objects??

maybe have a look at this [digital tutors video](http://www.digital-tutors.com/digital_tutors/display_video_details.php?videoX=187)

Or what do you want to achieve?  
Note that you may have a texture on the selected surface and you may not access the transparency value if its connected to a texture node.

however:  
hyperShade -o selects objects that have the given shader assigned. You cannot querry the shader(s) on the selection with that (as the Maya-docs say). Furthermore its impossible to querry shaders on the selection directly with the hyperShade command.

What you can do is hyperShade -smn. That replaces the selection with the shader(s) that are assigned to the former selection. Now you can do a ls -sl and you have the shader(s).

That may work for the first..

---

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 25, 2006, 2:07pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/3 "2006-01-25T14:07:50Z")

</div>

i tryed -smn because de script for maya 6 uses that, but dont work in maya 5.0.  
I think in maya 5.0 we have to use another flag instead of -smn.  
But i dont know what flag.

With the -smn flag gives me this error:  
// Error: Invalid flag: -smn //  
// Error: No object matches name: .transparency //

Thanks,  
Miguel

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [January 25, 2006, 2:16pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/4 "2006-01-25T14:16:27Z")

</div>

Hi Frnd

Try this code

CODE  
string $objectSelected[] = `ls -sl`;  
string $shaderQuery;  
$shaderQuery = `hyperShade -smn $objectSelected[0]`;  
string $newShsp[] = `ls -selection -materials`;  
string $getMtName=$newShsp[0];  
setAttr ($newShsp[0]+".transparency") -type double3 .5 .5 .5;  
select -r $objectSelected[0];

regds

o.S.k

---

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 25, 2006, 2:19pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/5 "2006-01-25T14:19:21Z")

</div>

Still dont recognize the -smn flag, but thanks anyway.

Miguel

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [January 25, 2006, 2:21pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/6 "2006-01-25T14:21:44Z")

</div>

QUOTE(Miguel22 @ 01/25/06, 06:19 AM) [snapback]226092[/snapback]  
Still dont recognize the -smn flag, but thanks anyway.

Miguel

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 25, 2006, 2:41pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/7 "2006-01-25T14:41:02Z")

</div>

you can still do it the shading-group-style..

that should work in every maya:  
have a look at the hypergraph: at every shape should be a shadinggroup attached. But I don't know to query them all... sometimes there are these green arrows with the double divided attribute path: eg:  
pCubeShape3.instObjGroups[0].objectGroups[1];

If you have all the shadinggroups on a surface you have also the shaders:  
shader.outColor --\> shadingGroup.surfaceShader.

(Brute force you could query all SGs for the faces they supply and substract the faces you don't have selected.. but I guess there IS a better way)

---

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 25, 2006, 2:46pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/8 "2006-01-25T14:46:48Z")

</div>

The tutorial you gave was very helpfull, thanks man!!  
Im using xray ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 25, 2006, 3:12pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/9 "2006-01-25T15:12:28Z")

</div>

Hahaaa!! have a look at good ol Brian Ewerts website:

[MEL How-To #43 How do I get the assigned Shading Group for an object or face component?](http://www.ewertb.com/maya/mel/mel.php?howto=43)

![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/biggrin.gif) I knew that you want to do that!! I knew it!!

---

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 25, 2006, 3:14pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/10 "2006-01-25T15:14:28Z")

</div>

Thanks man very helpfull, great forum!! ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [January 25, 2006, 3:25pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/11 "2006-01-25T15:25:43Z")

</div>

Hi Everybody

Its cool dude,,,,good link

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 25, 2006, 4:53pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/12 "2006-01-25T16:53:27Z")

</div>

Ahhh Miguel22?!?

Note that the dude in the video didn't pack the script into "{...}"!! If you run this, there might be other scripts having trouble.: btw here its a lil shoter:

CODE  
{  
&nbsp;&nbsp;&nbsp;&nbsp;string $sel[] = `ls -sl -ap -dag -type surfaceShape`;  
&nbsp;&nbsp;&nbsp;&nbsp;for ($s in $sel)  
&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int $xRayState[] = `displaySurface -q -xRay $s`;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;displaySurface -xRay (!$xRayState[0])$s;  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

---

<div class="post-metadata">

### Author: ![majc22](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/m/96bed5/32.png) [@majc22](https://forum.highend3d.com/u/majc22)
#### Post date: [January 26, 2006, 1:02pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/13 "2006-01-26T13:02:19Z")

</div>

Thx man you understand alot about MEL, where did you learned?

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 30, 2006, 2:52pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/14 "2006-01-30T14:52:32Z")

</div>

All by myself. Being interested in Maya. Being Lazy on the one hand and enthusiastic on the other to write stuff that makes your maya experience a lot more dynamic. (I'm a context-sesitivity and Hotkey-addicted!! 😜) Usually I spend a lot more time trying out stuff that helps me to save less time. But after all you learn and learn... ;]

furthermore: listen to and read code from: Joojaa, Naughty, failure, Rob Bateman, Brian Ewert... _rolleyes_ ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/biggrin.gif)

Someday you write a script an wonder why it really executes and works at the first time!! No Error? .. I was so baffled that I made it crash in a next attempt to see if everything is ok...

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [January 30, 2006, 5:51pm UTC](https://forum.highend3d.com/t/transparency-toggle/3360/15 "2006-01-30T17:51:30Z")

</div>

Hey everybody

Crazy man now you can add your name also in that line

"furthermore: listen to and read code from: Joojaa, Naughty, failure, Rob Bateman, Brian Ewert..."

and ewerybody ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/biggrin.gif)

but joojaa is unbeliveable ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/biggrin.gif)

regds

o.S.k

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [January 31, 2006, 11:11am UTC](https://forum.highend3d.com/t/transparency-toggle/3360/16 "2006-01-31T11:11:07Z")

</div>

naa.. I wouldn't presume to do that.. ;]

what I forgot : From our companys Head of Programmers I learned that codingstyle is worth the while!!
