How can I change one object only when another is selected?


#1

Good Day people!! I’m currently browsing MEL and expressions …
and trying to do something like this: if I select one object I deactivate one property from another …
but I’m having problems with the object selection denomination … The following is an example … .

If (select pCube1-r on)
{
PCube2.visibility = 0;
}

I have tried with strings too but it didn’t work…

global proc myscript()
{
string $a[] = ls -sl;

if ($a[0] == “pCube1”)

hide = “pCube2”;

else;
}

scriptJob -e"SelectionChanged"
“myScript”;

Can someone help? Obs: My English is not so good, sorry!

Thank you very much!!!


#2

I have tried this way and worked it!!

string $sel[] = ls -sl;
string $item;
for ($item in $sel)
{
if ($item == “pCube1”)
{
pCube2.translateX = 15;
}
if ($item == “pCube3”)
{
pCube2.translateX = 25;
}
}

But I still have a problem … it just work once… and I need it works everytime that the selection is changed…


#3

I have tried this way too…

global proc myScript()
{
string $sel[] = ls -sl;
string $item;
for ($item in $sel)
{
if ($item == “pCube1”)
{
pCube2.translateX = 15;
}
if ($item == “pCube3”)
{
pCube2.translateX = 25;
}
}
}

scriptJob -e"SelectionChanged"
“myScript”;