当前位置: 首页>>代码示例>>Python>>正文


Python cmds.file方法代码示例

本文整理汇总了Python中maya.cmds.file方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.file方法的具体用法?Python cmds.file怎么用?Python cmds.file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lock

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def lock():
    """Lock scene

    Add an invisible node to your Maya scene with the name of the
    current file, indicating that this file is "locked" and cannot
    be modified any further.

    """

    if not cmds.objExists("lock"):
        with lib.maintained_selection():
            cmds.createNode("objectSet", name="lock")
            cmds.addAttr("lock", ln="basename", dataType="string")

            # Permanently hide from outliner
            cmds.setAttr("lock.verticesOnlySet", True)

    fname = cmds.file(query=True, sceneName=True)
    basename = os.path.basename(fname)
    cmds.setAttr("lock.basename", basename, type="string") 
开发者ID:getavalon,项目名称:core,代码行数:22,代码来源:pipeline.py

示例2: maintained_selection

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def maintained_selection():
    """Maintain selection during context

    Example:
        >>> scene = cmds.file(new=True, force=True)
        >>> node = cmds.createNode("transform", name="Test")
        >>> cmds.select("persp")
        >>> with maintained_selection():
        ...     cmds.select("Test", replace=True)
        >>> "Test" in cmds.ls(selection=True)
        False

    """

    previous_selection = cmds.ls(selection=True)
    try:
        yield
    finally:
        if previous_selection:
            cmds.select(previous_selection,
                        replace=True,
                        noExpand=True)
        else:
            cmds.select(clear=True) 
开发者ID:getavalon,项目名称:core,代码行数:26,代码来源:lib.py

示例3: setUp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def setUp(self):

        # create new scene & load plugin
        cmds.file(new=True, f=True)
        plugin = 'spore'
        self.load_plugin('spore')

        # setup a simple scene
        plane = cmds.polyPlane()
        cone = cmds.polyCone()
        cmds.select(plane[0], cone[0])
        spore = cmds.spore()

        # get new instance data object and connect it to the current node
        self.node = node_utils.get_mobject_from_name(spore[0])
        self.instance_data = instance_data.InstanceData(self.node)
        self.instance_data.initialize_data() 
开发者ID:wiremas,项目名称:spore,代码行数:19,代码来源:test_instance_data.py

示例4: setUp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def setUp(self):

        # create new scene & load plugin
        cmds.file(new=True, f=True)
        plugin = 'spore'
        self.load_plugin('spore')

        # setup a simple scene
        plane = cmds.polyPlane(sx=10, sy=10, w=10, h=10)
        #  cone = cmds.polyCone()
        #  cmds.select(plane[0], cone[0])
        #  spore = cmds.spore()

        # get new instance data object and connect it to the current node
        #  self.node = node_utils.get_mobject_from_name(spore[0])
        self.plane = node_utils.get_dagpath_from_name(plane[0])
        self.geo_cache = geo_cache.GeoCache() 
开发者ID:wiremas,项目名称:spore,代码行数:19,代码来源:test_geo_cache.py

示例5: runPB

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def runPB(quality, sequence, autoReview):
  #Get the file unix path of the maya file
  filePath = cmds.file(q=True, sceneName=True)
  #Parse the unix path and convert it into a dpa fspattern

  if quality < 50:
    print "Lower than 50 percent quality may result in very poor imaging..."
    cmds.deleteUI("PBQuality")
    return

  print "Percentage chosen: " + str(quality)
  print "From Sequence: " + str(sequence)
  print "AutoSubmit: " + str(autoReview)

  #Attempts to create a playblast of the current maya scene
  success = playblaster(quality, sequence, autoReview)

  if success:
    print "Successfully generated playblast :)"
  else:
    print "Failed to generate playblast :(" 
开发者ID:Clemson-DPA,项目名称:dpa-pipe,代码行数:23,代码来源:playblast.py

示例6: maya_import

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def maya_import():
    temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
    folderPath = os.path.join(os.getenv('MAYA_APP_DIR'),'Scripting_Files','go')
    if not os.path.exists(folderPath):
        os.makedirs(os.path.dirname(folderPath+'\\'))  # 末尾\\が必要なので注意
    #print folderPath
    files = os.listdir(folderPath)
    if files is not None:
        for file in files:
            print file
            nameSpace = file.replace('.ma', '')
            cmds.file(folderPath+'\\'+file, i=True, typ="mayaAscii", iv=True, mnc=False, options="v=0;", pr=True)
            #重複マテリアルにファイル名が頭に付与されてしまうのを修正
            allMat = cmds.ls(mat=True)
            fileName = file.split('.')[0]
            for mat in allMat:
                if mat.startswith(fileName+'_'):
                    cmds.rename(mat, mat.replace(fileName+'_', ''))
        cmds.inViewMessage( amg='<hl>Go Maya</hl> : Imoprt objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
    else:
        cmds.inViewMessage( amg='<hl>Go Maya</hl> : There is no exported object', pos='midCenterTop', fade=True, ta=0.75, a=0.5) 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:23,代码来源:go.py

示例7: check_open

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def check_open():
    current_project = cmds.workspace(q=True, rootDirectory=True)
    scene_path = cmds.file(q=True, sceneName=True)
    scene_name = cmds.file(q=True, shortName=True, sceneName=True)
    msg01 = lang.Lang(
                en='Workspace not found',
                ja=u'ワークスペースがみつかりません')
    dir_list = scene_path.split('/')
    for i in range(len(dir_list)):
        dir_list = dir_list[:-1]
        root_dir = '/'.join(dir_list)+'/'
        try:
            all_files = os.listdir(root_dir)
        except:
            cmds.inViewMessage( amg=msg01.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
            return
        for file in all_files:
            if file == 'workspace.mel':
                set_work_space(root_dir)
                return
    cmds.inViewMessage( amg=msg01.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5) 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:23,代码来源:setup.py

示例8: source_nodes

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def source_nodes():
    cmds.file(new=True, force=True)

    source1, _ = pm.polyCube(name="source1")
    source2, _ = pm.polyCube(name="source2")
    target, _ = pm.polyCube(name="target")

    ch1 = att.addAttribute(source1,
                           "chanName",
                           "double",
                           0,
                           minValue=0,
                           maxValue=1)
    ch2 = att.addAttribute(source2,
                           "chanName",
                           "double",
                           0,
                           minValue=0,
                           maxValue=1)

    pm.connectAttr(ch1, source1.ty)
    pm.connectAttr(ch2, source2.ty) 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:24,代码来源:test_mgear_attribute.py

示例9: repath

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def repath(node, file, project_path):
    matches = []
    for root, dirnames, filenames in os.walk(project_path):
        for x in filenames:
            if x == file:
                matches.append([root,os.path.join(root, x)]) 
            elif x.split(".")[0] == file.split(".")[0]: #---> this second option is used when a file is useing ##### padding, we can match by name only
                
                x_ext = x.split(".")[len(x.split("."))-1]
                file_ext = file.split(".")[len(file.split("."))-1]
                if x_ext == file_ext:
                    matches.append([root,os.path.join(root, x)])
                
                
    if len(matches)>0:   
        return cmds.filePathEditor(node, repath=matches[0][0])      
     
    return None 
开发者ID:liorbenhorin,项目名称:pipeline,代码行数:20,代码来源:maya_warpper.py

示例10: _createResolutionComboBox

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def _createResolutionComboBox(self):
		userProps = cross3d.UserProps(self._nativePointer)

		# Local models have a resolution metadata.
		# Maybe it's not a good idea.
		if resolutionAttr in userProps:
			del userProps[resolutionAttr]

		resolutions = ':'.join(userProps.get('resolutions', []))

		# Object should support referencing, but referencing hasn't been setup, so create the structure.
		cmds.addAttr(self._nativeName(), longName=resolutionAttr, attributeType="enum", enumName=resolutions)

		# Make the attribute viewable, but not keyable in the channelBox
		try:
			cmds.setAttr(self._attrName(), keyable=False, channelBox=True)
		# Consume a runtime error if the resolution attribute was in the reference. This is only a
		# issue with some of our first models, Asset Exporter will remove them from future exports.
		except RuntimeError as error:
			pattern = r"setAttr: The attribute '[^']+' is from a referenced file, thus the keyable state cannot be changed."
			if not re.match(pattern, error.message):
				raise 
开发者ID:blurstudio,项目名称:cross3d,代码行数:24,代码来源:mayascenemodel.py

示例11: loadUiType

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def loadUiType(uiFile):
    """
    Pyside lacks the "loadUiType" command, so we have to convert the ui file to py code in-memory first
    and then execute it in a special frame to retrieve the form_class.
    http://tech-artists.org/forum/showthread.php?3035-PySide-in-Maya-2013 (ChrisE)
    """
    parsed = xml.parse(uiFile)
    widget_class = parsed.find('widget').get('class')
    form_class = parsed.find('class').text

    with open(uiFile, 'r') as f:
        o = StringIO()
        frame = {}

        pysideuic.compileUi(f, o, indent=0)
        pyc = compile(o.getvalue(), '<string>', 'exec')
        exec pyc in frame

        #Fetch the base_class and form class based on their type in the xml from designer
        form_class = frame['Ui_%s'%form_class]
        base_class = eval('QtWidgets.%s'%widget_class)
    return form_class, base_class 
开发者ID:chrisevans3d,项目名称:uExport,代码行数:24,代码来源:uExport.py

示例12: getP4Location

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def getP4Location(self, asset, root='//depot/ArtSource/', debug=1):
        from p4python.P4 import P4, P4Exception

        if asset:
            p4 = P4()
            try: p4.connect()
            except:
                print 'Cannot connect to P4!'
                return False

            try:
                file =  p4.run_files(root + '...' + asset)
                depotLoc = file[0]['depotFile']
                describe = p4.run_describe(file[0]['change'])
                return [describe[0]['user'], depotLoc, describe[0]['desc'], file[0]['change']]
            except Exception as e:
                print "findFileP4>>>> Cannot find file.", asset
                if debug: print e
                return False
            finally:
                p4.disconnect() 
开发者ID:chrisevans3d,项目名称:uExport,代码行数:23,代码来源:uExport.py

示例13: missingNodes

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def missingNodes(self):
        fileNodes = cmds.ls(type='file')
        missingFiles = {}
        for f in fileNodes:
            filePath = cmds.getAttr(f + '.fileTextureName')
            if filePath != '':
                if not cmds.file(filePath, exists=1, q=1):
                    fileName = filePath.split('/')[-1]
                    path = filePath.replace(fileName,'')
                    missingFiles[fileName] = {'path':path, 'node':f}
        return missingFiles


## SANITY CHECK
########################################################################

    #general methods 
开发者ID:chrisevans3d,项目名称:uExport,代码行数:19,代码来源:uExport.py

示例14: test_nodereuse

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def test_nodereuse():
    """Node re-use works ok"""

    import cmdx
    nodeA = cmdx.createNode("transform", name="myNode")
    nodeB = cmdx.createNode("transform", parent=nodeA)
    assert_is(cmdx.encode("|myNode"), nodeA)
    assert_is(nodeB.parent(), nodeA)

    with tempdir() as tmp:
        fname = os.path.join(tmp, "myScene.ma")
        cmds.file(rename=fname)
        cmds.file(save=True, type="mayaAscii")
        cmds.file(fname, open=True, force=True)

        # On scene open, the current scene is closed, triggering
        # the nodeDestroyed callback which invalidates the node
        # for cmdx. Upon encoding this node anew, cmdx will
        # allocate a new instance for it.
        assert_is_not(cmdx.encode("|myNode"), nodeA) 
开发者ID:mottosso,项目名称:cmdx,代码行数:22,代码来源:tests.py

示例15: test_nodereuse_noexist

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import file [as 别名]
def test_nodereuse_noexist():
    """Node re-use works on non-existent nodes"""

    nodeA = cmdx.createNode("transform", name="myNode")
    nodeB = cmdx.createNode("transform", parent=nodeA)
    assert_is(cmdx.encode("|myNode"), nodeA)
    assert_is(nodeB.parent(), nodeA)

    cmds.file(new=True, force=True)

    # Even if it's available for re-use, it will still throw
    # a cmdx.ExistError on account of trying to fetch an MObject
    # from a non-existing node.
    assert_raises(cmdx.ExistError, cmdx.encode, "|myNode")

    # Any operation on a deleted node raises RuntimeError
    assert_raises(RuntimeError, lambda: nodeA.name()) 
开发者ID:mottosso,项目名称:cmdx,代码行数:19,代码来源:tests.py


注:本文中的maya.cmds.file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。