I have been trying to figure this out with deepseek and its just going around in circles. It thinks I want to change what camera position to set when I lick on “default view”, maya wide; I am only interested in determining how to do this per scene.
Just to be clear, I am trying to interactively set a default camera’s position, then run some command, then next time I click on “view” > “default view”, the camera is stored to position it was at when I run the command.
Somethings I tried;
camera -e -worldUpType "scene" persp;
// Error: Invalid flag '-worldUpType'
I also tried:
camera -perspective -edit
-position 0 10 20 // X,Y,Z position
-rotation -15 0 0 // X-rotation, Y-rotation, Z-rotation
-worldUpType "scene"
persp;
// Error: Invalid flag '-perspective'
Searching around I turned up with nothing as well. I thought this would a simple task in mel or Python, but am at a loss.
Am I right in thinking you want to overwrite the camera’s “default” home position with your own? You can’t exactly do this per se, at least not how you might think.
Every camera node has an attribute called .homeCommand
. This is the (MEL) code run whenever you send the camera to its “default home”. If you query the default persp
cam:
cmds.getAttr("persp.homeCommand")
you will see it return:
# Result: viewSet -p %camera #
If you look up the viewSet
command in the docs you will see the -p
flag sets the given camera to the default “perspective” position (and there are no params for this).
What you can do, if this is indeed what you want, is simply put your own code on to any camera’s .homeCommand
attr:
cmds.setAttr("persp.homeCommand", "polyCube", type="string")
And now, if you hit View > Default View or press Home
, the persp camera doesn’t move, it just creates a cube at the origin!
(don’t do that)
2 Likes
Very informative, thank you. I have so many use cases for this kind of “overriding”, its perfect.
Also, I will save this one for future office shenanigans. 