MEL: If Camera View is A then set it to B (and vice versa)

MEL: If Camera View is A then set it to B (and vice versa)

Henrik_Cederblad
Advocate Advocate
272 Views
1 Reply
Message 1 of 2

MEL: If Camera View is A then set it to B (and vice versa)

Henrik_Cederblad
Advocate
Advocate

I want to make a simple toggle-script that switches camera view states between A and B, eg. Top and Bottom. So if I'm in Top view, then it should switch to Bottom and vice versa. I'm not great at coding but keen to learn, so would appreciate some help.

 

Pseudo code:

 

 

 

 

$currView = <some way of retrieving the current 'camera view'>

If currView is "top" {

viewSet -bottom;

}

else

{

viewSet -top;

}

 

 

 

0 Likes
Accepted solutions (1)
273 Views
1 Reply
Reply (1)
Message 2 of 2

manuel.spkDKCCG
Contributor
Contributor
Accepted solution

Hi Henrik

I don't know how to do It in Mel, but in python this would do the trick (also, not sure if It's the best way to accomplish It)

currentCamera = cmds.lookThru(q=True)
print (currentCamera)

if currentCamera=="top":
    cmds.lookThru(currentCamera, "bottom")
    
elif currentCamera=="bottom":
    cmds.lookThru(currentCamera, "top")

 

Make sure you cameras are named like this ("top" and "bottom"). If not, just change the literals in the code. Translating this to Mel, should not be a hard task.