Toggle Camera Lighting


#1

Hello guys,

I’m trying to toggle (ON/OFF) the two sided lighting, but this is not working properly.
Do you have any idea why?
Do you have aby solution?

For any help thank you in advace.

Cheers!

//modelEditor -e -twoSidedLighting false modelPanel4;
string $selectedPanel = getPanel -wf;

string $twoSL = modelEditor -e $selectedPanel;

if(modelEditor -edit $selectedPanel)
{
if($twoSL == “twoSidedLighting”)
{
modelEditor -edit -twoSidedLighting true $selectedPanel;
}
else
{
modelEditor -edit -twoSidedLighting false $selectedPanel;
}
}


#2

You have a few problems there.

The biggest problem is the variable $twoSL. You are using an edit flag and a panel name, and that should throw you an error because you are trying to edit something but not specifying anything.

You should use a query, because you want to know the status of TwoSideLighting in that editor, so you can know if you want to switch it on, or off later.

The second is the if(modelEditor -edit $selectedPanel) part
That’s a big structure problem because you are giving a conditional to a command. Translating that to english would be something like this:

if edit an attribute from $selectedPanel.

Yes, It doesn’t make sense.

Although I really don’t like writing in mel, I think this should work

string $selectedPanel = `getPanel -wf`;
string $twoSL = `modelEditor -q -twoSidedLighting $selectedPanel`;
int $int_twoSL = (int)$twoSL;
modelEditor -e -twoSidedLighting (1 - $int_twoSL) $selectedPanel;

I’m converting the twoSideLighting value to an integer so we can just switch it in one line.


#3

OH !
IM SO SOOORY MATE !!!
Thank you for your reply.

Much appreciate !
Cheers !