def _enableControl(nodeName, attrName, constraintType, supportedTypes): """ A small helper function that reduces code duplication for toggling UI controls on/off based on the selected constraint type. """ cmds.editorTemplate(dimControl=(nodeName, attrName, constraintType not in supportedTypes))
def updateSoftBodyUI(nodeName): """ Called when the attribute editor UI for the soft body needs to be updated to reflect the latest attribute values. Enables and disables controls. """ logger.debug(maya.stringTable['y_SoftBodyUI.kUpdatingSoftBody'] % nodeName) generateBendConstraints = cmds.getAttr( '{0}.generateBendConstraints'.format(nodeName)) enableVolumeMatching = cmds.getAttr( '{0}.enableVolumeMatching'.format(nodeName)) enableShapeMatching = cmds.getAttr( '{0}.enableShapeMatching'.format(nodeName)) cmds.editorTemplate(dimControl=(nodeName, "bendResistance", not generateBendConstraints)) cmds.editorTemplate(dimControl=(nodeName, "volumeCoefficient", not enableVolumeMatching)) cmds.editorTemplate(dimControl=(nodeName, "maxVolumeRatio", not enableVolumeMatching)) cmds.editorTemplate(dimControl=(nodeName, "shapeCoefficient", not enableShapeMatching))
def addControls(self, controls): for c in controls: if c not in self.suppressedAttrs: if self.attributeHasConnections(c): connectionsCustomControl = ConnectionsCustomControl( self.item, self.prim, c, self.useNiceName) self.defineCustom(connectionsCustomControl, c) elif self.isArrayAttribute(c): arrayCustomControl = ArrayCustomControl( self.prim, c, self.useNiceName) self.defineCustom(arrayCustomControl, c) else: cmds.editorTemplate(addControl=[c]) self.addedAttrs.append(c)
def updateConstraintUI(nodeName): """ Called when the attribute editor UI for the rigid body constraints needs to be updated to reflect the latest attribute values. Enables and disables controls. """ logger.debug( maya.stringTable['y_RigidBodyConstraintUI.kUpdatingConstrUI'] % nodeName) # Limit Properties section constraintType = cmds.getAttr('{0}.constraintType'.format(nodeName)) for attrName in dictConstraintAttributes.keys(): _enableControl(nodeName, attrName, constraintType, dictConstraintAttributes[attrName]) linearMotorEnabled = cmds.getAttr( '{0}.linearMotorEnabled'.format(nodeName)) cmds.editorTemplate(dimControl=(nodeName, "linearMotorTargetSpeed", not linearMotorEnabled)) cmds.editorTemplate(dimControl=(nodeName, "linearMotorMaxForce", not linearMotorEnabled)) angularMotorEnabled = cmds.getAttr( '{0}.angularMotorEnabled'.format(nodeName)) cmds.editorTemplate(dimControl=(nodeName, "angularMotorTargetSpeed", not angularMotorEnabled)) cmds.editorTemplate(dimControl=(nodeName, "angularMotorMaxForce", not angularMotorEnabled))
def addControl(self, control, ann="", lab="", callback=None): """ Adds a named control Args: control (unicode): Name of control (attribute) to add ann (unicode): Annotation to appear in the tooltip (if any) lab (unicode): Nice name of attribute (if any) callback (func): Function to call if something happens """ control = [control] if callback: control.append(callback) if lab: cmds.editorTemplate(label=lab, addControl=control, ann=ann) else: cmds.editorTemplate(addControl=control, ann=ann)
def __init__(self, ufeSceneItem): self.item = ufeSceneItem self.prim = mayaUsdUfe.ufePathToPrim( ufe.PathString.string(self.item.path())) # Get the UFE Attributes interface for this scene item. self.attrS = ufe.Attributes.attributes(self.item) self.suppressedAttrs = [] self.showArrayAttributes = False if cmds.optionVar(exists="mayaUSD_AEShowArrayAttributes"): self.showArrayAttributes = cmds.optionVar( query="mayaUSD_AEShowArrayAttributes") cmds.editorTemplate(beginScrollLayout=True) self.buildUI() cmds.editorTemplate(addExtraControls=True) self.createMetadataSection() cmds.editorTemplate(endScrollLayout=True)
def __init__(self, ufeSceneItem): self.item = ufeSceneItem self.prim = mayaUsdUfe.ufePathToPrim( ufe.PathString.string(self.item.path())) # Get the UFE Attributes interface for this scene item. self.attrS = ufe.Attributes.attributes(self.item) self.addedAttrs = [] self.suppressedAttrs = [] self.showArrayAttributes = False if cmds.optionVar(exists="mayaUSD_AEShowArrayAttributes"): self.showArrayAttributes = cmds.optionVar( query="mayaUSD_AEShowArrayAttributes") # Should we display nice names in AE? self.useNiceName = True if cmds.optionVar(exists='attrEditorIsLongName'): self.useNiceName = (cmds.optionVar(q='attrEditorIsLongName') == 1) cmds.editorTemplate(beginScrollLayout=True) self.buildUI() self.createAppliedSchemasSection() self.createCustomExtraAttrs() self.createMetadataSection() cmds.editorTemplate(endScrollLayout=True) if ('%s.%s' % (cmds.about(majorVersion=True), cmds.about(minorVersion=True))) > '2022.1': # Because of how we dynamically build the Transform attribute section, # we need this template to rebuild each time it is needed. This will # also restore the collapse/expand state of the sections. # Note: in Maya 2022 all UFE templates were forcefully rebuilt, but # no restore of section states. try: cmds.editorTemplate(forceRebuild=True) except: pass
def __enter__(self): cmds.editorTemplate(beginScrollLayout=True)
def editorTemplate(nodeName): with EditorTemplateBeginScrollLayout(): mel.eval('AEtransformMain "%s"' % nodeName) with EditorTemplateBeginLayout('Usd', collapse=False): cmds.editorTemplate( 'AEpxrUsdReferenceAssemblyTemplate_filePath_New', 'AEpxrUsdReferenceAssemblyTemplate_filePath_Replace', 'filePath', callCustom=True) #cmds.editorTemplate('filePath', addControl=True) cmds.editorTemplate('primPath', addControl=True) cmds.editorTemplate('excludePrimPaths', addControl=True) cmds.editorTemplate('time', addControl=True) cmds.editorTemplate('complexity', addControl=True) # Note: Specifying python functions directly here does not seem to work. # It looks like callCustom expects MEL functions. cmds.editorTemplate( 'AEpxrUsdReferenceAssemblyTemplate_variantSets_New', 'AEpxrUsdReferenceAssemblyTemplate_variantSets_Replace', '', callCustom=True) #cmds.editorTemplate('variantSets', addControl=True) mel.eval('AEtransformNoScroll "%s"' % nodeName) cmds.editorTemplate(addExtraControls=True) # suppresses attributes cmds.editorTemplate(suppress='kind') cmds.editorTemplate(suppress='initialRep') cmds.editorTemplate(suppress='inStageData') cmds.editorTemplate(suppress='assemblyEdits') cmds.editorTemplate(suppress='blackBox') cmds.editorTemplate(suppress='rmbCommand') cmds.editorTemplate(suppress='templateName') cmds.editorTemplate(suppress='templatePath') cmds.editorTemplate(suppress='viewName') cmds.editorTemplate(suppress='iconName') cmds.editorTemplate(suppress='viewMode') cmds.editorTemplate(suppress='templateVersion') cmds.editorTemplate(suppress='uiTreatment') cmds.editorTemplate(suppress='customTreatment') cmds.editorTemplate(suppress='creator') cmds.editorTemplate(suppress='creationDate') cmds.editorTemplate(suppress='containerType') cmds.editorTemplate(suppress='publishedNode') cmds.editorTemplate(suppress='publishedNodeInfo') cmds.editorTemplate(suppress='publishedNodeType')
def aiSwatchDisplay(nodeName): cmds.editorTemplate(aeCallback(aiSwatchDisplayNew), aeCallback(aiSwatchDisplayReplace), "message", callCustom=True)
def __enter__(self): cmds.editorTemplate(beginLayout=self.name, collapse=self.collapse)
def editorTemplate(nodeName): with EditorTemplateBeginScrollLayout(): mel.eval('AEtransformMain "%s"'%nodeName) with EditorTemplateBeginLayout('Usd', collapse=False): cmds.editorTemplate( 'AEpxrUsdReferenceAssemblyTemplate_filePath_New', 'AEpxrUsdReferenceAssemblyTemplate_filePath_Replace', 'filePath', callCustom=True) #cmds.editorTemplate('filePath', addControl=True) cmds.editorTemplate('primPath', addControl=True) cmds.editorTemplate('excludePrimPaths', addControl=True) cmds.editorTemplate('time', addControl=True) cmds.editorTemplate('complexity', addControl=True) cmds.editorTemplate('tint', addControl=True) cmds.editorTemplate('tintColor', addControl=True) # Note: Specifying python functions directly here does not seem to work. # It looks like callCustom expects MEL functions. cmds.editorTemplate( 'AEpxrUsdReferenceAssemblyTemplate_variantSets_New', 'AEpxrUsdReferenceAssemblyTemplate_variantSets_Replace', '', callCustom=True) #cmds.editorTemplate('variantSets', addControl=True) mel.eval('AEtransformNoScroll "%s"'%nodeName) cmds.editorTemplate(addExtraControls=True) # suppresses attributes cmds.editorTemplate(suppress='kind') cmds.editorTemplate(suppress='initialRep') cmds.editorTemplate(suppress='inStageData') cmds.editorTemplate(suppress='assemblyEdits') cmds.editorTemplate(suppress='blackBox') cmds.editorTemplate(suppress='rmbCommand') cmds.editorTemplate(suppress='templateName') cmds.editorTemplate(suppress='templatePath') cmds.editorTemplate(suppress='viewName') cmds.editorTemplate(suppress='iconName') cmds.editorTemplate(suppress='viewMode') cmds.editorTemplate(suppress='templateVersion') cmds.editorTemplate(suppress='uiTreatment') cmds.editorTemplate(suppress='customTreatment') cmds.editorTemplate(suppress='creator') cmds.editorTemplate(suppress='creationDate') cmds.editorTemplate(suppress='containerType') cmds.editorTemplate(suppress='publishedNode') cmds.editorTemplate(suppress='publishedNodeInfo') cmds.editorTemplate(suppress='publishedNodeType')
def addControls(self, controls): for c in controls: if c not in self.suppressedAttrs: cmds.editorTemplate(addControl=[c])
def __exit__(self, mytype, value, tb): cmds.editorTemplate(endLayout=True)
def separator(): """ Adds a separator to the template. """ cmds.editorTemplate(addSeparator=True)
def __exit__(self, type, value, traceback): cmds.editorTemplate(endLayout=True)
def suppress(self, control): cmds.editorTemplate(suppress=control) self.suppressedAttrs.append(control)
def defineCustom(customObj, attrs=[]): create = lambda *args: customObj.onCreate(args) replace = lambda *args: customObj.onReplace(args) cmds.editorTemplate(attrs, callCustom=[create, replace])
def configuration_settings_sampler_callback(self, node): if cmds.getAttr(node + '.sampler') == 0: # adaptive cmds.editorTemplate(dimControl=[node, 'adaptive_min_samples', False]) cmds.editorTemplate(dimControl=[node, 'adaptive_max_samples', False]) cmds.editorTemplate(dimControl=[node, 'adaptive_quality', False]) cmds.editorTemplate(dimControl=[node, 'uniform_samples', True]) cmds.editorTemplate(dimControl=[node, 'uniform_decorrelate_pixels', True]) else: # uniform cmds.editorTemplate(dimControl=[node, 'adaptive_min_samples', True]) cmds.editorTemplate(dimControl=[node, 'adaptive_max_samples', True]) cmds.editorTemplate(dimControl=[node, 'adaptive_quality', True]) cmds.editorTemplate(dimControl=[node, 'uniform_samples', False]) cmds.editorTemplate(dimControl=[node, 'uniform_decorrelate_pixels', False])
def EnableLayerChange(self,plugName): enabledAttr = '{}.{}'.format(self.nodeName, plugName) dimLayer = (cmds.getAttr(enabledAttr) == 0) dimLayerInverse = (cmds.getAttr(enabledAttr) == 1) getMelaninStatus = '{}.{}'.format(self.nodeName, plugName.replace('Layer ', 'outputMelanin_L')) dimLayer_global = (cmds.getAttr(getMelaninStatus) ==0) dimLayerInverse_global= (cmds.getAttr(getMelaninStatus) ==1) #if plugName[0:13]=='outputMelanin': # enabledAttr_melanin = '{}.{}'.format(self.nodeName, plugName) # dimLayer_global = (cmds.getAttr(enabledAttr_melanin)==0) # dimLayerInverse_global = (cmds.getAttr(enabledAttr_melanin)==1) if plugName[0:13]=='outputMelanin': cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('outputMelanin_', 'melaninRoot_'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('outputMelanin_', 'melaninTip_'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('outputMelanin_', 'rootColor_'), dimLayerInverse )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('outputMelanin_', 'tipColor_'), dimLayerInverse )) else: cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'outputMelanin_L'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'melaninRoot_L'), dimLayer_global if(dimLayerInverse==True) else dimLayer)) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'melaninTip_L'), dimLayer_global if(dimLayerInverse==True) else dimLayer)) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'rootColor_L'), dimLayerInverse_global if(dimLayerInverse==True) else dimLayer)) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'tipColor_L'), dimLayerInverse_global if(dimLayerInverse==True) else dimLayer)) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'probability_L'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'pos_L'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'soft_L'), dimLayer )) cmds.editorTemplate(dimControl=(self.nodeName, plugName.replace('Layer ', 'posDir_L'), dimLayer ))
def aiSwatchDisplay(nodeName) : cmds.editorTemplate(aeCallback(aiSwatchDisplayNew), aeCallback(aiSwatchDisplayReplace), "message", callCustom=True)