def delete_motion_path(self):
        curveSel = pm.selected()[0]
        old_name = curveSel.name()

        _dup_curve = pm.duplicate(curveSel)
        pm.delete(curveSel)
        pm.rename(_dup_curve, old_name)
Example #2
0
    def _rename_(self, mode=''):
        selection = pymel.ls(selection=True)
        nameList = []
        for each in selection:
            nameList.append(each.nodeName())
        
        if mode == 'searchAndReplace':
            renameList = self.figureOut_searchAndReplace(nameList)
        if mode == 'prefixSuffix':
            renameList = self.figureOut_prefixSuffix(nameList)
        if mode == 'nameAndNumber':
            renameList = self.figureOut_nameAndNumber(nameList)

            
#        renameList = self.figureOut_rename(selection)


        for i, each in enumerate(selection):
            pymel.rename( selection[i], renameList[i] )

        self.update()
        
        mods = cmds.getModifiers()
        if (mods & 4) > 0:    #Ctrl
            self.close()
Example #3
0
	def createEtAmbOccRE(self):
		
		#create etAmbOccRE
		etAmbOccRE = self.createRenderElement('ExtraTexElement')
		pm.rename(etAmbOccRE, 'rbEtAmbOcc')
		
		#SetAttrs on etAmbOccRE
		pm.setAttr(etAmbOccRE.vray_name_extratex, 'rbEtAmbOcc')
		pm.setAttr(etAmbOccRE.vray_explicit_name_extratex, 'rbEtAmbOcc')
		pm.setAttr(etAmbOccRE.vray_affectmattes_extratex, 0)
		
		
		#Create vraydirt tex and setAttrs
		pm.select(cl = True)
		
		vrayDirtTex = pm.createNode('VRayDirt')
		pm.rename(vrayDirtTex, 'rbVRayDirt')
		pm.setAttr(vrayDirtTex.workWithTransparency, 1)
		
		#connect vraydirt tex
		vrayDirtTex.outColor >> etAmbOccRE.vray_texture_extratex
		pm.select(cl = True)
		
		
		#verbose
		if(self.verbose): print('Extra Tex AmbOcc RE created')
Example #4
0
def orderedRename( objects=[], name=None, prompt=True ):
    """Renames selected objects in order of selection."""
    result = 'OK'

    if prompt:
        opt_name = 'orderedRename_name'

        result = pm.promptDialog( title='Ordered Rename',
                              message='Enter name:',
                              text=pm.optionVar.get( opt_name, 'object0' ),
                              button=( 'OK', 'Cancel' ),
                              defaultButton='OK',
                              cancelButton='Cancel',
                              dismissString='Cancel'
                              )
        if result == 'OK':
            name = pm.promptDialog( query=True, text=True )
            pm.optionVar[opt_name] = name

    if result == 'OK':
        if not prompt and name is None:
            assert False, r"'name' needs to be set when using 'prompt=False'"
        else:
            if len( objects ) is 0:
                objects = pm.ls( selection=True, type='transform' )

            i = 0
            for obj in objects:
                pm.rename( obj, name )
                i += 1

            print '// Results: %i objects renamed as "%s" //' % ( i, name )
Example #5
0
def replace_shape(old=None, new=None, maintainOffset=False):
    """ Replace the shape of old with new shape."""

    # Check that old is specified and either a Transform or Shape.
    if old and (not isinstance(old, pm.nodetypes.Transform)
                or not isinstance(old, pm.nodetypes.Shape)):
        raise ValueError(
            "Parameters new and old must be of type Transform or Shape.")

    # If nothing specified use selection,
    if not old and not new:
        # Not following the Maya standard of 'driver driven' but using the python str replace() order instead.
        old, new = pm.selected()

    # Get the shape we want to use instead of old
    shape = new.getShape()

    # Remove the shape of old,
    pm.delete(old.getShape())

    # Parent the new shape under the old transform
    pm.parent(
        shape,
        old,
        shape=True,
        relative=False if maintainOffset else True,
    )

    # Set shape name according to Maya standards,
    pm.rename(shape, old.nodeName() + 'Shape')

    # Remove transform of the new object, this will otherwise be empty and clutter the scene.
    pm.delete(new)
 def _create_follicle(self, obj, name, count=1, uPos=0.0, vPos=0.0):
     ''' 
     Manually place and connect a follicle onto a nurbs surface. 
     '''
     shape = obj.getShape()
     
     # create a name with frame padding
     fName = '_'.join([name, 'ShapeFollicle', str(count).zfill(2)])
     oFoll = pm.createNode('follicle', name=fName)
     shape.local.connect(oFoll.inputSurface)
     
     p = oFoll.getParent().name()
     tName = '_'.join([name, 'Follicle', str(count).zfill(2)])
     pm.rename(p,tName)
     # if using a polygon mesh, use this line instead.
     # (The polygons will need to have UVs in order to work.)
     #oMesh.outMesh.connect(oFoll.inMesh)
 
     shape.worldMatrix[0] >> oFoll.inputWorldMatrix
     oFoll.outRotate >> oFoll.getParent().rotate
     oFoll.outTranslate >> oFoll.getParent().translate
     oFoll.parameterU.set(uPos)
     oFoll.parameterV.set(vPos)
     oFoll.getParent().t.lock()
     oFoll.getParent().r.lock()
 
     return oFoll
Example #7
0
def suffixName( objects=[], suffix=None, dag=True, prompt=True ):
    """Add a suffix to all hierarchy names."""
    result = 'OK'

    if prompt:
        opt_suffix = 'suffixNames_suffix'

        result = pm.promptDialog( title='Suffix Name',
                              message='Enter suffix:',
                              text=pm.optionVar.get( opt_suffix, '_suffix' ),
                              button=( 'OK', 'Cancel' ),
                              defaultButton='OK',
                              cancelButton='Cancel',
                              dismissString='Cancel'
                              )
        if result == 'OK':
            suffix = pm.promptDialog( query=True, text=True )
            pm.optionVar[opt_suffix] = suffix

    if result == 'OK':
        if not prompt and suffix is None:
            assert False, r"'suffix' needs to be set when using 'prompt=False'"
        else:
            if len( objects ) is 0:
                objects = pm.ls( selection=True, type='transform', dag=dag )
            else:
                objects = pm.ls( objects, type='transform', dag=dag )

            i = 0
            for obj in objects:
                pm.rename( obj, obj.split( '|' )[-1] + suffix )
                i += 1

            print '// Results: %i objects rename with suffix "%s" //' % ( i, suffix )
def SearchReplaceNames (  searchString="pasted__", replaceString="",  objs=None ):
    
    if objs==None:
    	objs = pm.ls(sl=True)
    else:
        objs = pm.ls(objs)
    
    returnVal = []
    
    #============================================================================
    # RENAME
    		
    for obj in objs:
    	
    	currentFullName = obj.name()
    	
    	newFullName = currentFullName.replace ( searchString , replaceString )
    	
    	newFullNameSplitted = newFullName.split ("|")
    	
    	newName = newFullNameSplitted [len(newFullNameSplitted)-1]
    	
    	pm.rename (obj , newName )
    
    returnVal = pm.listRelatives(obj,ad=True)
    returnVal.append(obj)
    returnVal.reverse()
    	
    return returnVal
Example #9
0
def create_render_cam(name="RENDER_CAM", exposure=True):
    """
    Creates a camera and renames it 
    
    str name: name of the camera
    bool exposure: connect a mia_exposure_photographic node to the camera     
    """
    if not pm.objExists(name):
        cam = pm.camera()[0]
        pm.rename(cam, name)
        [cam.renderable.set(cam.name().startswith(name)) for cam in pm.ls(cameras=True)]
    cam = pm.PyNode(name)
    
    if exposure:
        if not cam.miLensShader.isConnected():
            node = pm.createNode("mia_exposure_photographic")
            node.film_iso.set(800)
            node.f_number.set(1.2)
            node.gamma.set(1)
            pm.connectAttr(node.message, cam.miLensShader, force=True)
    
    cam.getShape().setDisplayResolution(True)
    pm.lookThru(name)
    
    pm.select(cam)
Example #10
0
def connectButtonIcon():
    sel = pm.ls(sl = True)
    # match name
    pm.rename(sel[1], sel[0].name().replace('Button', 'ButtonIcon'))
    if not 'ButtonIcon' in sel[1].name():
        pm.rename(sel[1], sel[0].name().replace('Button', 'ButtonIcon'))
    else:
        pass
    
    # connect attributes
    
    try:
        pm.connectAttr('%s.translate' % sel[0],'%s.translate' % sel[1] )
    except Exception as ex:
        print ex
        
    try:
        pm.connectAttr('%s.scaleX' % sel[0],'%s.scaleX' % sel[1] )
    except Exception as ex:
        print ex
        
    try:
        pm.connectAttr('%s.scaleY' % sel[0],'%s.scaleY' % sel[1] )
    except Exception as ex:
        print ex
	def renameMultiMatteRE(self, mMRE):
		
		#rename
		pm.rename(mMRE, '{0}MmRenderElement'.format(vrayGlobals.PREFIX))
		
		#SetAttrs on mMRE
		pm.setAttr(mMRE.vray_name_multimatte, mMRE.name())
Example #12
0
 def execute(self, *args, **kwargs):
     """ This function can execute other functions based on user selection
     Args:
         None
     Returns (None)
     """
     crv_name = self.crvNameField.getText()
     new_crv_name = self.jntNameFeild.getText() + '_CRV'
     if kwargs.get('debug'):
         print "GO!!!"
     if self.jntPlaceBtn.getSelect()==2:
         self.evenly_spaced_crv()
     else:
         pm.rename(crv_name, new_crv_name)
         pm.select(clear = True)
         
     self.create_joints()
     
     if self.chkboxGrp.getValue1()==1:
         self.splineIK_jntsOnCrv()
         
     if self.chkboxGrp.getValue2()==1:
         self.splineIK_controls()
         
     if self.chkboxGrp.getValue3()==1:
         self.splineIK_stretch()
                 
     self.splineIK_organizeOutliner()
     pm.select(clear = True)  
     pm.delete(self.delete)
    def _build(self, *args):
        """
        Builds the joints on the curve.
        """
        # naming convention
        asset = self.asset
        side = self.side
        part = self.part
        joints = self.joints
        suffix = self.suffix

        if self.gui:
            asset = self.asset_name.text()
            side = self.side.currentText()
            part = self.part_name.text()
            joints = self.joints_box.value()
            suffix = self.suffix.currentText()
        try:
            curve = pm.ls(sl=True)[0]
            curve_name = NameUtils.get_unique_name(asset, side, part, "crv")
            self.curve = pm.rename(curve, curve_name)
        except IndexError:
            pm.warning("Please select a curve")
            return

        length_of_curve = pm.arclen(self.curve)
        equal_spacing = length_of_curve / float(joints)

        # clear the selection
        pm.select(cl=True)

        # # create the joints
        curve_joints = list()
        for x in xrange(int(joints) + 1):
            name = NameUtils.get_unique_name(asset, side, part, suffix)
            joint = pm.joint(n=name)
            curve_joints.append(joint)

            joint_position = (x * equal_spacing)
            pm.move(0, joint_position, 0)
        
        # rename last joint
        last_joint = curve_joints[-1]
        pm.rename(last_joint, last_joint + "End")

        root_joint = pm.selected()[0].root()
        end_joint = pm.ls(sl=True)[0]
        solver = 'ikSplineSolver'

        # attach joints to curve
        ik_name = NameUtils.get_unique_name(asset, side, part, "ikHandle")
        self.ikHandle = pm.ikHandle(sj=root_joint, ee=end_joint, sol=solver,
                        c=self.curve, pcv=True, roc=True, ccv=False, n=ik_name)
        joint_chain = pm.ls(root_joint, dag=True)

        # delete history
        pm.makeIdentity(root_joint, apply=True)

        # cleanup
        self._cleanup()
Example #14
0
    def createPad(cls, *args):

        if args:
            inputObject = args[0]
        else:
            inputObject = pm.selected()

        if type(inputObject) != list:
            inputObject = [inputObject]
        pads = []
        for obj in inputObject:
            pm.select(cl = True)

            paddingGroup = pm.group(em = True)
            upperPaddingGroup = pm.group(em = True)

            pm.parent(paddingGroup, upperPaddingGroup)
            movePivot = pm.parentConstraint(obj, upperPaddingGroup, mo = False)
            pm.delete(movePivot)
            pm.parent(obj, paddingGroup)
            pm.makeIdentity(apply = True, t = True, r = True, s = True, n = 0)

            pm.rename(paddingGroup, obj + '_sdkPad')
            pm.rename(upperPaddingGroup, obj + '_offsetPad')

            pads.append(upperPaddingGroup)
        return pads
Example #15
0
def renameShadingTrees(base_nodes=[], all_in_scene=False):
    """Rename the selected Shading tree. need to have shader selected
    import mo_Utils.mo_shaderUtils as mo_shaderUtils
    reload(mo_shaderUtils)
    mo_shaderUtils.renameSelectedShadingTree()
    """
    if all_in_scene:
        base_nodes = pm.ls(mat=True)[2:]
        print 'Renaming All Shaders: %s' % base_nodes

    if base_nodes == []:
        base_nodes = pm.selected()

        base_node_type = base_node.nodeType()
        if base_node_type not in pm.listNodeTypes('shader'):
            pm.warning(
                'No Shader Selected. Please select a shader and try again.')
            return

        print 'Renaming Selected: %s' % base_nodes

    shd_renamer = ShaderRenamer()

    for base_node in base_nodes:
        print 'renaming Hierarchy %s' % base_node
        basename = base_node.replace('_ai', '')
        shd_renamer.renameShadingTree(base_node, basename, target_attr=None)

        SG = base_node.connections(t="shadingEngine")
        if len(SG) > 0:
            pm.rename(SG[0], base_node + 'SG')
            shd_renamer.renameShadingTree(SG[0], basename, target_attr=None)
Example #16
0
def makeFkIk(*args):

	bindRoot = pm.ls(selection = True)[0]
	bindChain = pm.ls(bindRoot, dag = True)
	fkChain = pm.duplicate(bindRoot)
	replaceSuffix(fkChain, 'fk')
	makeFk(False, fkChain)
	ikChain = pm.duplicate(bindRoot)
	replaceSuffix(ikChain, 'ik')
	makeIk(False, ikChain)

	fkChainList = pm.ls(fkChain, dag = True)
	ikChainList = pm.ls(ikChain, dag = True)

	createPad(bindRoot)
	suffixIndex = bindChain[0].rfind('_')
	hanldeName = bindChain[0][:suffixIndex] + '_switch'
	handle = createHandle(hanldeName)
	pm.rename(handle, hanldeName)
	pm.parentConstraint(bindChain[-1], handle)
	constraintList = []
	for i, item in enumerate(bindChain):
		newConstraint = pm.orientConstraint(fkChainList[i], ikChainList[i], bindChain[i], mo = False)
		fkCon = pm.orientConstraint(newConstraint, q = True, wal = True)[1]
		ikCon = pm.orientConstraint(newConstraint, q = True, wal = True)[0]

		pm.setDrivenKeyframe(fkCon, cd = handle + '.switch', v = 1, dv = 10)
		pm.setDrivenKeyframe(fkCon, cd = handle + '.switch', v = 0, dv = 0)

		pm.setDrivenKeyframe(ikCon, cd = handle + '.switch', v = 0, dv = 10)
		pm.setDrivenKeyframe(ikCon, cd = handle + '.switch', v = 1, dv = 0)
Example #17
0
 def create_chain_for_curve(self, crv, obj=None, link_length=1):
     """
     Uses the Curve and creates a chain based on the object that is passed into the function
     
     crv = curve to be used
     obj = object to be used
     linklength = lenght of the obj
     """
             
     if obj is None:
         obj = self.create_link()
         link_length = (2*(self.radius - self.section_radius*2)+self.extrude)
     chain_length = int(pm.PyNode(crv).length()/link_length)
     chain = self.make_chain(obj=obj, link_length=link_length, chain_length=chain_length)
     joints = self.rig_chain(chain)
     
     ik = pm.ikHandle(startJoint=joints[0], endEffector=joints[-1], solver='ikSplineSolver', createCurve=False, curve=crv)[0]
     pm.rename(ik, self.name + "_ikHandle")
         
     control_group = pm.group(joints[0], ik, n="%sctrl_grp" % self.name)
     control_group.v.set(False)
     pm.group(crv, self.name, control_group, n="%s_grp" % self.name)
     
     self.add_cluster_handles(crv)
     pm.select(deselect=True)
     
     return self.name
Example #18
0
def makeLightSelectSet(sel=None):
    try:
        lgt = select.shapes(sel, xf=True, do=True)
    except:
        pass

    _go = pm.promptDialog(title='New Light Group:',
                          message='Enter Name:',
                          button=['OK', 'Cancel'],
                          tx='lg_',
                          defaultButton='OK',
                          cancelButton='Cancel',
                          dismissString='Cancel')

    if _go == 'OK':
        name = pm.promptDialog(query=True, text=True)
        _lg = pm.PyNode(pm.Mel.eval(
            'vrayAddRenderElement LightSelectElement;'))  # make the light grou

        pm.rename(_lg, name)
        _lg.vray_name_lightselect.set(name)
    else:
        return None

    if sel:
        for obj in sel:
            pm.sets(_lg, edit=True, forceElement=obj)

    return _lg
Example #19
0
	def createDynamicChainLocators(self, prefix = ''):
		
		#set instance prefix var
		self.setPrefix(prefix)
		
		pm.select(cl = True)
		
		#Create Space locators and translate
		self.dynamic_chain_locator_base = pm.spaceLocator(n = self.prefix + '_dynamic_chain_locator_base')
		self.dynamic_chain_locator_base.translate.set(0, 0, 0)
		pm.select(cl = True)
		
		self.dynamic_chain_locator_tip = pm.spaceLocator(n = self.prefix + '_dynamic_chain_locator_tip')
		self.dynamic_chain_locator_tip.translate.set(0, 10, 0)
		pm.select(cl = True)
		
		
		
		#Create Annotations and rename
		self.annotation_dynamic_chain_locator_base = pm.annotate( self.dynamic_chain_locator_base, tx = self.prefix +'_dynamic_chain_base' )
		pm.rename(self.annotation_dynamic_chain_locator_base.getParent().name(), self.prefix + '_dynamic_chain_base_annotation')
		
		self.annotation_dynamic_chain_locator_tip = pm.annotate( self.dynamic_chain_locator_tip, tx = self.prefix +'_dynamic_chain_tip' )
		pm.rename(self.annotation_dynamic_chain_locator_tip.getParent().name(), self.prefix + '_dynamic_chain_tip_annotation')
		
		pm.select(cl = True)
		
		#Parent constrain annotation transforms
		pm.parentConstraint(self.dynamic_chain_locator_base, self.annotation_dynamic_chain_locator_base.getParent(), mo = False)
		pm.parentConstraint(self.dynamic_chain_locator_tip, self.annotation_dynamic_chain_locator_tip.getParent(), mo = False)
Example #20
0
 def control_to_softMod(self):
     sels = pm.ls(sl=1)
     if len(sels) == 2 :
         control = sels[0]
         geometry = sels[1]
         falloff_radius = control.falloffRadius.get()
         falloff_mode = control.falloffMode.get()
         
         pos = t = pm.xform(control,q=1,ws=1,t=1)
         r = pm.xform(control,q=1,ws=1,ro=1)
         s = pm.xform(control,q=1,r=1,s=1)
         
         pm.select(geometry,r=1)
         #softMod -falloffMode 1 -falloffAroundSelection 0
         (softMod,softMod_handle) = pm.softMod(falloffMode=1, falloffAroundSelection=0)
         #rename $tempString[0] ("convertedSoftMod_"+$sel[0])
         pm.rename(softMod, ( 'convertedSoftMod_'+control.name() ) )
         pm.rename(softMod_handle, ( 'convertedSoftModHandle_'+control.name() ) )
         
         softMod.falloffRadius.set( falloff_radius )
         softMod.falloffMode.set( falloff_mode )
         #setAttr -type float3 ($softModHandle+"Shape.origin") ($pos[0]) $pos[1] $pos[2];
         softMod_handle.getShape().origin.set(pos)
         #setAttr ($softMod+".falloffCenter") ($pos[0]) $pos[1] $pos[2];
         softMod.falloffCenter.set(pos)
         
         #xform -piv ($pos[0]) $pos[1] $pos[2] $softModHandle;
         pm.xform(softMod_handle,piv=pos)
         #xform -ws -t ($t[0]-$pos[0]) ($t[1]-$pos[1]) ($t[2]-$pos[2]) -ro $r[0] $r[1] $r[2] -s $s[0] $s[1] $s[2] $softModHandle;
         pm.xform(softMod_handle,ws=1,t=((t[0]-pos[0]),(t[1]-pos[1]),(t[2]-pos[2])),ro=r,s=s)
         
         pm.select(softMod_handle)
         
     else:
         pm.warning('control_to_softMod:please select one control and one geometry first')
Example #21
0
    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
Example #22
0
def renameSGtoMatchShader():
    """ Renames Shader Group to Match Shader """
    shdList = pm.ls(sl=1, fl=1)
    for shader in shdList:
        shdGrp = shader.connections(type="shadingEngine")
        if shdGrp != []:
            pm.rename(shdGrp[0], str(shader) + "SG")
def transfer_shape(source, target, flip=True):
    """it will replace the shape of selected number 2 with the shapes of selected number 1"""

    target_shape = target.getShape(noIntermediate=True)
    target_shape_orig = get_orig_shape(target_shape)

    dup = pymel.duplicate(source, rc=1)[0]
    tmp = pymel.createNode('transform')
    pymel.parent(tmp, dup)
    pymel.xform(tmp, t=(0, 0, 0), ro=(0, 0, 0), scale=(1, 1, 1))
    pymel.parent(tmp, w=1)
    for sh in dup.getShapes(noIntermediate=True):
        pymel.parent(sh, tmp, r=1, s=1)

    pymel.delete(dup)
    temp_grp_negScale = pymel.createNode('transform')
    pymel.parent(tmp, temp_grp_negScale)
    if flip:
        temp_grp_negScale.scaleX.set(-1)

    pymel.parent(tmp, target)
    pymel.delete(temp_grp_negScale)

    pymel.makeIdentity(tmp, t=True)  # this brings translate values at 0 before scale freezing
    pymel.makeIdentity(tmp, apply=True, t=True, r=True, s=True)
    pymel.parent(tmp, w=1)

    color_info, vis_master = get_previous_controller_info(target)

    shapes_has_been_deleted = False
    for sh in tmp.getShapes():
        if target_shape_orig:
            adapt_to_orig_shape(sh, target.getShape())
        else:
            if not shapes_has_been_deleted:
                shapesDel = target.getShapes()
                if shapesDel: pymel.delete(shapesDel)
                shapes_has_been_deleted = True

            pymel.parent(sh, target, r=1, s=1)
            pymel.rename(sh.name(), target.name() + "Shape")

            if color_info[0]:
                if color_info[1]:
                    sh.overrideEnabled.set(True)
                    sh.overrideRGBColors.set(1)
                    sh.overrideColorRGB.set(color_info[2])

                else:
                    sh.overrideEnabled.set(True)
                    sh.overrideRGBColors.set(0)
                    sh.overrideColor.set(color_info[2])

            else:
                sh.overrideEnabled.set(False)

            if vis_master:
                vis_master.connect(sh.visibility)

    pymel.delete(tmp)
	def createLight(self, position):
		value = self.distance_float.value()
		if self.lightType_menu.currentIndex() == 1:
			light = pm.shadingNode('areaLight', asLight=True)
			
			pm.setAttr(light + '.intensity', 500)
			pm.setAttr(light + '.decayRate', 2)
			pm.setAttr(light + '.areaLight', 1)

		elif self.lightType_menu.currentIndex() == 2:
			light = pm.shadingNode('spotLight', asLight=True)

			pm.setAttr(light + '.intensity', 500)
			pm.setAttr(light + '.decayRate', 2)

		elif self.lightType_menu.currentIndex() == 3:
			light = pm.shadingNode('directionalLight', asLight=True)

		elif self.lightType_menu.currentIndex() == 4:
			light = pm.shadingNode('pointLight', asLight=True)

			pm.setAttr(light + '.intensity', 500)
			pm.setAttr(light + '.decayRate', 2)

		pm.rename(light, light_name)
		pm.xform(light, a=True, t=position)
		pm.xform(light, r=True, t=(0, 0, value))

		return light
Example #25
0
def renaming():
    preName = pm.textFieldGrp('pre',q = 1,tx = 1)
    
    sideB = pm.radioButtonGrp('side',q = 1,sl = 1)
    sideList = ['l','r','m']
    
    objName = pm.textFieldGrp('obj',q = 1,tx = 1)
    startNum = pm.textFieldGrp('starNum',q = 1,tx = 1)
    paddingNum = pm.textFieldGrp('paddingNum',q = 1,tx = 1)
    suffixName = pm.textFieldGrp('suffix',q = 1,tx = 1)
    jointEnd = pm.checkBox('je',q = 1,v = 1)
    
    sels = pm.ls(sl = 1)
    
    for num,sel in enumerate(sels):
    
        if len(str(startNum)) < paddingNum:
            number = str(0) + str(startNum)
        
        preNames = ''
        
        if preName != '':
            preNames = preName + '_'
            
        name = preNames + objName + '_' + sideList[sideB] + '_' + number + '_' + suffixName
         
        pm.rename(sel,name)
    
        if jointEnd == 1:
            name = preNames + objName + '_' + sideList[sideB] + '_' + number + '_' + 'je'
            pm.rename(sels[-1],name)
            print name
        startNum = int(startNum) + 1
Example #26
0
def GuideCrv ( startGuider=None , endGuider=None ):

	if startGuider==None or endGuider==None:
		startGuider,endGuider = pm.ls(sl=True)
	
	pm.select(clear=True)
	
	startJnt = pm.joint ( n = startGuider.name()+"_guideCrvJnt")
	pm.parent (startJnt , startGuider)
	startJnt.translate.set (0,0,0)
	startJnt.visibility.set (0)
	pm.setAttr ( startJnt.visibility , lock=True  )
	
	
	endJnt = pm.joint (  n = endGuider.name()+"_guideCrvJnt" )
	pm.parent (endJnt , endGuider)
	endJnt.translate.set (0,0,0)
	endJnt.visibility.set (0)
	pm.setAttr ( endJnt.visibility , lock=True  )
	
	startJntPos = pm.xform ( startJnt , q=True , ws=True , t=True)
	endJntPos = pm.xform ( endJnt , q=True , ws=True , t=True)
	
	guideCrv = pm.curve ( degree=1 , p = (startJntPos ,endJntPos) , k=(1,2)  )
	
	pm.rename ( guideCrv , startGuider.name()+"_guideCrv")
	
	pm.skinCluster ( guideCrv , startJnt , endJnt  )
	
	guideCrv.inheritsTransform.set(0)
	guideCrv.template.set(1)
	
	pm.select(clear=True)
	
	return guideCrv
Example #27
0
def bdRenameChain(chain1, chain2,side=''):
    if side == '':
        for i in range(len(chain1)):
            pm.rename(chain1[i],chain2[i])
    elif side == 'Right':
        for i in range(len(chain1)):
            pm.rename(chain1[i].replace('Left','Right'),chain2[i].replace('Left','Right'))
Example #28
0
 def build_twist_deform(self, *args):
     """ builds a curve with 3 cv's controled by clusters
     Args:
         None
     Returns (None)
     """
     surf_wireShp_name = self.flexiPlaneNameField.getText() + '_flexiPlane_wire_bShp_SURF'
     wireNode_name = self.flexiPlaneNameField.getText() + '_flexiPlane_bShp_wireNode_SURF'
     twistNode_name = self.flexiPlaneNameField.getText() + '_flexiPlane_bShp_twistNode_SURF'
     twistHandle_name = self.flexiPlaneNameField.getText() + '_flexiPlane_twist_Handle'
     surf_bShpGRP_name = self.flexiPlaneNameField.getText() + '_flexiPlane_bShp_GRP'
     
     pm.select( surf_wireShp_name, r = True )
     twist_deformer = mel.eval("nonLinear -type twist -lowBound -1 -highBound 1 -startAngle 0 -endAngle 0;")[0]
     
     twistSurf_inputList = pm.listConnections( surf_wireShp_name + 'Shape' )
     pm.rename( twistSurf_inputList [-3] , twistNode_name )
     
     twistNode_inputList = pm.listConnections( twistNode_name )
     pm.rename( twistNode_inputList [-1] , twistHandle_name )
     pm.setAttr( twistHandle_name + '.rotateZ', 90 )
     pm.reorderDeformers( wireNode_name, twistNode_name, surf_wireShp_name )
     pm.parent( twistHandle_name, surf_bShpGRP_name )
     
     pm.select( cl = True )
Example #29
0
def symCtrl(s, root):
    parent = pm.listRelatives(s, parent = True)
    children = pm.listRelatives(s, children = True, type = 'transform')
    # deparent children
    for c in children:
        c.setParent(world = True)
    # duplicate group parent
    for p in parent :
        newGroup = pm.duplicate(parent, renameChildren = True, name = p.name().replace('R_', 'L_'))
    # rename children
    child = pm.listRelatives(newGroup, children = True, type = 'transform')
    
    print(child)
    for c in child:
        pm.rename(c, c.name().replace('R_', 'L_'))
    # reparent children
    for c in children:
        c.setParent(s)
        # deparent copy 
        print(children)
    
    tempGrp = pm.group(em = True, world  = True, name = "tempMirrorGrp" )
    for grp in newGroup:
        grp.setParent(tempGrp)
     # reverse
        tempGrp.scaleX.set(-1)
    # parent copy group parent to world to world
        grp.setParent(world = True)
    # parent copy to facial 'facial_ctrl_grp'
        grp.setParent(root)
        pm.delete(tempGrp)
def makeNull():
	#pm.melGlobals.initVar( 'string[]', 'KinectSkelNames' )
	i=0
	for i in range(0,24):
		pm.spaceLocator(p=(0, 0, 0),n=KinectSkelNames[i])
		
	pm.spaceLocator(p=(0, 0, 0),n="KINECT_HAND")
	

	for i in range(0,15):
		point[i] = [0.0,0.0,0.0]

	makeSkel()
	
	for i in range(0,15):
	    pm.rename('joint'+str(i+1), KinectSkelJoints[i]+'_jt')

		
	for i in range(0,15):
	    pm.pointConstraint( KinectSkelJoints[i], KinectSkelJoints[i]+'_jt' )
	    pm.orientConstraint( KinectSkelJoints[i], KinectSkelJoints[i]+'_jt' )

    #Create Camera
	cam = pm.camera()[1]
	#print pm.camera(cam, query=True, aspectRatio=True)
	cam.setAspectRatio(3)
	print cam.getAspectRatio()
	def renameMultiMatteRE(self, mMRE):
		
		#rename
		pm.rename(mMRE, 'rbMmRenderElement')
		
		#SetAttrs on mMRE
		pm.setAttr(mMRE.vray_name_multimatte, mMRE.name())
def FTV_createMainFluidTextViewControl( inputsGrp , fluidSpaceTransform):
	''' creation of the main control for the viewer'''
	circle = pm.circle( n='fluidTextureViewerCtrl#', c=(0,0,0), nr=(0,1,0), sw=360, r=1, ut=False,s=8, ch=False )
	pm.parent(circle[0],fluidSpaceTransform,r=True)

	size = 0.5
	ptList = [(-size,-size,-size), (size,-size,-size), (size,-size,size), (-size,-size,size), (-size,-size,-size), (-size,size,-size), (size,size,-size), (size,size,size), (-size,size,size), (-size,size,-size), (size,size,-size),(size,-size,-size),(size,-size,size),(size,size,size),(-size,size,size),(-size,-size,size)]
	cube = pm.curve( p = ptList, d=1, n='tempNameCubeNurbs#')

	grpDummyTransform = pm.group(em=True,n='dummyFluidSizeToMatrix#')

	pm.connectAttr( inputsGrp+'.dimensionsW', grpDummyTransform+'.scaleX')
	pm.connectAttr( inputsGrp+'.dimensionsH', grpDummyTransform+'.scaleY')
	pm.connectAttr( inputsGrp+'.dimensionsD', grpDummyTransform+'.scaleZ')
	FTV_lockAndHide( grpDummyTransform, ['tx','ty','tz','rx','ry','rz','sx','sy','sz','v'])

	circleShape = FTV_createTransformedGeometry(circle,'local', 'create',grpDummyTransform)
	cubeShape = FTV_createTransformedGeometry(cube,'local', 'create',grpDummyTransform)
	pm.setAttr(cubeShape+'.template',True)
	allCubeShapes = pm.listRelatives(cube,s=True)
	parentShapeRes = pm.parent(allCubeShapes, circle, add=True, s=True)

	pm.delete(cube)
	pm.rename( parentShapeRes[0],'BBFluidShapeSrc#' )
	retShape = pm.rename( parentShapeRes[1],'BBFluidShape#' )

	FTV_lockAndHide(circle[0], ['rx','ry','rz','sx','sy','sz','v'])

	# attributes connections
	addMainAttributesToObject(circle[0],True)
	FTV_multiConnectAutoKeyableNonLocked( circle[0], inputsGrp, ['translateX','translateY','translateZ'])

	pm.parent(grpDummyTransform,fluidSpaceTransform,r=True)

	return circle[0], retShape
def main():
	prefRun()
	
	for s in pm.selected():
		old_name = s.name()
		new_name = cameraUp(old_name)
		pm.rename(old_name, new_name)
		print old_name, "->", new_name
Example #34
0
 def renameAllTextureNodes(cls, *args, **kwargs):
   """ rename texture nodes based on the name of linked file """
   textures = pm.ls(exactType='file')
   for tex in textures:
     if tex.fileTextureName.get() != "":
       path = tex.fileTextureName.get()
       fileName = 'tx_'+os.path.split(path)[1].split('.')[0]
       pm.rename(tex, fileName)
Example #35
0
 def fixNamespaceNames(cls, *args, **kwargs):
   ''' '''
   sel = pm.ls(sl=True)
   if sel:
     for obj in sel:
       if obj.find(':') != -1:
         newName = obj.split(':')[1]
         pm.rename(sel, newName)