def alembic_attribute_exists(self, alembic_path, object_path, attribute_name):
        """
        For object at object_path in alembic from alembic_path check if attribute exists.
        """

        #path exists
        if not (os.path.isfile(alembic_path)):
            #log
            self.logger.debug('Alembic file at path does not exist. Returning None')
            return False

        #alembic_query_result
        alembic_query_result = abc.alembicArbGeometry(alembic_path, object_path, attribute_name, 0)

        #object exists
        if not (alembic_query_result):
            #log
            self.logger.debug('Object path inside Alembic file does not exist. Returning False')
            return False


        #scope
        scope = alembic_query_result[2]
        
        #attr unknown
        if (scope == 'unknown'):
            #log
            self.logger.debug('Attribute for Object path inside Alembic file does not exist. Returning False')
            return False

        #return
        return True
Beispiel #2
0
    def alembic_attribute_exists(self, alembic_path, object_path, attribute_name):
        """
        For object at object_path in alembic from alembic_path check if attribute exists.
        """

        #path exists
        if not (os.path.isfile(alembic_path)):
            #log
            self.logger.debug('Alembic file at path does not exist. Returning None')
            return False

        #alembic_query_result
        alembic_query_result = abc.alembicArbGeometry(alembic_path, object_path, attribute_name, 0)

        #object exists
        if not (alembic_query_result):
            #log
            self.logger.debug('Object path inside Alembic file does not exist. Returning False')
            return False


        #scope
        scope = alembic_query_result[2]
        
        #attr unknown
        if (scope == 'unknown'):
            #log
            self.logger.debug('Attribute for Object path inside Alembic file does not exist. Returning False')
            return False

        #return
        return True
Beispiel #3
0
 def set_attr(prim, attr, from_path):
     """Try reading attribute from path in Alembic file and set to primitive
     Return `True` if operation sucess or `False`
     """
     result = abc.alembicArbGeometry(abc_file, from_path, attr, on_time)
     if result is not None:
         value, is_constane, scope = result
         if value:
             prim.setAttribValue(attr, value[0])
             return True
     return False
    def get_alembic_attribute_value(self, alembic_path, object_path, attribute_name):
        """
        For object at object_path in alembic from alembic_path get attribute value.
        """

        #check
        if not (self.alembic_attribute_exists(alembic_path, object_path, attribute_name)):
            #log
            self.logger.debug('Attribute {0} on alembic {1} at path {2} can not be retrieved. Returning None'.format(attribute_name,
                                                                                                                        alembic_path, 
                                                                                                                        object_path))
            return None

        #alembic_query_result
        alembic_query_result = abc.alembicArbGeometry(alembic_path, object_path, attribute_name, 0)

        #return
        return alembic_query_result[0]
Beispiel #5
0
    def get_alembic_attribute_value(self, alembic_path, object_path, attribute_name):
        """
        For object at object_path in alembic from alembic_path get attribute value.
        """

        #check
        if not (self.alembic_attribute_exists(alembic_path, object_path, attribute_name)):
            #log
            self.logger.debug('Attribute {0} on alembic {1} at path {2} can not be retrieved. Returning None'.format(attribute_name,
                                                                                                                        alembic_path, 
                                                                                                                        object_path))
            return None

        #alembic_query_result
        alembic_query_result = abc.alembicArbGeometry(alembic_path, object_path, attribute_name, 0)

        #return
        return alembic_query_result[0]
Beispiel #6
0
def getAbcAttr(attrName):
    """
    Gets an alembic attribute from the cache
    Requires an 'abcFileName' detail attribute
    
    @attrName: name of attribute to retrieve
    @useTransform: looks on the parent node instead. Equivalent to using maya's transform instead of shape
    """

    geo = hou.pwd().geometry()
    time = hou.frame() / hou.fps()

    if geo.findGlobalAttrib("abcFileName") is not None:
        url = geo.attribValue("abcFileName")

        for childGeo in abc.alembicGetSceneHierarchy(url, "/")[2]:
            path = "/" + childGeo[0] + "/" + childGeo[2][0][0]

            x = abc.alembicArbGeometry(url, path, attrName, time)
            if (x[1] == True):
                alert(x)
Beispiel #7
0
def getAbcAttr(attrName, useTransform=False):
    """
    Gets an alembic attribute from the cache
    Requires an 'abcFileName' detail attribute
    
    @attrName: name of attribute to retrieve
    @useTransform: looks on the parent node instead. Equivalent to using maya's transform instead of shape
    """
    geo = hou.pwd().curPrim().geometry()
    if geo.findGlobalAttrib("abcFileName") is not None:
        abcPath = geo.attribValue("abcFileName")
        
        path = hou.pwd().curPrim().attribValue("path")
        if useTransform:
            path = path.rsplit("/", 1)[0]
        
        x =  abc.alembicArbGeometry(abcPath, path, attrName, hou.frame() / hou.fps())
        if x[0]:
            return x[0][0]
        else:
            return ''