How to test if my selection is a face or an edge ?

452 views
Skip to first unread message

Sam555

unread,
Oct 16, 2014, 4:00:12 AM10/16/14
to python_in...@googlegroups.com


Hello guys,
i'm quite new to python pymel in Maya and i want to do a simple thing as testing if my selection is a face or a edge.
Searching the net i saw that you can either use the filterexpand() or using something like a hack (if "MeshVertex" in selection[0].__repr__()), is there a more simple and straightforward way to do this simple test ? 

What i'am simply trying to achieve :

if selection is a face or a edge :
    do something

Thanks for your help.

Marcus Ottosson

unread,
Oct 16, 2014, 4:34:35 AM10/16/14
to python_in...@googlegroups.com

You can use isinstance.

from pymel import core

# Select a vertex
selection = core.ls(sl=1)[0]
if isinstance(selection, core.MeshVertex):
    print "Selection is a vertex"

--
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/541bf09a-a92c-4aa8-b9d4-ec31bb5141d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Sam555

unread,
Oct 16, 2014, 9:36:05 AM10/16/14
to python_in...@googlegroups.com
Thank you, 
so simple and elegant, i'am learning a lot.

Thanks again. 

Solved.
Reply all
Reply to author
Forward
0 new messages