本文整理汇总了Python中pymel.core.fileDialog2函数的典型用法代码示例。如果您正苦于以下问题:Python fileDialog2函数的具体用法?Python fileDialog2怎么用?Python fileDialog2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fileDialog2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setWipFolder
def setWipFolder(self):
currentScene = pm.sceneName()
if currentScene:
projectPath,fileName = os.path.split(currentScene)
wipFolder = ''
try:
wipFolder = pm.fileDialog2(dir=projectPath,ds=2,fm=3,okc='Select Folder')[0]
except:
pm.warning('No folder was selected')
if wipFolder:
self.wipFolderEdit.setText(wipFolder)
self.wipFolderPath = wipFolder
self.bdPopulateFiles()
else:
projectPath = pm.workspace.path
charactersFolder = os.path.abspath(os.path.join(projectPath,'scenes','characters'))
path = ''
try:
path = pm.fileDialog2(dir=charactersFolder,ds=2,fm=3,okc='Select Folder')[0]
except:
pm.warning('No folder was selected')
if path:
self.wipFolderEdit.setText(path)
self.wipFolderPath = path
self.bdPopulateFiles()
示例2: _buttonAction
def _buttonAction(self):
#inputs the first object in the selection as the textfield text upon button press
if not self.disabler.getSelect()-1:
file = pm.fileDialog2( ds=2, fm=1, cap='Select a binary proxy', ff='*.mib', dir=( self.project_path+"/export/GEO/RENDERPROXY/"+self.user ) )
else:
file = pm.fileDialog2( ds=2, fm=3, cap='Select a binary proxy folder', dir=( self.project_path+"/export/GEO/RENDERPROXY/"+self.user ) )
pm.textFieldButtonGrp( self.button, e=True, text=file[0] )
示例3: exportAnim
def exportAnim(self, *args):
objs = pm.ls( sl=True )
successState = True
filePath = pm.fileDialog2( caption='Save Animation', startingDirectory=uad , fileFilter="Anim Files (*.anim)" )
if not filePath:
sys.stdout.write('Save animation cancelled.')
return None
animInfos = {} # dictionary containing dictionaries of every object's animations
for obj in objs:
if not ( self.hasUniqueName( obj ) ): # if object'n name is not unique, doesn't save animation for it
successState = False
pm.warning( "Object %s's name is not unique. skipped"%obj.name() )
continue
nameSpace = self.getNameSpace( obj )
if nameSpace:
objName = obj.name().split(':')[1]
else:
objName = obj.name()
# find all anim curves on the object
curves = pm.findKeyframe( obj , curve=True )
if not curves: # jump to next object if no anim curve found
continue
animInfo = {} # dictionary containing one object's animations
for curve in curves: # for each curve, find where it's connected to, keys' times, values and tangents
attr = pm.listConnections( '%s.output'%curve, plugs=True )[0]
if nameSpace:
attrName = attr.name().split(':')[1]
else:
attrName = attr.name()
times = pm.keyframe( attr, q=True, timeChange=True )
values = pm.keyframe( attr, q=True, valueChange=True )
outWeights = pm.keyTangent( attr, q=True, outWeight=True )
outAngles = pm.keyTangent( attr, q=True, outAngle=True )
inWeights = pm.keyTangent( attr, q=True, inWeight=True )
inAngles = pm.keyTangent( attr, q=True, inAngle=True )
animInfo[ attrName ] = { 'times':times, 'values':values, 'outWeights':outWeights, 'outAngles':outAngles, 'inWeights':inWeights, 'inAngles':inAngles }
animInfos[ objName ] = animInfo
# write anim info to file
filePath = filePath[0]
logfile = open( filePath , 'w')
logfile.write( str(animInfos) )
logfile.close()
if successState:
sys.stdout.write( 'Animation was successfully exported.' )
else:
pm.warning( 'Some objects animtions were not saved due to multiple object with the same name, check script editor for more info.' )
示例4: _exportGroup
def _exportGroup( self, *args ):
path = pm.fileDialog2( dialogStyle=2,
fileMode=0,
caption='Choose Group File',
okCaption='Export',
selectFileFilter='Group',
fileFilter='Group (*.group)'
)
if path is None:
return
else:
path = path[0]
groupName = self.groupOM.getValueStr()
group = self._poseGroups[ groupName ]
f = open( path, 'w' )
pp = pprint.PrettyPrinter( stream=f, indent=1 )
#output = ( groupName, 'group', group )
pp.pprint( group )
f.close()
print "Exported Group: '%s' to: %s" % ( groupName, path )
示例5: _exportPose
def _exportPose( self, *args ):
path = pm.fileDialog2( dialogStyle=2,
fileMode=0,
caption='Choose Pose File',
okCaption='Export',
selectFileFilter='Pose',
fileFilter='Pose (*.pose)'
)
if path is None:
return
else:
path = path[0]
group = self._poseGroups[ self.groupOM.getValueStr() ]
#try:
poseName = self.poseListTSL.getSelectItem()[0]
f = open( path, 'w' )
pp = pprint.PrettyPrinter( stream=f, indent=1 )
#output = ( poseName, 'pose', group[poseName] )
pp.pprint( group[poseName] )
f.close()
print "Exported Pose: '%s' to: %s" % ( group[poseName], path )
示例6: __importBone__
def __importBone__(self):
"""import from file data"""
# check if we have an object to work with
if self.objSwc != None:
# opening file dialog to choose a file
basicFilter = "*.swc"
path = pmc.fileDialog2(fileFilter=basicFilter, dialogStyle=2, caption='Import Bones Influences', okCaption='Import', fileMode=1)
if (path):
# get all items from both array
itemsL = self.boneUI['tslBoneL'].getAllItems()
itemsR = self.boneUI['tslBoneR'].getAllItems()
# open the file
f = open(str(path[0]), 'r')
for line in f:
if line.count('#') == 0:
if line != '\n':
tmp = line.split('=')
if itemsL.count(tmp[0]) > 0:
index = itemsL.index(tmp[0])
self.__renameBone__(tmp[1].replace('\n', ''), index+1)
# and then close the file
f.close()
示例7: __exportBone__
def __exportBone__(self):
"""export into file current data"""
# check if we have an object to work with
if self.objSwc != None:
# opening file dialog to choose a file
basicFilter = "*.swc"
path = pmc.fileDialog2(fileFilter=basicFilter, dialogStyle=2, caption='Export Bones Influences', okCaption='Export', fileMode=0)
if (path):
# get all items from both array
itemsL = self.boneUI['tslBoneL'].getAllItems()
itemsR = self.boneUI['tslBoneR'].getAllItems()
# create and open the file
f = open(str(path[0]), 'w')
# writting in the file
f.write('# SWC export for %s \n' % self.objSwc.name())
for i in range(0, len(itemsL)):
f.write(str(itemsL[i]).replace('=', '_'))
f.write('=')
f.write(str(itemsR[i]).replace('=', '_'))
f.write('\n')
# and then close the file
f.close()
vp.vPrint('Export Done, %s' % path[0], 2)
示例8: Maya_createNode
def Maya_createNode(self, nodeType, *args):
if nodeType == 'aiStandard':
# Ask for name
name = self.User_inputDialog("Create aiStandard", "Enter a name for the node: ")
# Create and assign shader
aiStd = pc.shadingNode('aiStandard', asShader=True, name=name)
aiStdSg = pc.sets(renderable=True, noSurfaceShader=True, empty=True, name=name + 'SG')
aiStd.outColor >> aiStdSg.surfaceShader
self.UI_refreshShaders()
return(str(aiStd))
if nodeType == 'file':
# Ask for name
name = self.User_inputDialog("Create file", "Enter a name for the node: ")
# Ask for location of the file
location = pc.fileDialog2(fm=1, dialogStyle=2)
myTex = pc.shadingNode('file', asTexture=True, name=name)
myTex.fileTextureName.set(location)
return(str(myTex))
if nodeType == 'ygColorCorrect':
# Ask for name
name = self.User_inputDialog("Create ygColorCorrect", "Enter a name for the node: ")
ygC = pc.shadingNode('ygColorCorrect', asShader=True, name=name)
return(str(ygC))
示例9: new_scene
def new_scene(self):
cmds.file(newFile=True, force=True)
location = "{0}{1}{2}".format(os.path.dirname(os.path.realpath(__file__)), os.path.sep, self.cleanScene)
self.set_project(location)
cmds.file("cleanScene.ma", open=True)
select_dir = pm.fileDialog2(fileMode=2, dialogStyle=3, startingDirectory=self.statusDir)
if select_dir != None:
print select_dir[0]
sDir = str(select_dir[0])
result = cmds.promptDialog(
title='Asset Name',
message='Enter Name:',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if result == 'OK':
assetName = cmds.promptDialog(query=True, text=True)
print assetName
# makes project folder
projectFolder = os.path.join(sDir, assetName)
if not os.path.exists(projectFolder):
print "Creating {0}".format(projectFolder)
os.makedirs(projectFolder)
# makes scenes folder
scenesFolder = os.path.join(projectFolder, SCENE_FOLDER)
if not os.path.exists(scenesFolder):
print "Creating {0}".format(scenesFolder)
os.makedirs(scenesFolder)
# makes turntable folder
turntableFolder = os.path.join(projectFolder, TURNTABLE_FOLDER)
if not os.path.exists(turntableFolder):
print "Creating {0}".format(turntableFolder)
os.makedirs(turntableFolder)
# makes export folder
exportFolder = os.path.join(projectFolder, EXPORT_FOLDER)
if not os.path.exists(exportFolder):
print "Creating {0}".format(exportFolder)
os.makedirs(exportFolder)
# makes sourceimages folder
sourceimagesFolder = os.path.join(projectFolder, SOURCEIMAGES_FOLDER)
if not os.path.exists(sourceimagesFolder):
print "Creating {0}".format(sourceimagesFolder)
os.makedirs(sourceimagesFolder)
fileName = assetName + "_v001_" + get_author_initials() + ".ma"
fileSavePath = os.path.join(scenesFolder, fileName)
print fileSavePath
cmds.file(rename=fileSavePath)
cmds.file(save=True)
示例10: Export
def Export(data):
multipleFilters = "JSON Files (*.json)"
f = pm.fileDialog2(fileMode=0, fileFilter=multipleFilters)
if f:
f = open(f[0], 'w')
json.dump(data, f)
f.close()
示例11: loadDeformerWeights
def loadDeformerWeights(filename=None):
'''
Usage:
loadDeformerWeights(filename='/jobs/mercedesFable_5402587/build/charTortoise/maya/export/WEIGHTS/tortoiseAFacial/extraWeights/deformerWeights/v03/deformerWeights.json')
loadDeformerWeights()
'''
if not filename:
try:
filename = pm.fileDialog2(cap='Select a json file you stored', fm=1, okc='Load', ff='JSON (*.json)')[0]
except:
pm.error('file not found, whatever.')
with open(filename, 'rb') as fp:
data = json.load(fp)
for key in data.keys():
if pm.objExists(key):
deformer = Deformer(pm.PyNode(key))
print 'Loading weights for deformer:\t%s'%deformer
for deformedShape in data[key].keys():
if pm.objExists(deformedShape):
print '\tLoading deformer weights on shape:\t%s'%deformedShape
deformedTransform = pm.PyNode(deformedShape).getParent()
#print data[key][deformedShape]
deformer.setWeights(data[key][deformedShape], deformedTransform)
else:
pm.warning('Object %s does not exist to apply deformer weights to...skipping'%deformedShape)
else:
pm.warning('Deformer %s doesn\'t exist...skipping'%key)
示例12: storeDeformerWeights
def storeDeformerWeights(selection=True, type='rig_vertSnap'):
'''
Usage:
storeDeformerWeights(selection=False)
storeDeformerWeights(selection=True, type=['rig_vertSnap'])
storeDeformerWeights(selection=False, type=['rig_vertSnap', 'wire'])
'''
deformers = pm.ls(type=type)
if selection:
if len(pm.ls(sl=True))==0:
pm.error('select something numbnuts!')
deformers = pm.ls(sl=True)[0].listHistory(type='rig_vertSnap')
vsFile = {}
for deformer in deformers:
vs = Deformer(deformer)
vs.initializeWeights()
if len(vs.weightsList) > 0:
vsFile[deformer.name()] = vs.weightsList
try:
filename = os.path.join( pm.fileDialog2(cap='Select a folder to store the weights', fm=3, okc='Select')[0], 'deformerWeights.json' )
except:
pm.error('Why did you cancel? :(')
with open(filename, 'wb') as fp:
print 'Storing weights in file:\n\t%s'%(filename)
print '\t\tDeformers Stored:\n\t\t\t%s'%('\n\t\t\t'.join([deformer.name() for deformer in deformers]))
json.dump(vsFile, fp, indent=4)
示例13: xmlFileBrowse
def xmlFileBrowse(self, args=None):
filename = pm.fileDialog2(fileMode=0, caption="Export Corona File Name")
if len(filename) > 0:
filename = filename[0]
if not filename.endswith(".igs"):
filename += ".igs"
self.rendererTabUiDict['xml']['xmlFile'].setText(filename)
示例14: changeOutputDestination
def changeOutputDestination(self, dest = None):
'''updates the output location for muster renders'''
#TODO: check access to proposed render location location
if not dest:
dest = pm.fileDialog2(fileMode = 3, dialogStyle = 1, startingDirectory = self.widgets['outputDir'].getFileName())
if dest:
self.widgets['outputDir'].setText(pm.Path(dest[0]))
示例15: load_shelf_UI
def load_shelf_UI(cls):
""" Gives us a file dialog to pick a specific shelf to reload/create
"""
prefs = cls.get_user_shelves_dir()
shelf_path = pm.fileDialog2(ff='*.mel', ds=2, fm=4,dir=prefs)
if shelf_path:
cls.shelf_update(shelf_path[0])