Better way to select a object by it's verts?

18 views
Skip to first unread message

I73

unread,
Sep 20, 2016, 4:14:42 PM9/20/16
to Python Programming for Autodesk Maya
selectedObject = cmds.ls( selection=True)
dagObject = selectedObject[0].split('.')[0]
cmds.select(dagObject)

Currently I am able to return the dag object by using a split method, is there a cleaner way of doing this?

Marcus Ottosson

unread,
Sep 20, 2016, 4:27:41 PM9/20/16
to python_in...@googlegroups.com
Have a look at passing objectsOnly=True to the ls() function.
--
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/b36e49be-3d5b-4969-8175-c6468b3acd18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wesley Keeling

unread,
Sep 20, 2016, 4:31:42 PM9/20/16
to python_in...@googlegroups.com
Unfortunately that does not work.
Sorry, I should have explained a little further. I need to start with selected objects verts from there I would like to grab the dag object from it's verts.

On Tue, Sep 20, 2016 at 1:27 PM, Marcus Ottosson <konstr...@gmail.com> wrote:
Have a look at passing objectsOnly=True to the ls() function.

On 20 Sep 2016, at 21:14, I73 <wesley....@iugome.com> wrote:

selectedObject = cmds.ls( selection=True)
dagObject = selectedObject[0].split('.')[0]
cmds.select(dagObject)

Currently I am able to return the dag object by using a split method, is there a cleaner way of doing this?

--
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_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/kQmQD76OsXY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0BA1BC98-E165-42B1-832D-C637D77CECE4%40gmail.com.

Marcus Ottosson

unread,
Sep 20, 2016, 4:45:32 PM9/20/16
to python_in...@googlegroups.com

Hm, that should work. Here’s an example that works for me in Maya 2016.

cmds.file(new=True, force=True)
cmds.polyCube()
cmds.select("pCube1.vtx[0]")
dag_object = cmds.ls(sl=True, objectsOnly=True)
cmds.select(dag_object)

Wesley Keeling

unread,
Sep 20, 2016, 4:49:19 PM9/20/16
to python_in...@googlegroups.com
FFS I don't know why it did not work the first time but yes that did it. Thanks so much!!! 

dagObject = cmds.ls( selection=True, objectsOnly=True)
cmds.select(dagObject)

--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/kQmQD76OsXY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.

Marcus Ottosson

unread,
Sep 20, 2016, 4:56:17 PM9/20/16
to python_in...@googlegroups.com
Don't mention it, glad it worked!​
Reply all
Reply to author
Forward
0 new messages