Transparency Toggle

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

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

maybe have a look at this digital tutors video

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..

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

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

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

Miguel

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

Miguel

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)

The tutorial you gave was very helpfull, thanks man!!
Im using xray

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?

I knew that you want to do that!! I knew it!!

Thanks man very helpfull, great forum!!

Hi Everybody

Its cool dude,,,,good link

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
{
    string $sel[] = ls -sl -ap -dag -type surfaceShape;
    for ($s in $sel)
    {
        int $xRayState[] = displaySurface -q -xRay $s;
        displaySurface -xRay (!$xRayState[0])$s;
    }
}

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

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!! :stuck_out_tongue_winking_eye:) 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

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...

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

but joojaa is unbeliveable

regds

o.S.k

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!!