Ah and I forgot to mention, you should not use `myobj` for both the pattern
matching and object in selection. It makes the code less clear. Better to
use some other name. Here's what I suggest:
def delcube(self, *args):
sel = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False)
todelete = "myCube*"
for myobj in sel:
if myobj == todelete:
try:
cmds.delete(myobj)
except ValueError:
# Shape Node already deleted
pass
also notice that the try, except should be inside the loop otherwise the
for loop will run only once.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMRcHUhvyCagcMLrKEDqrFEMWUav7PQrXzv0jpL%2BsOMzQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.