Set Attributes Mel Problem


#1

Hello guys,

I just wonder if you can help me with this.

In MaYa 2017 doesnt work anymore this mel script.

string $sel[] = ls -sl;
for ($i = 0; $i < size($sel); $i++)
{
setAttr ($sel[$i] + “.visibleInReflections”) 1;
setAttr ($sel[$i] + “.visibleInRefractions”) 1;
};

Do you know the reason?

Any advice or help will be much appreciate.

Cheers!


#2

The attribute ‘visibleInReflections’ exists on the shape node, so if you were selecting transforms then that script would fail.

You could try finding the shapes from the selected transforms and then setting the value like so:

string $sel[] = `ls -sl`;
for ($i = 0; $i < size($sel); $i++)
{
	string $shapes[] = `listRelatives -s $sel[$i]`;
	for ($j = 0; $j < size($shapes); $j++){
		setAttr ($shapes[$j] + ".visibleInReflections") 1;
	};
};

Hope that helps!


#3

Hi mlefevre,

Thank you for replying to this issue I have.
I will have a look and try it.

Thnx a bunch!

EDIT:
Hi mlefevre!
Thank you very much for your help.
Your changes or script work perfect!

Thnx a lot!
Cheers!