To check the type of an object, use the following command:
Will result in
Lets see an example:
Why is this object a list? Remember that objects return lists, we saw previously that printing a variable which contains an object results in something like this:
[…] = Square brackets mean that this is a ‘list’ containing one or more strings.
u = Unicode string, we can ignore this, its something that Maya does.
pCube1 = The name of the cube object itself.
polyCube1 = The name of the Maya node that created the cube.
We extract the single object by using the array selector in a new variable:
newVariable = cube
Resulting in ‘pCube1’
With that in mind how do we get the type of the object within the list? We do this by using the position selector (in square brackets). Lets say we created a circle:
circle = cmds.circle()
Writing type(circle) will return ‘list’, so isn’t quite what we are after. Lets be more selective in whatwe want to know the ‘type’ of:
circle = cmds.circle() type(circle)
We are now asking ‘What is the typeof the thingat position 0 in the circle() list?’. Let’s run this code and see the output:
Hang on? The type is an encoding standard and not something 3D’ish? What’s the craic!?
Well Unicode is a type of string, so we may as well just refer to this as a string.
Maya makes ALL strings Unicode, because that’s how its handled under the hood