Mayapython Incremental button that increment value
Clash Royale CLAN TAG#URR8PPP
Mayapython Incremental button that increment value
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
2 Answers
2
As it happens, cmds.polyCrease
includes a flag that does what you want:
cmds.polyCrease
cmds.polyCrease(rv=1)
will bump the crease value on the currently selected components by 1; a negative value will bump it down. A global counter works from a programming standpoint but it will probably have surprising results if you hop between different objects in the scene.
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.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.