def doTransferTo(self, target):
        """ 
        Transfer an instanced attribute to a target with all settings and connections intact
        
        Keyword arguments:
        target(string) -- object to transfer it to
        *a, **kw
        """
        assert mc.objExists(target), "'%s' doesn't exist" % target
        assert mc.ls(target, type='transform',
                     long=True), "'%s' Doesn't have a transform" % target
        assert self.obj.transform is not False, "'%s' Doesn't have a transform. Transferring this attribute is probably a bad idea. Might we suggest doCopyTo along with a connect to source option" % self.obj.nameShort
        assert mc.ls(target, long=True) != [self.obj.nameShort
                                            ], "Can't transfer to self!"
        assert '.' not in list(
            target
        ), "'%s' appears to be an attribute. Can't transfer to an attribute." % target
        assert self.dynamic is True, "'%s' is not a dynamic attribute." % self.nameCombined

        #mc.copyAttr(self.obj.nameShort,self.target.obj.nameShort,attribute = [self.target.attr],v = True,ic=True,oc=True,keepSourceConnections=True)
        attributes.doCopyAttr(self.obj.nameShort,
                              self.nameLong,
                              target,
                              self.nameLong,
                              convertToMatch=True,
                              values=True,
                              inputConnections=True,
                              outgoingConnections=True,
                              keepSourceConnections=False,
                              copyAttrSettings=True,
                              connectSourceToTarget=False)
        self.doDelete()
Exemple #2
0
    def doTransferTo(self,target):
        """ 
        Transfer an instanced attribute to a target with all settings and connections intact
        
        Keyword arguments:
        target(string) -- object to transfer it to
        *a, **kw
        """ 
        assert mc.objExists(target),"'%s' doesn't exist"%target
        assert mc.ls(target,type = 'transform',long = True),"'%s' Doesn't have a transform"%target
        assert self.obj.transform is not False,"'%s' Doesn't have a transform. Transferring this attribute is probably a bad idea. Might we suggest doCopyTo along with a connect to source option"%self.obj.nameShort        
        assert mc.ls(target,long=True) != [self.obj.nameShort], "Can't transfer to self!"
        assert '.' not in list(target),"'%s' appears to be an attribute. Can't transfer to an attribute."%target
        assert self.dynamic is True,"'%s' is not a dynamic attribute."%self.nameCombined
        
        #mc.copyAttr(self.obj.nameShort,self.target.obj.nameShort,attribute = [self.target.attr],v = True,ic=True,oc=True,keepSourceConnections=True)
        attributes.doCopyAttr(self.obj.nameShort,
                              self.nameLong,
                              target,
                              self.nameLong,
                              convertToMatch = True,
                              values = True, incomingConnections = True,
                              outgoingConnections = True, keepSourceConnections = False,
                              copyAttrSettings = True, connectSourceToTarget = False)
        self.doDelete()

            

        
        
Exemple #3
0
    def doCopyTo(self,target, targetAttrName = None, convertToMatch = True, values = True, incomingConnections = False, outgoingConnections = False, keepSourceConnections = True, copyAttrSettings = True, connectSourceToTarget = False):
        """                                     
        Replacement for Maya's since maya's can't handle shapes....blrgh...
        Copy attributes from one object to another as well as other options. If the attribute already
        exists, it'll copy the values. If it doesn't, it'll make it. If it needs to convert, it can.
        It will not make toast.
    
        Keywords:
        toObject(string) - obj to copy to
        targetAttrName(string) -- name of the attr to copy to . Default is None which will create an 
                          attribute of the fromAttr name on the toObject if it doesn't exist
        convertToMatch(bool) -- whether to convert if necessary.default True        
        values(bool) -- copy values. default True
        incomingConnections(bool) -- default False
        outGoingConnections(bool) -- default False
        keepSourceConnections(bool)-- keeps connections on source. default True
        copyAttrSettings(bool) -- copy the attribute state of the fromAttr (keyable,lock,hidden). default True
        connectSourceToTarget(bool) useful for moving attribute controls to another object. default False
        
        RETURNS:
        success(bool)
        """
        assert mc.objExists(target),"'%s' doesn't exist"%target
        assert mc.ls(target,long=True) != [self.obj.nameShort], "Can't transfer to self!"
        
        copyTest = [values,incomingConnections,outgoingConnections,keepSourceConnections,connectSourceToTarget,copyAttrSettings]
        
        if sum(copyTest) < 1:
            guiFactory.warning("You must have at least one option for copying selected. Otherwise, you're looking for the 'doDuplicate' function.")            
            return False

        if '.' in list(target):
            targetBuffer = target.split('.')
            if len(targetBuffer) == 2:
                attributes.doCopyAttr(self.obj.nameShort,
                                      self.nameLong,
                                      targetBuffer[0],
                                      targetBuffer[1],
                                      convertToMatch,
                                      values, incomingConnections,
                                      outgoingConnections, keepSourceConnections,
                                      copyAttrSettings, connectSourceToTarget)               

            else:
                guiFactory.warning("Yeah, not sure what to do with this. Need an attribute call with only one '.'")
        else:
            attributes.doCopyAttr(self.obj.nameShort,
                                  self.nameLong,
                                  target,
                                  targetAttrName, convertToMatch,
                                  values, incomingConnections,
                                  outgoingConnections, keepSourceConnections,
                                  copyAttrSettings, connectSourceToTarget)  
Exemple #4
0
    def copy(self):
        """ Purge all set memebers from a set """
        
        try:
            buffer = mc.sets(name = ('%s_Copy'%self.nameShort), copy = self.nameLong)
            guiFactory.report("'%s' duplicated!"%(self.nameLong))
	    
	    for attr in dictionary.cgmNameTags:
		if mc.objExists("%s.%s"%(self.nameLong,attr)):
		    attributes.doCopyAttr(self.nameLong,attr,buffer)
		
	    return buffer
        except:
            guiFactory.warning("'%s' failed to copy"%(self.nameLong)) 
    def copy(self):
        """ Purge all set memebers from a set """

        try:
            buffer = mc.sets(name=('%s_Copy' % self.nameShort),
                             copy=self.nameLong)
            guiFactory.report("'%s' duplicated!" % (self.nameLong))

            for attr in dictionary.cgmNameTags:
                if mc.objExists("%s.%s" % (self.nameLong, attr)):
                    attributes.doCopyAttr(self.nameLong, attr, buffer)

            return buffer
        except:
            guiFactory.warning("'%s' failed to copy" % (self.nameLong))
Exemple #6
0
 def getNameTagsFromObject(self,target,ignore=[False]):
     """
     Get name tags from a target object (connected)
     
     Keywords
     ignore(list) - tags to ignore
     
     Returns
     success(bool)
     """
     targetCGM = NameFactory.returnObjectGeneratedNameDict(target,ignore = ignore)
     didSomething = False
     
     for tag in targetCGM.keys():
         if tag not in ignore and targetCGM[tag] is not None or False:
             attributes.doCopyAttr(target,tag,
                                   self.nameLong,connectTargetToSource=True)
             didSomething = True
     return didSomething
Exemple #7
0
        def _copyTransform(self):		    
            copyTransform = self.d_kws['copyTransform']
            if copyTransform is not None:
                if issubclass(type(copyTransform),cgmMeta.cgmNode):
                    i_target = copyTransform
                elif mc.objExists(copyTransform):
                    i_target = cgmMeta.cgmObject(copyTransform)
                else:
                    raise StandardError,"Failed to find suitable copyTransform object: '%s"%copyTransform

                #Need to move this to default cgmNode stuff
                mBuffer = self.mi_control
                i_newTransform = cgmMeta.cgmObject( rigging.groupMeObject(i_target.mNode,False) )
                for a in mc.listAttr(self.mi_control.mNode, userDefined = True):
                    attributes.doCopyAttr(self.mi_control.mNode,a,i_newTransform.mNode)
                curves.parentShapeInPlace(i_newTransform.mNode,self.mi_control.mNode)#Parent shape
                i_newTransform.parent = self.mi_control.parent#Copy parent
                self.mi_control = cgmMeta.asMeta(i_newTransform,'cgmControl', setClass=True)
                mc.delete(mBuffer.mNode)
        def _copyTransform(self):		    
            copyTransform = self.d_kws['copyTransform']
            if copyTransform is not None:
                if issubclass(type(copyTransform),cgmMeta.cgmNode):
                    i_target = copyTransform
                elif mc.objExists(copyTransform):
                    i_target = cgmMeta.cgmObject(copyTransform)
                else:
                    raise StandardError,"Failed to find suitable copyTransform object: '%s"%copyTransform

                #Need to move this to default cgmNode stuff
                mBuffer = self.mi_control
                i_newTransform = cgmMeta.cgmObject( rigging.groupMeObject(i_target.mNode,False) )
                for a in mc.listAttr(self.mi_control.mNode, userDefined = True):
                    attributes.doCopyAttr(self.mi_control.mNode,a,i_newTransform.mNode)
                curves.parentShapeInPlace(i_newTransform.mNode,self.mi_control.mNode)#Parent shape
                i_newTransform.parent = self.mi_control.parent#Copy parent
                self.mi_control = cgmMeta.asMeta(i_newTransform,'cgmControl', setClass=True)
                mc.delete(mBuffer.mNode)
    def doCopyTo(self, target, targetAttrName=None, debug=True, *a, **kw):
        """                                     
        Replacement for Maya's since maya's can't handle shapes....blrgh...
        Copy attributes from one object to another as well as other options. If the attribute already
        exists, it'll copy the values. If it doesn't, it'll make it. If it needs to convert, it can.
        It will not make toast.
    
        Keywords:
        toObject(string) - obj to copy to
        targetAttrName(string) -- name of the attr to copy to . Default is None which will create an 
                          attribute oft the fromAttr name on the toObject if it doesn't exist
        convertToMatch(bool) -- whether to convert if necessary.default True        
        values(bool) -- copy values. default True
        inputConnections(bool) -- default False
        outGoingConnections(bool) -- default False
        keepSourceConnections(bool)-- keeps connections on source. default True
        copyAttrSettings(bool) -- copy the attribute state of the fromAttr (keyable,lock,hidden). default True
        connectSourceToTarget(bool) useful for moving attribute controls to another object. default False
        
        RETURNS:
        success(bool)
        """
        assert mc.objExists(target), "'%s' doesn't exist" % target
        assert mc.ls(target, long=True) != [self.obj.nameShort
                                            ], "Can't transfer to self!"
        functionName = 'doCopyTo'

        convertToMatch = kw.pop('convertToMatch', True)
        values = kw.pop('values', True)
        inputConnections = kw.pop('inputConnections', False)
        outgoingConnections = kw.pop('outgoingConnections', False)
        keepSourceConnections = kw.pop('keepSourceConnections', True)
        copyAttrSettings = kw.pop('copyAttrSettings', True)
        connectSourceToTarget = kw.pop('connectSourceToTarget', False)
        connectTargetToSource = kw.pop('connectTargetToSource', False)

        if debug:
            guiFactory.doPrintReportStart(functionName)
            guiFactory.report("AttrFactory instance: '%s'" % self.nameCombined)
            guiFactory.report("convertToMatch: '%s'" % convertToMatch)
            guiFactory.report("targetAttrName: '%s'" % targetAttrName)
            guiFactory.report("inputConnections: '%s'" % inputConnections)
            guiFactory.report("outgoingConnections: '%s'" %
                              outgoingConnections)
            guiFactory.report("keepSourceConnections: '%s'" %
                              keepSourceConnections)
            guiFactory.report("copyAttrSettings: '%s'" % copyAttrSettings)
            guiFactory.report("connectSourceToTarget: '%s'" %
                              connectSourceToTarget)
            guiFactory.report("keepSourceConnections: '%s'" %
                              keepSourceConnections)
            guiFactory.report("connectTargetToSource: '%s'" %
                              connectTargetToSource)
            guiFactory.doPrintReportBreak()

        copyTest = [
            values, inputConnections, outgoingConnections,
            keepSourceConnections, connectSourceToTarget, copyAttrSettings
        ]

        if sum(copyTest) < 1:
            guiFactory.warning(
                "You must have at least one option for copying selected. Otherwise, you're looking for the 'doDuplicate' function."
            )
            return False

        if '.' in list(target):
            targetBuffer = target.split('.')
            if len(targetBuffer) == 2:
                attributes.doCopyAttr(
                    self.obj.nameShort,
                    self.nameLong,
                    targetBuffer[0],
                    targetBuffer[1],
                    convertToMatch=convertToMatch,
                    values=values,
                    inputConnections=inputConnections,
                    outgoingConnections=outgoingConnections,
                    keepSourceConnections=keepSourceConnections,
                    copyAttrSettings=copyAttrSettings,
                    connectSourceToTarget=connectSourceToTarget)

            else:
                guiFactory.warning(
                    "Yeah, not sure what to do with this. Need an attribute call with only one '.'"
                )
        else:
            attributes.doCopyAttr(self.obj.nameShort,
                                  self.nameLong,
                                  target,
                                  targetAttrName,
                                  convertToMatch=convertToMatch,
                                  values=values,
                                  inputConnections=inputConnections,
                                  outgoingConnections=outgoingConnections,
                                  keepSourceConnections=keepSourceConnections,
                                  copyAttrSettings=copyAttrSettings,
                                  connectSourceToTarget=connectSourceToTarget)
        if debug:
            guiFactory.doPrintReportEnd(functionName)