Пример #1
0
    def getMessage(self, *a, **kw):
        """ 
        Get and store attribute value as if they were messages. Used for bufferFactory to use a connected
        attribute as a poor man's attribute message function
        
        Keyword arguments:
        *a, **kw
        """
        try:
            if self.form == 'message':
                self.value = attributes.returnMessageObject(
                    self.obj.nameShort, self.attr)
                if search.returnObjectType(self.value) == 'reference':
                    if attributes.repairMessageToReferencedTarget(
                            self.obj.nameLong, self.attr, *a, **kw):
                        self.value = attributes.returnMessageObject(
                            self.obj.nameShort, self.attr)
            else:
                self.value = attributes.returnDriverAttribute(
                    "%s.%s" % (self.obj.nameShort, self.attr))

            guiFactory.report("'%s.%s' >Message> '%s'" %
                              (self.obj.nameShort, self.attr, self.value))
            return self.value

        except:
            guiFactory.warning("'%s.%s' failed to get" %
                               (self.obj.nameShort, self.attr))
Пример #2
0
def returnTagInfo(obj,tag):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Reads the data from a tag

    ARGUMENTS:
    obj(string) - object to read the tag from
    tag(string) - cgmName, cgmType, etc

    RETURNS:
    Success - read data
    Failure - false
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """   
    if (mc.objExists('%s.%s' %(obj,tag))) == True:
        messageQuery = (mc.attributeQuery (tag,node=obj,msg=True))
        if messageQuery == True:
            returnBuffer = attributes.returnMessageData(obj,tag,False)
            if not returnBuffer:
                return False
            elif returnObjectType(returnBuffer[0]) == 'reference':
                if attributes.repairMessageToReferencedTarget(obj,tag):
                    return attributes.returnMessageData(obj,tag,False)[0]
                return returnBuffer[0]
            return returnBuffer[0]
        else:
            infoBuffer = mc.getAttr('%s.%s' % (obj,tag))
            if infoBuffer is not None and len(list(str(infoBuffer))) > 0:
                return infoBuffer
            else:
                return False
    else:
        return False
Пример #3
0
def get_nodeTagInfo(node=None, tag=None):
    """
    Get the info on a given node with a provided tag
    
    :parameters:
        node(str): Object to check

    :returns
        status(bool)
    """
    _str_func = 'get_nodeTagInfo'
    _node = VALID.stringArg(node, False, _str_func)

    if (mc.objExists('%s.%s' % (_node, tag))) == True:
        messageQuery = (mc.attributeQuery(tag, node=_node, msg=True))
        if messageQuery == True:
            log.debug("|{0}| >> message...".format(_str_func))
            returnBuffer = attributes.returnMessageData(_node, tag, False)
            if not returnBuffer:
                return False
            elif VALID.get_mayaType(returnBuffer[0]) == 'reference':
                if attributes.repairMessageToReferencedTarget(_node, tag):
                    return attributes.returnMessageData(_node, tag, False)[0]
                return returnBuffer[0]
            return returnBuffer[0]
        else:
            log.debug("|{0}| >> reg...".format(_str_func))
            infoBuffer = mc.getAttr('%s.%s' % (_node, tag))
            if infoBuffer is not None and len(list(str(infoBuffer))) > 0:
                return infoBuffer
            else:
                return False
    else:
        return False
Пример #4
0
def returnTagInfo(obj, tag):
    """
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Reads the data from a tag

    ARGUMENTS:
    obj(string) - object to read the tag from
    tag(string) - cgmName, cgmType, etc

    RETURNS:
    Success - read data
    Failure - false
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    if (mc.objExists('%s.%s' % (obj, tag))) == True:
        messageQuery = (mc.attributeQuery(tag, node=obj, msg=True))
        if messageQuery == True:
            returnBuffer = attributes.returnMessageData(obj, tag, False)
            if not returnBuffer:
                return False
            elif returnObjectType(returnBuffer[0]) == 'reference':
                if attributes.repairMessageToReferencedTarget(obj, tag):
                    return attributes.returnMessageData(obj, tag, False)[0]
                return returnBuffer[0]
            return returnBuffer[0]
        else:
            infoBuffer = mc.getAttr('%s.%s' % (obj, tag))
            if infoBuffer is not None and len(list(str(infoBuffer))) > 0:
                return infoBuffer
            else:
                return False
    else:
        return False
Пример #5
0
    def getMessage(self,*a, **kw):
        """ 
        Get and store attribute value as if they were messages. Used for bufferFactory to use a connected
        attribute as a poor man's attribute message function
        
        Keyword arguments:
        *a, **kw
        """   
        try:
            if self.form == 'message':
                self.value = attributes.returnMessageObject(self.obj.nameShort,self.attr)
                if search.returnObjectType(self.value) == 'reference':
                    if attributes.repairMessageToReferencedTarget(self.obj.nameLong,self.attr,*a,**kw):
                        self.value = attributes.returnMessageObject(self.obj.nameShort,self.attr)                        
            else:
                self.value = attributes.returnDriverAttribute("%s.%s"%(self.obj.nameShort,self.attr))

            guiFactory.report("'%s.%s' >Message> '%s'"%(self.obj.nameShort,self.attr,self.value))
            return self.value
            
        except:
            guiFactory.warning("'%s.%s' failed to get"%(self.obj.nameShort,self.attr))