Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Henrik_Cederblad
205 Views, 1 Reply

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

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

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;

}

 

 

 

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

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. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report