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]
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)
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]
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]
def __init__(self, attr, frame): super(_ArrayAttributeModel, self).__init__() self.val = attr.Get(frame) from scalarTypes import GetScalarTypeFromAttr self._scalarTypeName, _ = GetScalarTypeFromAttr(attr)
def SetAttribute(self, attr, frame): from scalarTypes import GetScalarTypeFromAttr arrayData = attr.Get(frame) scalarTypeName, _ = GetScalarTypeFromAttr(attr) self._arrayAttrModel.SetArrayDataAndTypeName(arrayData, scalarTypeName)