This result won't print. Not sure why.

21 views
Skip to first unread message

jettam

unread,
Aug 30, 2017, 2:48:45 PM8/30/17
to Python Programming for Autodesk Maya
The script below selects all objects found in a group. But, for some reason it doesn't want to print the result. Could someone explain why it doesn't print the result ?

cmds.select( instanceGroup )
result = cmds.select( cmds.listRelatives(cmds.ls(selection=True), children=True))
print result

jettam

unread,
Aug 30, 2017, 3:16:00 PM8/30/17
to Python Programming for Autodesk Maya
I found if I just removed a lot of that in bracket stuff then I was able to print the result.  The more complicated version I found online. Still not sure why it didn't print in the first place. 

cmds.select( instanceGroup )
result =  cmds.listRelatives()
print result

Justin Israel

unread,
Aug 30, 2017, 3:32:37 PM8/30/17
to Python Programming for Autodesk Maya

If you take a look at the docs for the select() command, you will see that it reports it has no return value :
http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/select.html

The following code is getting a None return value from the select() call:

result = cmds.select( cmds.listRelatives(cmds.ls(selection=True), children=True))

You are passing the results of listRelatives() to select(), which is what you wanted, but if you also want to print that return value then you want to capture it to a variable first:

result = cmds.listRelatives(cmds.ls(selection=True), children=True)
print result
cmds.select(result)


--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f56a8442-0955-4861-9c69-e437801cd2e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages