This may be slightly stupid but I wanted to ask how do I list out all cameras (either imported/created and hidden or not) with the exception of the default ones?
I tried out persistentNodes where in the documentation, it states Returns persistent nodes, which are nodes that stay in the Maya session after a file > new
allCams = cmds.ls(type='camera', pn = 1)
However, if I used it, it will not show anything. Should I change it to pn = 0, this time round there are results but it is inluding in the persp/front/side/top which is not what I wanted.
I couldn’t get the -persistentNodes flag to return anything for me, using mel or python.
The default cameras are marked as “startup cameras” by maya. This attribute of a camera can be changed, so if someone has messed with it, or set other cameras as a startup camera, then you will get different results. That being said it’s the most consistent method of returning the default cameras that I know of aside from hard-coding the names.
nonStartup = [c for c in cmds.ls(cameras=True) if not cmds.camera(c, q=True, startupCamera=True)]
[QUOTE=sciloop;25678]Ah, I misunderstood your question. Thought you wanted only the persistent cameras…
In Mel, the ‘pn’ flat is not a boolean. Its mere existence means you want it to be active.
So you can do:
ls( "-pn", "-type", "camera" );
[/QUOTE]
Hi sciloop, try out the mel code, but I am not getting anything out of it
[QUOTE=capper;25713]I couldn’t get the -persistentNodes flag to return anything for me, using mel or python.
The default cameras are marked as “startup cameras” by maya. This attribute of a camera can be changed, so if someone has messed with it, or set other cameras as a startup camera, then you will get different results. That being said it’s the most consistent method of returning the default cameras that I know of aside from hard-coding the names.
nonStartup = [c for c in cmds.ls(cameras=True) if not cmds.camera(c, q=True, startupCamera=True)]
[/QUOTE]
Hi capper, as mentioned in my first post, the persistentNodes also does not seems to be working in python for me… But I never knew that there is a flag called ‘startupCamera’… Works great in my cause as well.
Just wondering where or how do you derive the ‘startupCamera’?
startupCamera is an attribute that can be set on a camera. From the docs:
A startup camera is marked undeletable and implicit. This flag can be used to set or query the startup state of a camera. There must always be at least one startup camera.
You can remove the startupCamera setting from any of the default (persp, front, etc) cameras, and make any user-created cameras a startupCamera. Because of that it’s not a guarantee that you’ll get the 4 default ones, but it’s probably your best shot outside of hardcoding the names.
[QUOTE=capper;25731]startupCamera is an attribute that can be set on a camera. From the docs:
You can remove the startupCamera setting from any of the default (persp, front, etc) cameras, and make any user-created cameras a startupCamera. Because of that it’s not a guarantee that you’ll get the 4 default ones, but it’s probably your best shot outside of hardcoding the names.[/QUOTE]
Hi capper, thanks a lot of the information. My bad on this as I must have missed reading it in the camera docs (overwhelmed by the list of flags it have) and this is definetely better than the hardcoded ones that I did.