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


Python cmds.connectAttr函数代码示例

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


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

示例1: createJointOnCurveByLength

def createJointOnCurveByLength( multRate, distNode=True ):
    
    sels = cmds.ls( sl=1 )
    
    curveSetInst = CreateJointOnCurveSet()
    
    curveInfo = cmds.createNode( 'curveInfo' )
    
    returnTargets = []
    for sel in sels:
        
        selCurve = cmds.listRelatives( sel, s=1 )
        
        if not selCurve: continue
        
        selCurve = selCurve[0]
        cmds.connectAttr( selCurve+'.local', curveInfo+'.inputCurve', f=1 )
        length = cmds.getAttr( curveInfo+'.arcLength' )
        curveSetInst.setJointNum( int( length * multRate ) )
        curveSetInst.setCurve( selCurve )
        joints = curveSetInst.create( distNode )
        
        returnTargets.append( joints )

    return returnTargets
开发者ID:jonntd,项目名称:mayadev-1,代码行数:25,代码来源:createJointOnCurve.py

示例2: nucleus_

	def nucleus_(self, name = ''):
		nucleus = cmds.createNode('nucleus')
		if name:
			nucleus = cmds.rename(nucleus, name)
		cmds.connectAttr('time1.outTime', '%s.currentTime' % nucleus)

		return nucleus
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:7,代码来源:fx_lib.py

示例3: switch

def switch(node,attr,value=0,inputNames=list(),inputValues=list()):
    '''
    :param node:
    :param attr:
    :param value:
    :param inputName:
    :param inputValues:
    :return:
    '''

    attrName = "{0}.{1}".format(node,attr)
    choiceName = "{0}_{1}_switch".format(node,attr)
    cmds.createNode("choice",name=choiceName)
    cmds.addAttr(node,ln=attr,at="enum",en=":".join(inputNames),dv=value,keyable=True)

    for i in range(len(inputValues)):
        choiceAttr = "output{0}".format(i)
        cmds.addAttr(choiceName,ln=choiceAttr,at="double3")
        cmds.addAttr(choiceName,ln="{0}x".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][0])
        cmds.addAttr(choiceName,ln="{0}y".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][1])
        cmds.addAttr(choiceName,ln="{0}z".format(choiceAttr),at="double",p=choiceAttr,dv=inputValues[i][2])

        cmds.connectAttr("{0}.{1}".format(choiceName,choiceAttr),"{0}.input[{1}]".format(choiceName,i))

    cmds.connectAttr(attrName,"{0}.selector".format(choiceName),f=True)

    return "{0}.output".format(choiceName)
开发者ID:jdynamite,项目名称:autorigger,代码行数:27,代码来源:attribute.py

示例4: _bind_joint_setup

 def _bind_joint_setup(self):
     """Skinweight the nurbs curve which affects the nurbs surface."""
     skn = cmds.skinCluster(self.nrbcurve, self.joints,
                            tsb=True, nw=1, sm=0, bm=0, mi=1, dr=10)[0]
     bindpose = cmds.listConnections('%s.bindPose' % skn)[0]
     cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % skn)
     cmds.connectAttr('%s.showHistory' % self.mod_grp, '%s.ihi' % bindpose)
开发者ID:jonntd,项目名称:Public,代码行数:7,代码来源:volume_push_collider.py

示例5: _publish_gpu_for_item

    def _publish_gpu_for_item(self, item, output, work_template, primary_publish_path, sg_task, comment, thumbnail_path, progress_cb):
        """
        Export a gpu cache for the specified item and publish it  to Shotgun.
        """
        group_name = item["name"].strip("|")
        debug(app = None, method = '_publish_gpu_for_item', message = 'group_name: %s' % group_name, verbose = False)
        tank_type = output["tank_type"]
        publish_template = output["publish_template"]        
                
        # get the current scene path and extract fields from it using the work template:
        scene_path = os.path.abspath(cmds.file(query=True, sn= True))
        fields = work_template.get_fields(scene_path)
        publish_version = fields["version"]

        # update fields with the group name:
        fields["grp_name"] = group_name

        ## create the publish path by applying the fields with the publish template:
        publish_path = publish_template.apply_fields(fields)
        #'@asset_root/publish/gpu/{name}[_{grp_name}].v{version}.abc'
        gpuFileName = os.path.splitext(publish_path)[0].split('\\')[-1] 
        fileDir = '/'.join(publish_path.split('\\')[0:-1])
        debug(app = None, method = '_publish_gpu_for_item', message = 'gpuFileName: %s' % gpuFileName, verbose = False)
        
        ## Now fix the shaders
        shd.fixDGForGPU()
        
        if cmds.objExists('CORE_ARCHIVES_hrc'):
            cmds.setAttr('CORE_ARCHIVES_hrc.visiblity', 0)
        
        if cmds.objExists('ROOT_ARCHIVES_DNT_hrc'):
            cmds.setAttr('ROOT_ARCHIVES_DNT_hrc.visiblity', 0)
                                       
        ## build and execute the gpu cache export command for this item:
        try:
            print '====================='
            print 'Exporting gpu now to %s\%s' % (fileDir, gpuFileName)
            #PUT THE FILE EXPORT COMMAND HERE
            cmds.select(clear = True)
            for geo in cmds.listRelatives(group_name, children = True):
                if 'geo_hrc' in geo:
                    geoGroup = str(group_name)
                    debug(app = None, method = '_publish_gpu_for_item', message = 'geoGroup: %s' % geoGroup, verbose = False)
                
            cmds.select(geoGroup)
            
            debug(app = None, method = '_publish_gpu_for_item', message = 'geoGroup: %s' % geoGroup, verbose = False)
            debug(app = None, method = '_publish_gpu_for_item', message = "gpuCache -startTime 1 -endTime 1 -optimize -optimizationThreshold 40000 -directory \"%s\" -fileName %s %s;" % (fileDir, gpuFileName, geoGroup), verbose = False)
            
            mel.eval("gpuCache -startTime 1 -endTime 1 -optimize -optimizationThreshold 40000 -directory \"%s\" -fileName %s %s;" % (fileDir, gpuFileName, geoGroup))

            print 'Finished gpu export...'
            print '====================='
            
            if cmds.objExists('dgSHD'):            
                ## Now reconnect the FileIn nodes
                for key, var in filesDict.items():
                    cmds.connectAttr('%s.outColor' % key, '%s.color' % var)
        except Exception, e:
            raise TankError("Failed to export gpu cache file")
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:60,代码来源:maya_asset_secondary_publish.py

示例6: connect

	def connect( self, obj, slot=None ):
		'''
		performs the actual connection of an object to a connect slot
		'''
		if not cmd.objExists(obj):
			return -1

		#if the user is trying to connect the trigger to itself, return zero which is the reserved slot for the trigger
		if apiExtensions.cmpNodes( self.obj, obj ):
			return 0

		if slot is None:
			slot = self.nextSlot()

		if slot <= 0:
			return 0

		#make sure the connect isn't already connected - if it is, return the slot number
		existingSlots = self.isConnected(obj)
		if existingSlots:
			return self.getConnectSlots(obj)[0]

		conPrefix = 'zooTrig'
		prefixSize = len(conPrefix)

		slotPath = "%s.%s%d" % (self.obj, conPrefix, slot)
		if not objExists( slotPath ):
			cmd.addAttr(self.obj,ln= "%s%d" % (conPrefix, slot), at='message')

		cmd.connectAttr( "%s.msg" % obj, slotPath, f=True )
		self.cacheConnect( slot )

		return slot
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:33,代码来源:triggered.py

示例7: setCage

 def setCage(self, node):
     meshes = pm.selected( type="transform" )
     if not meshes:
         return
     shape=meshes[-1].getShapes()[0]
     cmds.connectAttr(shape+".worldMesh[0]", node.name()+".cageMesh")
     self.updateUI()
开发者ID:shizuo-kaji,项目名称:CageDeformerMaya,代码行数:7,代码来源:ui_cageDeformer.py

示例8: BindSkeletons

def BindSkeletons(source, dest, method='connect'):
    '''
    From 2 given root joints search through each hierarchy for child joints, match
    them based on node name, then connect their trans/rots directly, or 
    parentConstrain them. Again cmds for speed
    '''
    sourceJoints = cmds.listRelatives(source, ad=True, f=True, type='joint')
    destJoints = cmds.listRelatives(dest, ad=True, f=True, type='joint')
 
    if cmds.nodeType(source) == 'joint':
        sourceJoints.append(source)
    if cmds.nodeType(dest) == 'joint':
        destJoints.append(dest)
        
    attrs = ['rotateX', 'rotateY', 'rotateZ', 'translateX', 'translateY', 'translateZ']   
     
    for sJnt, dJnt in MatchGivenHierarchys(sourceJoints, destJoints):
        if method == 'connect':
            for attr in attrs:
                try:
                    cmds.connectAttr('%s.%s' % (sJnt, attr), '%s.%s' % (dJnt, attr), f=True)
                except:
                    pass
        elif method == 'constrain':
            try:
                cmds.parentConstraint(sJnt, dJnt, mo=True)    
            except:
                pass
开发者ID:miketon,项目名称:SymLink,代码行数:28,代码来源:AnimationBinder.py

示例9: __setup_sculpt_shader

 def __setup_sculpt_shader(self):
     #--- this method setups the sculpt shader color
     #--- list all the shader names
     shader_list = ['sculptShaderGreen']
     #--- check if shader exists, else create a new one
     for s in range(len(shader_list)):
         if cmds.objExists(shader_list[s]):
             #--- check which mesh is selected
             self.shader = shader_list[0]
             self.shader_set = shader_list[0] + '3SG'
         else:
             #--- create the lambert shader
             self.shader = cmds.shadingNode('lambert',
                                            asShader = True,
                                            name = shader_list[0])
             self.shader_set = cmds.sets(self.shader,
                                         renderable = True,
                                         noSurfaceShader = True,
                                         empty = True,
                                         name = shader_list[0] + '3SG')
             cmds.connectAttr(self.shader + '.outColor',
                              self.shader_set + '.surfaceShader',
                              force = True)
     #--- change the color
     cmds.setAttr(self.shader + '.color', 0, 1, 1)
     #--- assign the shader to the sculpt_mesh
     cmds.sets(self.sculpt_mesh, forceElement = self.shader_set)
开发者ID:jonntd,项目名称:Public,代码行数:27,代码来源:shotfinaling.py

示例10: ShapeInverterCmdold

def ShapeInverterCmdold(base=None, corrective=None, name=None):
    mc.undoInfo(openChunk=True)
    if not base or not corrective:
        sel = mc.ls(sl=True)
        base, corrective = sel
    shapes = mc.listRelatives(base, children=True, shapes=True)
    for s in shapes:
        if mc.getAttr("%s.intermediateObject" % s) and mc.listConnections("%s.worldMesh" % s, source=False):
            origMesh = s
            break
    deformed = mc.polyPlane(ch=False)[0]
    mc.connectAttr("%s.worldMesh" % origMesh, "%s.inMesh" % deformed)
    mc.setAttr("%s.intermediateObject" % origMesh, 0)
    mc.delete(deformed, ch=True)
    mc.setAttr("%s.intermediateObject" % origMesh, 1)
    if not name:
        name = "%s_inverted#" % corrective
    invertedShape = duplicateMesh(base, name=name)
    deformer = mc.deformer(invertedShape, type="ShapeInverter")[0]
    mc.ShapeInverterCmd(baseMesh=base, invertedShape=invertedShape, ShapeInverterdeformer=deformer, origMesh=deformed)
    # correctiveShape = duplicateMesh(base,name=corrective+"_corrective#")
    # mc.connectAttr('%s.outMesh' % getShape(correctiveShape), '%s.correctiveMesh' % deformer)
    # transferMesh(corrective,[correctiveShape])
    mc.connectAttr("%s.outMesh" % getShape(corrective), "%s.correctiveMesh" % deformer)
    mc.setAttr("%s.activate" % deformer, True)
    mc.delete(deformed)
    bdingBx = mc.polyEvaluate(corrective, boundingBox=True)
    xDifVal = bdingBx[0][1] - bdingBx[0][0]
    # mc.move(xDifVal*1.10,correctiveShape,r=True,moveX=True)
    mc.move(xDifVal * 2.20, invertedShape, r=True, moveX=True)
    mc.undoInfo(closeChunk=True)
    return invertedShape  # ,correctiveShape
开发者ID:jonntd,项目名称:cvShapeInverter,代码行数:32,代码来源:ShapeInverterScript.py

示例11: connectMovedDriverToFixedNode

 def connectMovedDriverToFixedNode(self):
     
     targetMesh = self._targetMesh
     node = getBlendAndFixedShapeNode( targetMesh )
     
     attrs = []
     
     for driver, attr in self._driverAndAttr:
         value0 = cmds.getAttr( driver+'.'+attr )
         attrs.append( driver+'.'+attr )
     
     self._connectIndices = []
     self._connectWeights = []
     
     for attr in attrs:
         blendAndFixedShapeCons = cmds.listConnections( attr, type='blendAndFixedShape' )
         
         if not blendAndFixedShapeCons:
             targetIndex = fnc.getLastIndex( node+'.driverWeights' )+1
             cmds.connectAttr( attr, node+'.driverWeights[%d]' % targetIndex )
             self._connectIndices.append( targetIndex )
             self._connectWeights.append( value0 )
             continue
         
         if not node in blendAndFixedShapeCons:
             continue
         
         cons = cmds.listConnections( attr, p=1, c=1 )
         targetAttr = cons[1]
         
         connectedIndex = int( targetAttr.split('[')[1].replace(']','' ) )
         connectedValue = cmds.getAttr( cons[1] )
         self._connectIndices.append( connectedIndex )
         self._connectWeights.append( connectedValue )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:34,代码来源:assignMeshCommand.py

示例12: ImportCustomTexture

def ImportCustomTexture(name):
	
	os.system("cd ~/maya/2014-x64/scripts; python texture.py")
	
	file = '/usr/tmp/texture.jpg'
	
	#create a shader
	shader=cmds.shadingNode( "blinn", asShader=True )

	#a file texture node
	shaderName = file_node=cmds.shadingNode( "file", asTexture=True )
	
	print shaderName
	
	#attach file to node
	cmds.setAttr( '%s.fileTextureName' %file_node, file, type = "string")
 
	# a shading group
	shading_group= cmds.sets(renderable=True,noSurfaceShader=True,empty=True)

	#connect shader to sg surface shader
	cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader' %shading_group)

	#connect file texture node to shader's color
	cmds.connectAttr('%s.outColor' %file_node, '%s.color' %shader)

	cmds.sets(name, edit=True, forceElement=shading_group)
开发者ID:Gmadges,项目名称:PastWork,代码行数:27,代码来源:TerrainLib.py

示例13: perform

def perform(**kwargs):
	sel = cmds.ls(sl=True)
	sel3=[]
	for s in sel:
	    sel3+=cmds.xform(s,q=True, ws=True, t=True)
	pointset=[]
	for i in xrange(len(sel3)/3):
	    pointset+=[Vector(sel3[i*3],sel3[i*3+1],sel3[i*3+2])]
	bbox = BBox()
	bbox.obbFromPointSet(pointset)
	t = Transform(bbox.axis[0],bbox.axis[1],bbox.axis[2])
	t = t.transpose()
	z = t.getEuler()
	cube = cmds.createNode("polyCube")
	cubeShape = cmds.createNode("mesh")
	cubeTrans = cmds.listRelatives(cubeShape,p=True)[0]
	cmds.connectAttr(cube+".output",cubeShape+".inMesh")
	cmds.setAttr(cubeTrans+".tx",bbox.center[0])
	cmds.setAttr(cubeTrans+".ty",bbox.center[1])
	cmds.setAttr(cubeTrans+".tz",bbox.center[2])
	cmds.setAttr(cubeTrans+".rz",degrees(z[2]))
	cmds.setAttr(cubeTrans+".ry",degrees(z[1]))
	cmds.setAttr(cubeTrans+".rx",degrees(z[0]))
	cmds.setAttr(cube+".width",bbox.max[0]-bbox.min[0])
	cmds.setAttr(cube+".height",bbox.max[1]-bbox.min[1])
	cmds.setAttr(cube+".depth",bbox.max[2]-bbox.min[2])
	cmds.sets(e=True,forceElement="initialShadingGroup")
	cmds.select(sel)
开发者ID:ainaerco,项目名称:meshTools,代码行数:28,代码来源:obb.py

示例14: _parentSurfaceFLCL

    def _parentSurfaceFLCL(self, constrained_obj, geo, deleteCPOMS=1):
        """
        Parents object to follicle at closest point on surface. 
        Select child transform, then select mesh to hold parent follicle. 
        
        """
        cpos = pmc.createNode('closestPointOnSurface', n='cpos_flcl_' + geo)

        mc.connectAttr(pmc.listRelatives(geo, shapes=True, children=True)[0] + '.local', cpos + '.inputSurface')
        obj_mtx = pmc.xform(constrained_obj, q=True, m=True)
        pmc.setAttr(cpos + '.inPosition', [obj_mtx[12], obj_mtx[13], obj_mtx[14]])

        flclShape = pmc.createNode('follicle', n='flclShape' + geo)
        flcl = pmc.listRelatives(flclShape, type='transform', parent=True)
        pmc.rename(flcl, 'flcl_' + geo + '_1')

        mc.connectAttr(flclShape + '.outRotate', flcl[0] + '.rotate')
        mc.connectAttr(flclShape + '.outTranslate', flcl[0] + '.translate')
        mc.connectAttr(geo + '.worldMatrix', flclShape + '.inputWorldMatrix')
        mc.connectAttr(geo + '.local', flclShape + '.inputSurface')
        mc.setAttr(flclShape + '.simulationMethod', 0)

        u = mc.getAttr(cpos + '.result.parameterU')
        v = mc.getAttr(cpos + '.result.parameterV')
        pmc.setAttr(flclShape + '.parameterU', u)
        pmc.setAttr(flclShape + '.parameterV', v)

        pmc.parent(constrained_obj, flcl)
        if deleteCPOMS == 1:
            pmc.delete(cpos)
                
        return flcl
开发者ID:scorza,项目名称:variableFK,代码行数:32,代码来源:vfk_UI.py

示例15: returnClosestUV

def returnClosestUV (targetObject,surface):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Pass target object and surface into it and return the closest UV coordinates

    ARGUMENTS:
    targetObject(string)
    surface(string)

    RETURNS:
    UV(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    """ pass target object and surface into it and return the closest UV coordinates"""
    UVs = []
    """ make the node """
    tmpNode = mc.createNode ('closestPointOnSurface')
    """ to account for target objects in heirarchies """
    tmpObj = rigging.locMeObjectStandAlone(targetObject)
    mc.connectAttr ((tmpObj+'.translate'),(tmpNode+'.inPosition'))
    mc.connectAttr ((surface+'.worldSpace'),(tmpNode+'.inputSurface'))
    UVs.append (mc.getAttr (tmpNode+'.u'))
    UVs.append (mc.getAttr (tmpNode+'.v'))
    mc.delete (tmpNode)
    mc.delete (tmpObj)
    return UVs
开发者ID:GuidoPollini,项目名称:MuTools,代码行数:27,代码来源:distance.py


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