0

I'm starting exploring python in maya (pymel) and I have a problem with getting right type of selected object.

In outliner I have selected camera but when I'm executing code below it's returning type "transform". How to get right type ("camera")?

from pymel.core import *

selection = ls(sl=True)

print(selection[0].nodeType())

enter image description here

Websterek
  • 39
  • 5

1 Answers1

1

The camera construct is a combination of a transform node and a shape node. You selected the transform node so the output is correct. Either select the shape node below (make shapes visible in the outliner display menu) or simply do a selection[0].getShape().

haggi krey
  • 1,885
  • 1
  • 7
  • 9
  • yep it works thanks, `selection[0].getShape().nodeType()` just returns "camera" – Websterek Oct 08 '19 at 09:23
  • if your script is specificly looking for camera, you can selection = ls(sl=True, type='camera') and then use cam[0].getTransform() if you need to manipulate the transform – DrWeeny Oct 09 '19 at 16:09