I still don't understand comparison between the current item from the
selection and "myObj*". Can objects actually have a literal * in their name
in Maya? When would this check actually pass?

On Sat, Apr 8, 2017, 3:32 PM Alok Gandhi <alok.gandhi2...@gmail.com> wrote:

> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMRcHUhvyCagcMLrKEDqrFEMWUav7PQrXzv0jpL%2BsOMzQQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMRcHUhvyCagcMLrKEDqrFEMWUav7PQrXzv0jpL%2BsOMzQQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CAPGFgA08s0K9dG93DkQxzrDkV-Xc309eWm2r8u4cABftTN05AQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to