No, sorry. That returns an error if *obj* happens to have no getShape() method, which is what i'm rying to check for...
On Tuesday, June 17, 2014 3:27:16 PM UTC-7, Kurian wrote: > > import maya.cmds as cmd > > import pymel.core as pm > > list = cmd.ls(sl=True) > > for obj in list: > > obj = pm.PyNode(obj) > > if obj.getShape(): > > print obj.getShape() > > Are you looking for this ? > > > On Tue, Jun 17, 2014 at 3:24 PM, Brian Eyre <brian...@googlemail.com > <javascript:>> wrote: > >> It's actually a function that returns the shape node, yes. Do I need a >> different syntax for that? obj.getShape() definitely works, which is why >> i'm puzzled. >> >> >> On Tuesday, June 17, 2014 3:20:19 PM UTC-7, Kurian wrote: >> >>> hasAttr will check only for existing attribute. >>> >>> import maya.cmds as cmd >>> >>> import pymel.core as pm >>> >>> list = cmd.ls(sl=True) >>> >>> for obj in list: >>> >>> obj = pm.PyNode(obj) >>> >>> print pm.hasAttr(obj,'tx') >>> >>> This will work and what is getShape ?, is it a function ? or is it >>> attribute which is existed in selected object ? >>> >>> >>> On Tue, Jun 17, 2014 at 3:08 PM, Brian Eyre <brian...@googlemail.com> >>> wrote: >>> >>>> Hi, >>>> >>>> I'm trying to add a line that error checks for whether the getShape() >>>> method exists for selected objects, by using *hasAttr*, but it keeps >>>> returning *false* even when getShape() exists for the obj: >>>> >>>> import maya.cmds as cmd >>>> import pymel.core as pm >>>> >>>> list = cmd.ls(sl=True) >>>> >>>> for obj in list: >>>> obj = pm.PyNode(obj) >>>> print pm.hasAttr(obj,'getShape') >>>> >>>> >>>> Any ideas?? >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> 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/0abb0814-ff47-42a9-9464- >>>> 5ce2f856dbee%40googlegroups.com >>>> <https://groups.google.com/d/msgid/python_inside_maya/0abb0814-ff47-42a9-9464-5ce2f856dbee%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> --:: Kurian ::-- >>> >> -- >> 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 <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/1637e11d-8553-4b2d-a79a-43ae0c0cfc27%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/1637e11d-8553-4b2d-a79a-43ae0c0cfc27%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > --:: Kurian ::-- > -- 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/dca48f87-4fa9-4f61-ab57-0182c9d6f16a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.