Exemplo n.º 1
0
def rig_visConnect(control, geo):

    """
    used to create a vis channel on an object (first selected object)
    and attach it to the visibility of all other selected objects
    @param control:
    @type control:
    @param geo:
    @type geo: object
    """

    if not cmds.objExists(control):
        raise UserInputError('The control specified to rig_visConnect does not exist!')

    if not cmds.attributeExists('vis', control):
        cmds.addAttr(control, k=True, ln='vis', at='enum', en='off:on:')
        cmds.setAttr(control + '.vis')
        1

    for i in len(geo):
        if not cmds.objExists(geo[i]):
            continue
        temp = cmds.listConnections(geo[i] + '.v', s=True, d=False)
        if not temp:
            raise UserInputError('Warning, the object ' + geo[
                i] + ' already has an incoming connection on its visibility and will be skipped.')
            continue
        cmds.setAttr(geo[i] + '.v', l=False)
        cmds.connectAttr((geo[i] + '.v'), (control + '.vis'), f=True)
        channelStateSetFlags(-1, -1, -1, -1, -1, -1, -1, -1, -1, 2, geo[i])
Exemplo n.º 2
0
   obj[] = stringArrayRemove({ccc}, sel);
   
   rig_visConnect(ccc, obj);

#################################################################################################################

def rig_visConnect(control, geo[]):
	
	'''
	used to create a vis channel on an object (first selected object)
	and attach it to the visibility of all other selected objects
	'''
	
	if not mc.objExists(control):
	   raise UserInputError('The control specified to rig_visConnect does not exist!')
	   
   if not mc.attributeExists('vis', control):
	   mc.addAttr(control, k=True, ln='vis', at='enum', en='off:on:')
	   mc.setAttr(control + '.vis') 1
	
	for i in len(geo):
		if not mc.objExists(geo[i]):
			continue
		temp = mc.listConnections(s=True, d=False, geo[i] + '.v')
		if not temp:
			raise UserInputError('Warning, the object ' + geo[i] + ' already has an incoming connection on its visibility and will be skipped.')
			continue
		mc.setAttr(geo[i] + '.v', l=False)
		mc.connectAttr((geo[i] + '.v'), (control + '.vis'), f=True)
		channelStateSetFlags(-1,-1,-1,-1,-1,-1,-1,-1,-1,2, {geo[i]})
Exemplo n.º 3
0
   obj[] = stringArrayRemove({ccc}, sel);

   rig_visConnect(ccc, obj);

#################################################################################################################

def rig_visConnect(control, geo[]):

	'''
	used to create a vis channel on an object (first selected object)
	and attach it to the visibility of all other selected objects
	'''

	if not mc.objExists(control):
	   raise UserInputError('The control specified to rig_visConnect does not exist!')

   if not mc.attributeExists('vis', control):
	   mc.addAttr(control, k=True, ln='vis', at='enum', en='off:on:')
	   mc.setAttr(control + '.vis') 1

	for i in len(geo):
		if not mc.objExists(geo[i]):
			continue
		temp = mc.listConnections(s=True, d=False, geo[i] + '.v')
		if not temp:
			raise UserInputError('Warning, the object ' + geo[i] + ' already has an incoming connection on its visibility and will be skipped.')
			continue
		mc.setAttr(geo[i] + '.v', l=False)
		mc.connectAttr((geo[i] + '.v'), (control + '.vis'), f=True)
		channelStateSetFlags(-1,-1,-1,-1,-1,-1,-1,-1,-1,2, {geo[i]})
Exemplo n.º 4
0
def getSpeNodeFiles():
    fileDict = {}
    # reference
    rList = my.ls(type="reference")
    if len(rList):
        fileDict["reference"] = []
        for r in rList:
            if r != "shareReferenceNode" and r != "_UNKNOWN_REF_NODE" and my.referenceQuery(
                    r, inr=True) != True:
                rPath = my.referenceQuery(r, f=True).replace("\\", "/")
                if "{" in rPath:
                    rPath = re.findall("(.*){.*", rPath)[0]
                    rPathList = [rPath, os.path.isfile(rPath)]
                    if not rPathList in fileDict["reference"]:
                        fileDict["reference"].append(rPathList)

    # cacheFile
    cacheList = my.ls(type="cacheFile")
    if len(cacheList):
        fileDict["cacheFile"] = []
        for cache in cacheList:
            cacheDir = my.getAttr(cache + ".cachePath")
            cacheName = my.getAttr(cache + ".cacheName")
            if cacheDir and cacheDir.strip():
                cachePath = os.path.join(cacheDir, cacheName + ".xml")
                if os.path.isfile(cachePath):
                    files = os.listdir(cacheDir)
                    for f in files:
                        pattern = cacheName + "*"
                        if re.match(pattern, f):
                            fPath = os.path.join(cacheDir,
                                                 f).replace("\\", "/")
                            fPathList = [fPath, os.path.isfile(fPath)]
                            if not fPathList in fileDict["cacheFile"]:
                                fileDict["cacheFile"].append(fPathList)

    # particle cacheFile
    cacheList = my.ls(type="dynGlobals")
    if len(cacheList):
        fileDict["dynGlobals"] = []
        for cache in cacheList:
            cacheDir = my.getAttr(cache + ".cacheDirectory")
            if cacheDir and cacheDir.strip():
                if not os.path.isdir(cacheDir):
                    tmp = os.path.join(my.workspace(q=True, rd=True),
                                       my.workspace(fre="particles"))
                    cacheDir = os.path.join(tmp, cacheDir)
                files = os.listdir(cacheDir)
                for f in files:
                    fPath = os.path.join(cacheDir, f).replace("\\", "/")
                    fPathList = [fPath, os.path.isfile(fPath)]
                    if not fPathList in fileDict["dynGlobals"]:
                        fileDict["dynGlobals"].append(fPathList)

    # yeti
    yetiShapeList = my.ls(type="pyYetiMaya")
    if len(yetiShapeList):
        fileDict["pyYetiMaya_cache"] = []
        fileDict["pyYetiMaya_groom"] = []
        fileDict["pyYetiMaya_texture"] = []
        fileDict["pyYetiMaya_reference"] = []
        for yetiShape in yetiShapeList:
            # ensure to update yeti, otherwise it could not get node correctly sometimes.
            my.select(yetiShape)
            # cachePath
            if my.attributeExists("cacheFileName", yetiShape):
                cfn = my.getAttr(yetiShape + ".cacheFileName")
                if cfn and cfn.strip():
                    fileDict["pyYetiMaya_cache"] += getFiles(cfn)
            # groomPath
            if my.attributeExists("groomFileName", yetiShape):
                groomPath = my.getAttr(yetiShape + ".groomFileName")
                if groomPath and groomPath.strip():
                    fileDict["pyYetiMaya_groom"] += getFiles(groomPath)
            # textureNode
            if mel.eval('cache(`pgYetiGraph -listNodes -type "texture" %s`)' %
                        yetiShape) == 0:
                texturePathList = mel.eval("pgYetiCommand -listTextures %s" %
                                           yetiShape)
                if len(texturePathList):
                    for texturePath in texturePathList:
                        if texturePath and texturePath.strip():
                            fileDict["pyYetiMaya_texture"] += getFiles(
                                texturePath)
            # referenceNode
            if mel.eval(
                    'cache(`pgYetiGraph -listNodes -type "reference" %s`)' %
                    yetiShape) == 0:
                referenceNodes = mel.eval(
                    'pgYetiGraph -listNodes -type "reference" %s' % yetiShape)
                for referenceNode in referenceNodes:
                    referencePathList = mel.eval(
                        'pgYetiGraph -getParamValue -node %s -param "reference_file"'
                        % referenceNode)
                    if len(referencePathList):
                        for referencePath in referencePathList:
                            if referencePath and referencePath.strip():
                                fileDict["pyYetiMaya_reference"] += getFiles(
                                    referencePath)

    return fileDict