Пример #1
0
def GetShortStringForValue(prop, val):
    if isinstance(prop, Usd.Relationship):
        val = ", ".join(str(p) for p in val)
    elif isinstance(prop, Sdf.RelationshipSpec):
        return str(prop.targetPathList)

    # If there is no value opinion, we do not want to display anything,
    # since python 'None' has a different meaning than usda-authored None,
    # which is how we encode attribute value blocks (which evaluate to 
    # Sdf.ValueBlock)
    if val is None:
        return ''
    
    from scalarTypes import GetScalarTypeFromAttr
    scalarType, isArray = GetScalarTypeFromAttr(prop)
    result = ''
    if isArray and not isinstance(val, Sdf.ValueBlock):
        def arrayToStr(a):
            from itertools import chain
            elems = a if len(a) <= 6 else chain(a[:3], ['...'], a[-3:])
            return '[' + ', '.join(map(str, elems)) + ']'
        if val is not None and len(val):
            result = "%s[%d]: %s" % (scalarType, len(val), arrayToStr(val))
        else:
            result = "%s[]" % scalarType
    else:
        result = str(val)

    return result[:500]
Пример #2
0
 def __init__(self, attr, frame):
     super(_ArrayAttributeModel, self).__init__()
     self.val = attr.Get(frame)
     self._rowCount = 0 if self.val is None else len(self.val)
     self._publishedRows = 0
     from scalarTypes import GetScalarTypeFromAttr
     self._scalarTypeName, _ = GetScalarTypeFromAttr(attr)
Пример #3
0
def GetShortString(prop, frame):
    if isinstance(prop, Usd.Relationship):
        val = ", ".join(str(p) for p in prop.GetTargets())
    elif isinstance(prop, (Usd.Attribute, CustomAttribute)):
        val = prop.Get(frame)
    elif isinstance(prop, Sdf.AttributeSpec):
        if frame == Usd.TimeCode.Default():
            val = prop.default
        else:
            numTimeSamples = -1
            if prop.HasInfo('timeSamples'):
                numTimeSamples = prop.layer.GetNumTimeSamplesForPath(prop.path)
            if numTimeSamples == -1:
                val = prop.default
            elif numTimeSamples == 1:
                return "1 time sample"
            else:
                return str(numTimeSamples) + " time samples"
    elif isinstance(prop, Sdf.RelationshipSpec):
        return str(prop.targetPathList)

    # If there is no value opinion, we do not want to display anything,
    # since python 'None' has a different meaning than usda-authored None,
    # which is how we encode attribute value blocks (which evaluate to
    # Sdf.ValueBlock)
    if val is None:
        return ''

    from scalarTypes import GetScalarTypeFromAttr
    scalarType, isArray = GetScalarTypeFromAttr(prop)
    result = ''
    if isArray and not isinstance(val, Sdf.ValueBlock):

        def arrayToStr(a):
            from itertools import chain
            elems = a if len(a) <= 6 else chain(a[:3], ['...'], a[-3:])
            return '[' + ', '.join(map(str, elems)) + ']'

        if val is not None and len(val):
            result = "%s[%d]: %s" % (scalarType, len(val), arrayToStr(val))
        else:
            result = "%s[]" % scalarType
    else:
        result = str(val)

    return result[:500]
Пример #4
0
def GetShortString(prop, frame):
    if isinstance(prop, Usd.Relationship):
        val = ", ".join(str(p) for p in prop.GetTargets())
    elif isinstance(prop, (Usd.Attribute, CustomAttribute)):
        val = prop.Get(frame)
    elif isinstance(prop, Sdf.AttributeSpec):
        if frame == Usd.TimeCode.Default():
            val = prop.default
        else:
            numTimeSamples = -1
            if prop.HasInfo('timeSamples'):
                numTimeSamples = prop.layer.GetNumTimeSamplesForPath(prop.path)
            if numTimeSamples == -1:
                val = prop.default
            elif numTimeSamples == 1:
                return "1 time sample"
            else:
                return str(numTimeSamples) + " time samples"
    elif isinstance(prop, Sdf.RelationshipSpec):
        return str(prop.targetPathList)

    from scalarTypes import GetScalarTypeFromAttr
    scalarType, isArray = GetScalarTypeFromAttr(prop)
    result = ''
    if isArray and not isinstance(val, Sdf.ValueBlock):

        def arrayToStr(a):
            from itertools import chain
            elems = a if len(a) <= 6 else chain(a[:3], ['...'], a[-3:])
            return '[' + ', '.join(map(str, elems)) + ']'

        if val is not None and len(val):
            result = "%s[%d]: %s" % (scalarType, len(val), arrayToStr(val))
        else:
            result = "%s[]" % scalarType
    else:
        result = str(val)

    return result[:500]
Пример #5
0
    def __init__(self, attr, frame):
        super(_ArrayAttributeModel, self).__init__()

        self.val = attr.Get(frame)
        from scalarTypes import GetScalarTypeFromAttr
        self._scalarTypeName, _ = GetScalarTypeFromAttr(attr)
Пример #6
0
    def SetAttribute(self, attr, frame):
        from scalarTypes import GetScalarTypeFromAttr

        arrayData = attr.Get(frame)
        scalarTypeName, _ = GetScalarTypeFromAttr(attr)
        self._arrayAttrModel.SetArrayDataAndTypeName(arrayData, scalarTypeName)