I searched and tried out a few more stuff and manage to get the name of the 
object selection by doing the following:
for item in sel:
    print item

Was wondering if this is acceptable in Maya, despite I am getting the 
output I wanted?


On Wednesday, November 12, 2014 4:57:01 PM UTC+8, yann19 wrote:
>
> Hey there..
>
> Will this means that I have to use this Maya API thingy?
> Just googled online and it looks like a foreign language to me :O
>
>
> On Wednesday, November 12, 2014 4:52:37 PM UTC+8, Justin Israel wrote:
>>
>> Hi, 
>>
>> You are doing it correctly. What you are getting is a list of string 
>> (Unicode actuslly) results. The Maya commands api, just like the MEL 
>> counterpart, uses string paths to all object references. 
>>
>> If you are expecting a 1st node object, then you are probably thinking of 
>> the PyMel api which is an abstraction over the native Maya API to provide 
>> something more pythonic and object oriented. 
>>
>> The Maya API (derived from the C++ counterpart) also is more object 
>> oriented that the commands Mel api. 
>>
>> Basically, if you use the Python commands api, you pass around strings. 
>>
>> On Wed, 12 Nov 2014 9:46 PM yann19 <[email protected]> wrote:
>>
>>> Hi all, I just started learning Python and currently I am confused about 
>>> some stuff in Maya. Please do bear with me and my noob questions
>>>
>>> I am selecting on an object in which it is called pCube1 and so I run 
>>> the following code:
>>> sel = cmds.ls (selection = True)
>>> print str(sel)
>>>
>>> However, here I thought I am supposed to get the output result as 
>>> pSphere1 in my editor but yet I am seeing [u'pSphere1'] instead.
>>>
>>> Or am I doing it in the wrong way to grab the object name?
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/python_inside_maya/3d317cc5-4a5f-424a-9cb3-7ac5af4c040a%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/python_inside_maya/3d317cc5-4a5f-424a-9cb3-7ac5af4c040a%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/db5e7ecc-e2d3-4553-b9f9-7861b8305308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to