Created
January 13, 2024 18:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
######################################################################################################################## | |
AUTHOR: | |
Steffano Richi (steffano.richi@gmail.com) | |
https://encci20.blogspot.pe/ | |
16.04.2023 | |
DESCRIPTION: | |
Set Default Attr for float and integers | |
USAGE: | |
*Put in maya/scripts | |
*Run the next code in scriptEditor in Python | |
import wrSetDefault as wrSetDefault | |
wrSetDefault.ui() | |
######################################################################################################################## | |
""" | |
import maya.cmds as mc | |
def setDefault(self): | |
nodes = mc.channelBox('mainChannelBox',q=True,mol=True) | |
attrs = mc.channelBox('mainChannelBox',q=True,sma=True) | |
defV = mc.floatField('floatSetDefault',q=True,v=1) | |
for node in nodes: | |
for attr in attrs: | |
try: | |
mc.addAttr(node + '.' + attr,e=1,dv=defV) | |
except: | |
mc.warning('The ' + node + '.' + attr + ' can not set a default value') | |
def ui(): | |
w = 160 | |
h = 60 | |
if mc.window('wrSetDefaultValue',ex=True): | |
mc.deleteUI('wrSetDefaultValue') | |
mc.window('wrSetDefaultValue',t='Set Default',s=False,mxb=False,mnb=False) | |
mc.window('wrSetDefaultValue',e=1,w=w,h=h) | |
mc.columnLayout(adj=1,rs=8,cat=['both',20]) | |
mc.rowLayout(nc=2,adj=2) | |
mc.columnLayout(adj=1,rs=5) | |
mc.text(align='right',l='Value:',h=20) | |
mc.setParent('..') | |
mc.columnLayout(adj=1,rs=5) | |
mc.floatField('floatSetDefault',h=20,v=0) | |
mc.setParent('..') | |
mc.setParent('..') | |
mc.button(l='Set Default',bgc=[1, 0.5, 0],c=setDefault) | |
mc.showWindow('wrSetDefaultValue') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment