> > > I use the bug to ignore the error warning that i received .. like this ## > Error: ValueError: file <maya console> line 14: No object matches name: > myCube1Shape # > not sure whether I did the right thing or misuse the handling exceptions.
It is perfectly ok to `pass` exceptions if you know what you are doing. This is a known technique in python, sometimes referred to as EAFP (stands for `It's easier to ask forgiveness than permission`). You can find more information here <http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#eafp-vs-lbyl> . However, it is strongly advised not to use a bare `except`, which causes every exception to pass silently and not just the one you are anticipating. You should only except what you can handle. In your case, just use except ValueError: def delcube(self, *args): sel = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False) myobj = "myCube*" for myobj in sel: if myobj == myobj: try: cmds.delete(myobj) except ValueError: # Shape Node already deleted pass -- 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/CAPaTLMRDZ2ZFWRccJ%2Ba9t5QHtWEVgYTA%3DcETiZz6xYmyUR6EZg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.