Websterek
Websterek

Reputation: 39

pymel how to get right type of selected node

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

Upvotes: 0

Views: 1647

Answers (1)

haggi krey
haggi krey

Reputation: 1978

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().

Upvotes: 1

Related Questions