I'm new in python. I try to make a button in Maya that increments the value of the crease edges. Each time I click on it I want to make +1 to the crease value.
I tried this :
def crease(ignore):
value=+1
newvalue = value
for i in value(int(newvalue)+1):
maya.cmds.polyCrease(i)
But it doesn't work. If somebody could help I really appreciate any help you can provide
It's a problem of nesting values, when your value is under a def, it is not not stored in the global scope.
counter = 0
def crease(ignore):
value = counter+1
maya.cmds.polyCrease(v=i)
return value
counter = crease(0)
if you want to keep track of the counter, you can create a global : Can not increment global variable from function in python
a dict : python modify a dictionary inside a method
or even a class.