def createTransformAttributesSection(self, sectionName, attrsToAdd): # Get the xformOp order and add those attributes (in order) # followed by the xformOp order attribute. allAttrs = self.attrS.attributeNames geomX = UsdGeom.Xformable(self.prim) xformOps = geomX.GetOrderedXformOps() xformOpOrderNames = [op.GetOpName() for op in xformOps] xformOpOrderNames.append(UsdGeom.Tokens.xformOpOrder) # Don't use createSection because we want a sub-sections. with ufeAeTemplate.Layout(self, sectionName): with ufeAeTemplate.Layout(self, 'Transform Attributes'): attrsToAdd.remove(UsdGeom.Tokens.xformOpOrder) self.addControls(xformOpOrderNames) # Get the remainder of the xformOps and add them in an Unused section. xformOpUnusedNames = fnmatch.filter(allAttrs, 'xformOp:*') xformOpUnusedNames = [ ele for ele in xformOpUnusedNames if ele not in xformOpOrderNames ] self.createSection('Unused Transform Attributes', xformOpUnusedNames, collapse=True) # Then add any reamining Xformable attributes self.addControls(attrsToAdd) # Add a custom control for UFE attribute changed. t3dObs = UfeAttributesObserver(self.item) self.defineCustom(t3dObs)
def createMetadataSection(self): # We don't use createSection() because these are metadata (not attributes). with ufeAeTemplate.Layout(self, 'Metadata', collapse=True): metaDataControl = MetaDataCustomControl(self.prim) usdNoticeControl = NoticeListener(self.prim, [metaDataControl]) self.defineCustom(metaDataControl) self.defineCustom(usdNoticeControl)
def createSection(self, layoutName, attrList, collapse=False): # We create the section named "layoutName" if at least one # of the attributes from the input list exists. for attr in attrList: if self.attrS.hasAttribute(attr): with ufeAeTemplate.Layout(self, layoutName, collapse): # Note: addControls will silently skip any attributes # which does not exist. self.addControls(attrList) return
def createTransformAttributesSection(self, ufeSceneItem, sectionName, attrsToAdd): # Get the xformOp order and add those attributes (in order) # followed by the xformOp order attribute. allAttrs = self.attrS.attributeNames prim = mayaUsd.ufe.getPrimFromRawItem(ufeSceneItem.getRawAddress()) geomX = UsdGeom.Xformable(prim) xformOps = geomX.GetOrderedXformOps() xformOpOrderNames = [op.GetOpName() for op in xformOps] xformOpOrderNames.append(UsdGeom.Tokens.xformOpOrder) # Don't use createSection because we want a sub-sections. with ufeAeTemplate.Layout(self, sectionName): with ufeAeTemplate.Layout(self, 'Transform Attributes'): attrsToAdd.remove(UsdGeom.Tokens.xformOpOrder) self.addControls(xformOpOrderNames) # Get the remainder of the xformOps and add them in an Unused section. xformOpUnusedNames = fnmatch.filter(allAttrs, 'xformOp:*') xformOpUnusedNames = [ele for ele in xformOpUnusedNames if ele not in xformOpOrderNames] self.createSection('Unused Transform Attributes', xformOpUnusedNames, collapse=True) # Then add any reamining Xformable attributes self.addControls(attrsToAdd)
def createAppliedSchemasSection(self): # USD version 0.21.2 is required because of # Usd.SchemaRegistry().GetPropertyNamespacePrefix() if Usd.GetVersion() < (0, 21, 2): return showAppliedSchemasSection = False # loop on all applied schemas and store all those # schema into a dictionary with the attributes. # Storing the schema into a dictionary allow us to # group all instances of a MultipleApply schema together # so we can later display them into the same UI section. # # By example, if UsdCollectionAPI is applied twice, UsdPrim.GetAppliedSchemas() # will return ["CollectionAPI:instance1","CollectionAPI:instance2"] but we want to group # both instance inside a "CollectionAPI" section. # schemaAttrsDict = {} appliedSchemas = self.prim.GetAppliedSchemas() for schema in appliedSchemas: if Usd.GetVersion() > (0, 21, 5): typeAndInstance = Usd.SchemaRegistry().GetTypeNameAndInstance( schema) else: typeAndInstance = Usd.SchemaRegistry().GetTypeAndInstance( schema) typeName = typeAndInstance[0] schemaType = Usd.SchemaRegistry().GetTypeFromName(typeName) if schemaType.pythonClass: isMultipleApplyAPISchema = Usd.SchemaRegistry( ).IsMultipleApplyAPISchema(typeName) if isMultipleApplyAPISchema: # get the attributes names. They will not include the namespace and instance name. instanceName = typeAndInstance[1] attrList = schemaType.pythonClass.GetSchemaAttributeNames( False, instanceName) # build the real attr name # By example, collection:lightLink:includeRoot namespace = Usd.SchemaRegistry( ).GetPropertyNamespacePrefix(typeName) prefix = namespace + ":" + instanceName + ":" attrList = [prefix + i for i in attrList] if typeName in schemaAttrsDict: schemaAttrsDict[typeName] += attrList else: schemaAttrsDict[typeName] = attrList else: attrList = schemaType.pythonClass.GetSchemaAttributeNames( False) schemaAttrsDict[typeName] = attrList # The "Applied Schemas" will be only visible if at least # one applied Schemas has attribute. if not showAppliedSchemasSection: for attr in attrList: if self.attrS.hasAttribute(attr): showAppliedSchemasSection = True break # Create the "Applied Schemas" section # with all the applied schemas if showAppliedSchemasSection: with ufeAeTemplate.Layout(self, 'Applied Schemas', collapse=True): for typeName, attrs in schemaAttrsDict.items(): typeName = self.sectionNameFromSchema(typeName) self.createSection(typeName, attrs, False)