本文整理汇总了Python中maya.cmds.promptDialog函数的典型用法代码示例。如果您正苦于以下问题:Python promptDialog函数的具体用法?Python promptDialog怎么用?Python promptDialog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了promptDialog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: newModule
def newModule():
# MODULE NAME
result = mc.promptDialog(
title='New Module Name',
message='Enter Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if result == 'OK':
name = mc.promptDialog(query=True, text=True)
else: return
filename = mc.fileDialog2(fileMode=1, caption="Select module File")[0]
modGrp = mc.group(em = 1, n = name)
mc.parent(modGrp, 'modules')
mc.setAttr((addString('Name',modGrp)), name, type = "string")
mc.setAttr((addString('Module_Path',modGrp)), filename, type = "string")
# GET THE SCRIPT OF THE MODULE
print getModuleScript(name)
launch()
示例2: performTranferV1
def performTranferV1(self):
getMesh=cmds.ls(sl=1)
if len(getMesh)<2:
print "select a skinned mesh group and an unskinned target mesh group"
return
else:
pass
getMeshController=getMesh[0]
getMeshTarget=getMesh[1]
getChildrenController=cmds.listRelatives(getMeshController, c=1, typ="transform")
if getChildrenController==None:
getChildrenController=([getMeshController])
getChildrenTarget=cmds.listRelatives(getMeshTarget, c=1, typ="transform")
if getChildrenTarget==None:
getChildrenTarget=([getMeshTarget])
result = cmds.promptDialog(
title='find XML',
message="Enter path",
text="C:\Users\\"+str(getFolderName)+"\Documents\maya\projects\default\scenes\\",
button=['Continue','Cancel'],
defaultButton='Continue',
cancelButton='Cancel',
dismissString='Cancel' )
if result == 'Continue':
skinPath=cmds.promptDialog(q=1)
if skinPath:
pass
else:
print "nothing collected"
self.callJointsWin(getChildrenController, getChildrenTarget, skinPath)
示例3: make_geo_layer
def make_geo_layer(geos):
if not geos:
return False
print('// make_geo_layer(geos)->')
print(geos)
geos = mklist(geos)
# query user for input
answer = mc.promptDialog(title='Sharc Question',
message='Enter name for new geomtry matte render layer.',
text='NameMe_Matte')
print('// make_geo_layer:answer='+answer)
if answer == 'dismiss':
return False
else:
mc.promptDialog(q=1)
# create a render layer to store our work in
print('// make_geo_layer:geos->')
print(geos)
rl = createRenderLayer(geos,name=answer,nr=1,mc=1)
print('// made render layer ='+rl+'\n')
# make a SG, material, name it, color it
sg = sets(renderable=1,noSurfaceShader=1,empty=1,name='geo_shader_SG')
mat = shadingNode('surfaceShader',asShader=1)
mat.outColor >> sg.surfaceShader
mat = rename(mat,'geo_shader')
mat.setAttr('outColorR',1)
mat.setAttr('outColorG',1)
mat.setAttr('outColorB',1)
# assign new shader to the geos
for geo in geos:
sets(sg,forceElement=geo)
arnold_disable_all_aovs(rl)
return True
示例4: renameSelection
def renameSelection():
"""rename all the selected objects going 1 by 1"""
sel = mn.ls( sl = True )
for s in sel:
s() #select
mc.refresh()
result = mc.promptDialog(
title = 'Rename Object ' + s.name,
message = 'Enter Name:',
button = ['OK', 'Cancel','Stop'],
defaultButton = 'OK',
tx = s.name,
cancelButton = 'Cancel',
dismissString = 'Cancel')
if result == 'OK':
text = mc.promptDialog(query=True, text=True)
if '#' in text:
similars = mn.ls( text.replace( '#', '*' ) )
if not similars:
similars = []
s.name = text.replace( '#', str( len( similars ) ) )
else:
s.name = text
if result == 'Stop':
return
示例5: infoButton
def infoButton(*args):
cmds.promptDialog(
title='Info',
message='Info',
button=['OK'],
defaultButton='OK',
dismissString='OK')
示例6: Renameanim
def Renameanim(posefile,*args):
filename = os.path.basename(posefile).split('.')[0]
dirname = os.path.dirname(posefile)
seltab = mc.shelfTabLayout('Animation',q=1,st=1)
AnimRename = mc.promptDialog(
title='AnimRename',
message='AnimRename:',
text = filename,
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if AnimRename=='OK':
newanimname = mc.promptDialog (query=True, text=True)
renamanim= dirname+'/'+ newanimname+'.anim'
renamimag= dirname+'/'+ newanimname+'.bmp'
animimg = posefile.replace('.anim','.bmp')
print animimg
mc.sysFile(posefile,rename= renamanim)
mc.sysFile(animimg,rename= renamimag)
Refresh_UI(savepathini)
print'Anim name changed succesfully'
else:
return
mc.shelfTabLayout('Animation',e=1,st=seltab)
示例7: checkin
def checkin():
print 'checkin'
saveFile() # save the file before doing anything
print 'save'
filePath = cmds.file(q=True, sceneName=True)
print 'filePath: '+filePath
toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
print 'toCheckin: '+toCheckin
if amu.canCheckin(toCheckin):
comment = 'Comment'
commentPrompt = cmds.promptDialog(
title='Comment',
message='What changes did you make?',
button=['OK','Cancel'],
defaultButton='OK',
dismissString='Cancel',
sf = True)
if commentPrompt == 'OK':
comment = cmds.promptDialog(query=True, text=True);
else:
return
amu.setComment(toCheckin, comment)
dest = amu.getCheckinDest(toCheckin)
saveFile()
cmds.file(force=True, new=True) #open new file
dest = amu.checkin(toCheckin) #checkin
else:
showFailDialog()
示例8: defaultButtonPush09
def defaultButtonPush09(*args):
Maximum = cmds.promptDialog(
title = "Maximum shots of Episode",
message = "(Total shot of Episode) Insert_number:",
button = ["OK", "Cancel"],
defaultButton = "OK",
cancelButton = "Cancel",
dismissString = "Cancel")
if Maximum == "OK":
text001 = cmds.promptDialog(query = True, text = True)
Num = 0
EPI = cmds.promptDialog(
title = "Episode",
message = "ep + insert number:",
button = ["OK", "Cancel"],
defaultButton = "OK",
cancelButton = "Cancel",
dismissString = "Cancel")
if EPI == "OK":
Episode = cmds.promptDialog(query = True, text = True)
for x in range(1, int(text001)+1):
Num = Num+1
AnimCachePath = "I:/bubblebathbay/episodes/%s/%s_sh%.3d/FX/publish/fx/" %(Episode,Episode,int(Num))
if os.path.exists(AnimCachePath):
if len(os.listdir(AnimCachePath)) != 0:
VersionFolder = [i for i in os.listdir(AnimCachePath) if i.startswith("v") and not i.endswith("-copy")]
LatestVersion = reduce(lambda a,b: a if int(a.strip("v")) > int(b.strip("v")) else b ,VersionFolder)
if len(os.listdir(AnimCachePath+LatestVersion))== 0:
print(Episode+"sh%.3d" %int(Num))
else:
print(Episode+"sh%.3d Empty or not Required" %int(Num))
else:
print(Episode+"sh%.3d Empty or not Required" %int(Num))
示例9: selectByAttr
def selectByAttr(attr=''):
'''
Select nodes with the specified attribute
@param attr: Attribute to use a for the selection filter
@type attr: str
'''
# Check Attribute
if not attr:
result = mc.promptDialog( title='Select By Attribute',
message='Attribute:',
button=['Select','Cancel'],
defaultButton='Select',
cancelButton='Cancel',
dismissString='Cancel' )
if result == 'Select':
attr = mc.promptDialog(q=True,text=True)
# Check Attribute
if not attr: return
# Select By Attribute
sel = mc.ls('*.'+attr,o=True)
# Return Result
return sel
示例10: StripAndPublishComponent
def StripAndPublishComponent(component):
"""Prior to publishing a guide component, save a temp version and strip it of locked nodes."""
if not cmds.objExists('rig_%s_guide' % component):
rigUtils.log('Object not found: rig_%s_guide' % component, 'e')
return
prompt = cmds.promptDialog(m='Enter comment', b=['OK', 'Cancel'], cb='Cancel', db='OK', t='Enter Comment')
if prompt == 'Cancel': return
comment = cmds.promptDialog(q=True, tx=True)
tmp = tempfile.mkstemp('.ma')[1]
rigUtils.log('Saving temp file for %s: %s' % (component, tmp))
cmds.file(rn=tmp)
cmds.file(s=True, f=True, typ='mayaAscii')
rigUtils.log('Removing lockNode commands from temp file: %s' % tmp)
tmp2 = tempfile.mkstemp('.ma')[1]
fin = open(tmp, 'r')
fout = open(tmp2, 'w')
# remove lockNode commands from ma file
for line in fin.readlines():
if 'lockNode' in line: continue
fout.write(line)
fin.close()
fout.close()
publishComponentGuide(component, tmp2, comment)
示例11: saveInPreWindow
def saveInPreWindow(nClothShapeName,charNameTarget):
"""创建预设保存窗口,输入预设名,保存预设
Description:
在预设保存窗口拿到用户输入的预设名,若预设名符合要求则保存预设
Arguments:
nClothShapeName:布料节点名称
charNameTarget:目标角色名
Returns:
无
"""
result = cmds.promptDialog(title = "Save Preset", message = "Char Preset Name:", button = ["Save", "Cancel"],
defaultButton = "Save", cancelButton = "Cancel", dismissString = "Cancel") #拿到用户所选择的按钮
if result == "Save":
presetName = cmds.promptDialog(query=True, text=True)
#
#对输入的预设名进行检查:
# 1、检查该预设名是否合理(只能是英文字母,不能含有下划线等符号);
# 2、检查预设名是否已经存在(maya自带该检查功能)
#
p = re.compile("^[A-Za-z]+$") #正则表达式,匹配所有英文字母
if not p.match(presetName):
cmds.confirmDialog(title = "Warning", message = "Please Input Letters(a-z A-Z) Only!", button = "OK", defaultButton = "OK")
saveInPreWindow(nClothShapeName,charNameTarget) #递归调用,重新创建预设保存窗体
else:
cPresetName = presetName + "_" + charNameTarget
savePresetP(nClothShapeName, cPresetName)
return cPresetName
示例12: setCutGeometry
def setCutGeometry(proxyList, cutGeo=[]):
"""
Set the cut geometry for the specified proxy bounds objects
@param proxyList: List of proxy objects to set cut geometry for.
@type proxyList: list
@param cutGeo: The cut geometry list to set for the specified proxy bounds objects. If empty, string dialog is provided.
@type cutGeo: list
"""
# Check Proxy List
if not proxyList: return
for proxy in proxyList:
if not isProxyBound(proxy):
raise Exception('Invalid proxy object "' + proxy + '"!')
if not cmds.objExists(proxy + '.cutGeometry'):
print('Adding "cutGeometry" attribute to proxy bounds object "' + proxy + '"')
cutGeoAttr([proxy])
# Check Cut Geometry List
if not cutGeo:
result = cmds.promptDialog(title='Set Cut Geometry',
message='Cut Geometry:',
button=['Set', 'Cancel'],
defaultButton='Set',
cancelButton='Cancel',
dismissString='Cancel')
if result == 'Set':
cutGeo = cmds.promptDialog(q=True, text=True)
if not cutGeo:
print('No valid cut geometry list provided!')
# Set Cut Geometry List
for proxy in proxyList:
cmds.setAttr(proxy + '.cutGeometry', str(cutGeo), type='string')
示例13: remapGeometry
def remapGeometry():
'''
'''
# Check Window
win = 'skinClusterDataUI'
if not mc.window(win,q=True,ex=True): return
# Check SkinClusterData
skinData = glTools.gl_global.glSkinClusterData
if not skinData: return
# Get User Selections
geo = ''
sel = mc.ls(sl=1,dag=True)
if not sel:
result = mc.promptDialog(title='Remap Geometry',message='Enter Name:',button=['Remap', 'Cancel'],defaultButton='Remap',cancelButton='Cancel',dismissString='Cancel')
if result == 'Remap':
geo = mc.promptDialog(q=True,text=True)
else:
print('User cancelled!')
return
else:
geo = sel[0]
# Remap Geometry
skinData.remapGeometry(geometry=geo)
# Refresh UI
reloadUI()
# Return Result
return geo
示例14: setRootScale
def setRootScale(self) :
''' Menu callback '''
for rn in m.ls(type = 'peelSolveOptions') :
for skelRoot in m.getAttr("peelSolveOptions.rootNodes") :
if not m.objExists ( skelRoot ) :
m.warning("Could not find: " + str( skelRoot ))
continue
attr = skelRoot + ".mocapScale"
val = m.getAttr(attr) if m.objExists( attr ) else 1.0
ret = m.promptDialog(m="Scale for: " + str(skelRoot), text=str(val))
if ret != 'Confirm' :
print ret
continue
text = m.promptDialog(q=True, text=True)
try :
fval = float(text)
except ValueError :
m.warning("Invalid Value: " + str( text) )
continue
print "Setting scale attribute on: ", attr, "to", str(fval)
if not m.objExists( attr ) :
m.addAttr( skelRoot, sn='ms', ln='mocapScale', at='float')
m.setAttr( attr, keyable=True)
m.setAttr( attr, fval)
示例15: setAddGeometry
def setAddGeometry(proxyList,addGeo=[]):
'''
Set the add geometry for the specified proxy bounds objects
@param proxyList: List of proxy objects to set add geometry for.
@type proxyList: list
@param addGeo: The add geometry list to set for the specified proxy bounds objects. If empty, string dialog is provided.
@type addGeo: list
'''
# Check Proxy List
if not proxyList: return
for proxy in proxyList:
if not isProxyBound(proxy):
raise Exception('Invalid proxy object "'+proxy+'"!')
if not mc.objExists(proxy+'.addGeometry'):
print('Adding "addGeometry" attribute to proxy bounds object "'+proxy+'"')
addGeoAttr([proxy])
# Check Add Geometry List
if not addGeo:
result = mc.promptDialog( title='Set Add Geometry',
message='Add Geometry:',
button=['Set', 'Cancel'],
defaultButton='Set',
cancelButton='Cancel',
dismissString='Cancel' )
if result == 'Set':
addGeo = mc.promptDialog(q=True,text=True)
if not addGeo:
print('No valid add geometry list provided!')
# Set Add Geometry List
for proxy in proxyList:
mc.setAttr(proxy+'.addGeometry',str(addGeo),type='string')