here are two more ways to add to the ways listed here. import pymel.core as pm # pm.selected returns a list of selected itemsfor x in pm.selected():
# if you can get a shape node continue if x.getShape(): # if the shapenode type is mesh then the test is good if x.getShape().nodeType() == 'mesh': print("Yep {0} is indeed a polygon mesh".format(x)) # returning only a list of meshes selected. # same as above but uses a fancy pants list comprehension justMeshes = [y for y in [ x for x in pm.selected() if x.getShape()] if y.getShape().nodeType() == 'mesh'] On Fri, May 6, 2016 at 2:38 PM, simonp91 <simon...@gmail.com> wrote: > You can use a nodeType query, but remember, a transform node can contain > more than one shape node. Also, you might want to query multiple selected > objects. Not at the machine for syntax testing, but it would look something > like this : > > import pymel.core as pm > for o in pm.ls(selection=True): > for shp in pm.listRelatives(o, children=True, sh=True): > if pm.nodeType(shp, q=True)=='mesh': > print '%s is a poly mesh' % shp > > ...can't remember off the top of my head if you need an extra flag in the > nodeType query to return its proper type, but if it doesn't return the > mesh/es, just check the command in the maya python docs (is the same in > maya cmds and pymel) and you'll see straight away. > > Simon > > Sent from my iPhone > > > On 6 May 2016, at 21:54, s...@weacceptyou.com wrote: > > > > Hi sorry, im guessing this is a simple one. But just wanted to know the > simplest way of doing this. > > > > i want to check that the object i have selected is a polygon mesh. I > assumed i had to use the 'objectType' command. but it seems you have to > provide the name of the shape node of the object first. If there is a pymel > way of doing it that is also fine, > > > > any help would be great, > > thanks, > > Sam > > > > -- > > 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+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/3a332d6c-0659-4d67-98e1-9b2caabeb760%40googlegroups.com > . > > 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 python_inside_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/DD09D5E0-531D-4323-93CD-5AA9B9572DA0%40gmail.com > . > 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 python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABPXW4hJKguY%3DoxOL-tPF__qMR8oragBXK2XS_7AhLkjMGifAA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.