From a python standpoint, yes any value is allowed. From a Maya standpoint, as you expected Maya will use * as a wildcard to match objects.
Also, you have a bug in your example. obj is being shadowed by each value in your loop, so the assignment to "object*" has no effect.
Justin
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/308b9f75-c0d0-4fd4-b48c-0a63921ec08d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
From a python standpoint, yes any value is allowed. From a Maya standpoint, as you expected Maya will use * as a wildcard to match objects.
Also, you have a bug in your example. obj is being shadowed by each value in your loop, so the assignment to "object*" has no effect.
Justin
On Sat, Apr 8, 2017, 2:24 PM NAS18 <nurulm...@gmail.com> wrote:
Hello,--
May I know is it suitable to use * as variable valueThe purpose function is to delete an selected object that prefix with myobj* and delete it.thank you so muchregardsNurul
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+unsub...@googlegroups.com.
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.
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
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
passI 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?
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMRcHUhvyCagcMLrKEDqrFEMWUav7PQrXzv0jpL%2BsOMzQQ%40mail.gmail.com.
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?
def delcube(self, *args): todelete = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False) for obj in todelete: try: cmds.delete(obj)
I tried to use this snippet but it does not work..It does not give any error but it does not pass the functionality to the button .but if I use myobj==myobj like old one .it works.even though it is working but still not satisfied. i'm curious.
def delcube(self, *args): todelete = cmds.ls("myCube*", sl=True, dag=True, v=True, ud=False) for obj in todelete: try: cmds.delete(obj)
And to explain again why your snippet didn't work and the myObject==myObject always passes, consider this..
1==1
And then
x=1
x==x
Basically comparing a value to itself is always going to pass.
Justin
--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/1049c7e3-6afa-48e7-8579-7792713975a6%40googlegroups.com.