def isRenderEngineInstalled(self,renderEngineName): #bug fix: 06-20-2012: if mentalRay plugin not installed maya still has nodes called mentalraytexture #this prevents LCMT from not not working when the mentalray pluguin isn't installed by default if renderEngineName == 'mentalray' or renderEngineName == 'mentalRay': renderEngineName = self.MentalRayLightTypes[-1] #Arnold compatibility elif renderEngineName == 'arnold': #Since all there is no node specifically named arnold we use the #standard shader node name to see if arnold is indeed installed or no renderEngineName = 'aiStandard' #query all the types and look for Vray Types, and Renderman Types AllTypes = cmds.allNodeTypes() regex = '\w*'+renderEngineName+'\w*' to_find = re.compile(regex,re.IGNORECASE) to_search = ", ".join(AllTypes) match = re.search(to_find, to_search) if match!=None: #print 'Found',renderEngineName #print match.group() return True else: print self.version, 'Didn\'t find',renderEngineName return False
def _generate(): """ Generate a Schema instance by analysing the current session. :return: A new Schema instance :rtype: MockedSessionSchema """ # Determine empty scene default state cmds.file(new=True, force=True) default_state = {name: cmds.nodeType(name) for name in cmds.ls()} inst = MockedSessionSchema(default_state=default_state) # Determine known nodes and their ports node_types = cmds.allNodeTypes() namespaces = sorted(".".join(_maya.get_node_type_namespace(node_type)) for node_type in node_types) for namespace in iter_namespaces(namespaces): _LOG.info("Registering %r", namespace) node_type = get_namespace_leaf(namespace) parent_namespace = get_namespace_parent(namespace) parent = (inst.get_node_by_namespace(parent_namespace) if parent_namespace else None) data = _maya.get_node_attributes_info(node_type) classification = _maya.get_node_classification(node_type) node = NodeTypeDef(namespace, data, classification, parent=parent) inst.register_node(node) return inst
def isRenderEngineInstalled(self, renderEngineName): #bug fix: 06-20-2012: if mentalRay plugin not installed maya still has nodes called mentalraytexture #this prevents LCMT from not not working when the mentalray pluguin isn't installed by default if renderEngineName == 'mentalray' or renderEngineName == 'mentalRay': renderEngineName = self.MentalRayLightTypes[-1] #Arnold compatibility elif renderEngineName == 'arnold': #Since all there is no node specifically named arnold we use the #standard shader node name to see if arnold is indeed installed or no renderEngineName = 'aiStandard' #query all the types and look for Vray Types, and Renderman Types AllTypes = cmds.allNodeTypes() regex = '\w*' + renderEngineName + '\w*' to_find = re.compile(regex, re.IGNORECASE) to_search = ", ".join(AllTypes) match = re.search(to_find, to_search) if match != None: #print 'Found',renderEngineName #print match.group() return True else: print self.version, 'Didn\'t find', renderEngineName return False
def __load_json_settings(cls): """ Read JSON file and create corresponding list @return: supported_type, unsupported_type, texture_source_folder and custom_buttons """ # json file json_file_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'mtt.json') # create file with default value if doesn't exists if not os.path.isfile(json_file_path): with open(json_file_path, 'w') as f: f.write(DEFAULT_JSON_CONTENT) # now read json file with open(json_file_path, 'r') as json_file: json_settings = json.load(json_file) # get supported node types maya_type = set(cmds.allNodeTypes()) for entry in json_settings.get('supported_nodes', []): entry_type = entry.get('node_type', '') if entry_type not in maya_type: cmds.warning('Unsupported node type %s' % entry_type) MTTSettings.UNSUPPORTED_TYPE.append(entry_type) else: MTTSettings.SUPPORTED_TYPE.append(( entry_type, entry.get('node_nicename', entry_type), entry.get('node_attr', 'fileTextureName'))) # get workspace extend ws_extend = json_settings.get('workspace_extend', {}) # get texture source folder MTTSettings.TEXTURE_SOURCE_FOLDER = ws_extend.get( 'texture_source_folder', '<WORKSPACE>/PSD/') # get custom buttons for customButtonData in json_settings.get('custom_buttons', []): MTTSettings.CUSTOM_BUTTONS.append(( customButtonData.get('icon', ':/menuIconImages.png'), customButtonData.get('tooltip', ''), customButtonData.get('cmd', '') )) # get import policy MTTSettings.IMPORT_POLICY = json_settings.get('import_policy', '') # get path pattern if 'path_pattern' in json_settings: # convert string to raw string MTTSettings.PATH_PATTERN = ('%r' % json_settings['path_pattern'])[2:-1] # get VCS commands if 'VCS' in json_settings: MTTSettings.VCS = json_settings['VCS']
def test_abbreviation(): """Setup function to test Abbreviation class""" from maya import cmds data = ['Friday'] data += cmds.allNodeTypes() abb = Abbreviation(exclude_abbreviation={'Friday': ['FR', 'FRI', 'FRID'], 'pointConstraint': ['PO']}) result = abb.abbreviate(data, length=2) print len(result) print result['polyCube'], result['pointConstraint']
def test_abbreviation(): """Setup function to test Abbreviation class""" from maya import cmds data = ['Friday'] data += cmds.allNodeTypes() abb = Abbreviation(exclude_abbreviation={ 'Friday': ['FR', 'FRI', 'FRID'], 'pointConstraint': ['PO'] }) result = abb.abbreviate(data, length=2) print len(result) print result['polyCube'], result['pointConstraint']
def _getNodeHierarchy( version=None ): """ get node hierarchy as a list of 3-value tuples: ( nodeType, parents, children ) """ import pymel.util.trees as trees if versions.current() >= versions.v2012: # We now have nodeType(isTypeName)! yay! # For whatever reason, we can't query these objects from the hierarchy # correctly using nodeType(isTypeName) inheritances = {'file':[u'texture2d', u'file']} for nodeType in cmds.allNodeTypes(): inheritance = cmds.nodeType(nodeType, inherited=True, isTypeName=True) if inheritance is None: if nodeType in inheritances: pass else: raise RuntimeError("Could not query the inheritance of node type %s" % nodeType) else: inheritances[nodeType] = inheritance parentTree = {} # Convert inheritance lists node=>parent dict for nodeType, inheritance in inheritances.iteritems(): assert inheritance[-1] == nodeType for i in xrange(len(inheritance)): child = inheritance[i] if i == 0: if child == 'dependNode': continue else: parent = 'dependNode' else: parent = inheritance[i - 1] if child in parentTree: assert parentTree[child] == parent else: parentTree[child] = parent nodeHierarchyTree = trees.treeFromDict(parentTree) else: from parsers import NodeHierarchyDocParser parser = NodeHierarchyDocParser(version) nodeHierarchyTree = trees.IndexedTree(parser.parse()) return [ (x.value, tuple( [y.value for y in x.parents()]), tuple( [y.value for y in x.childs()] ) ) \ for x in nodeHierarchyTree.preorder() ]
def setId() : result = cmds.promptDialog(title='RenameGeo',message='Enter Name',button=['OK','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel') if result == 'OK': id = int(cmds.promptDialog(q=True,text=True)) selected = cmds.ls( sl=True ) cmds.select(hi=True) for t in types : if t not in cmds.allNodeTypes() : continue objs = cmds.ls(sl=True,type=t,long=True) for o in objs : if not cmds.attributeQuery(attr, ex=True, node=o) : cmds.addAttr(o, ln=attr, nn="Object ID", at='long', dv=0) cmds.setAttr(o+'.'+attr, e=True, keyable=True) cmds.setAttr(o+'.'+attr, id)
def setDisplayFlag(cls, show): nodes = cmds.allNodeTypes() types = [] for n in nodes: c = cmds.getClassification(n)[0] do = True for cl in cls: if cl not in c: do = False break if do: types.append(n) for t in types: print(t) tag = cmds.objectType(tagFromType=t) cmds.setNodeTypeFlag(tag, display=show)
def list_filtered(self): filter = cmds.textScrollList(self.node_list, query=True, selectItem=True) all_types = cmds.allNodeTypes() for f in filter[:]: if f not in all_types: filter.remove(f) if filter: nodes=[] for type in filter: n = sorted(cmds.ls(type=type), key=lambda x: x.lower()) if n and type in ['mesh', 'nurbsCurve', 'nurbsSurface', 'camera']: sorted(set(cmds.listRelatives(n, Parent=True)), key=lambda x: x.lower()) nodes.extend(n) cmds.textScrollList(self.filter_list, exists=True, removeAll=True, append=nodes)
def getObjectsById() : result = cmds.promptDialog(title='RenameGeo',message='Enter Name',button=['OK','Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel') out = [] if result == 'OK': id = int(cmds.promptDialog(q=True,text=True)) for t in types : if t not in cmds.allNodeTypes() : continue objs = cmds.ls( type=t, long=True ) for o in objs : if cmds.attributeQuery( attr, ex=True, node=o ) : if id == cmds.getAttr( o+'.'+attr ) : out.append( o ) cmds.select(cl=True) if len( out ) > 0 : cmds.select( out )
def node_to_list(self): node_type = cmds.textScrollList(self.node_list, q=True, si=True) all_types = cmds.allNodeTypes() for n in node_type[:]: if n not in all_types: node_type.remove(n) if node_type: nodes = [] for n_type in node_type: n = sorted(cmds.ls(type=n_type), key=lambda s: s.lower()) if n and n_type in ['nurbsCurve', 'nurbsSurface', 'mesh']: n = sorted(set(cmds.listRelatives(n, parent=True))) nodes.extend(n) cmds.textScrollList(self.outline_list, e=True, append=nodes, removeAll=True) return
def setGeomAttr(attr, val): selected = cmds.ls(sl=True) targetTypes = ['mesh', 'particle'] types = set(cmds.allNodeTypes()) if "gtoLocator" in types: targetTypes.append("gtoLocator") if "veFurNode" in types: targetTypes.append("veFurNode") if len(selected) > 0: # apply to objects below selection cmds.select(selected, hi=True) else: # apply to all objects of target types cmds.select(all=True, hi=True) for t in targetTypes: objs = cmds.ls(sl=True, type=t, long=True) for o in objs: doSetAttr(o, attr, val) if len(selected) > 0: cmds.select(selected) cmds.confirmDialog( title='Done', message= '%s attribute set to selected objecs.\n(%d object(s) and below)' % (targetAttrs[attr][0], len(selected)), button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok') else: cmds.select(cl=True) cmds.confirmDialog(title='Done', message='%s attribute set to ALL objecs.' % targetAttrs[attr][0], button=['Ok'], defaultButton='Ok', cancelButton='Ok', dismissString='Ok')
def main(fname=None): standalone.initialize() blacklist = ( # Causes crash (Maya 2018) "caddyManipBase", # Causes TypeError "applyAbsOverride", "applyOverride", "applyRelOverride", "childNode", "lightItemBase", "listItem", "override", "selector", "valueOverride", ) cmdt = [ "from maya.api import OpenMaya as om", "" ] dg = om.MFnDependencyNode() for name in cmds.allNodeTypes(): if name in blacklist: continue try: mobj = dg.create(name) print(mobj.apiType()) fn = om.MFnDependencyNode try: # If `name` is a shape, then the transform # is returned. We need the shape. mobj = om.MFnDagNode(mobj).child(0) except RuntimeError: pass except TypeError: # This shouldn't happen, but might depending # on the Maya version, and if there are any # custom plug-ins registereing new (bad) nodes. # # If so: # Add to `blacklist` # sys.stderr.write("%s threw a TypeError\n" % name) continue typeId = fn(mobj).typeId cmdt += ["{type} = om.MTypeId({id})".format( type=name[0].upper() + name[1:], id=str(typeId)) ] text = os.linesep.join(cmdt) dirname = os.path.dirname(__file__) fname = fname or os.path.join(dirname, "cmdt.py") with open(fname, "w") as f: f.write(text)
def _getMayaTypes(real=True, abstract=True, basePluginTypes=True, addAncestors=True, noManips=True, noPlugins=False, returnRealAbstract=False): '''Returns a list of maya types Parameters ---------- real : bool Include the set of real/createable nodes abstract : bool Include the set of abstract nodes (as defined by allNodeTypes(includeAbstract=True) basePluginTypes : bool Include the set of "base" plugin maya types (these are not returned by allNodeTypes(includeAbstract=True), and so, even though these types are abstract, this set shares no members with those added by the abstract flag addAncestors : bool If true, add to the list of nodes returned all of their ancestors as well noManips : bool If true, filter out any manipulator node types noPlugins : bool If true, filter out any nodes defined in plugins (note - if basePluginTypes is True, and noPlugins is False, the basePluginTypes will still be returned, as these types are not themselves defined in the plugin) returnRealAbstract : bool if True, will return two sets, realNodes and abstractNodes; otherwise, returns a single set of all the desired nodes (more precisely, realNodes is defined as the set of directly createdable nodes matching the criteria, and abstract are all non-createable nodes matching the criteria) ''' import maya.cmds as cmds # keep track of which nodes were abstract - this can be useful later, # especially pre-2012 abstractNodes = set() realNodes = set() if abstract or addAncestors: # if we want abstract, need to do extra processing to strip the # trailing ' (abstract)' raw = cmds.allNodeTypes(includeAbstract=True) for node in raw: if node.endswith(_ABSTRACT_SUFFIX): node = node[:-len(_ABSTRACT_SUFFIX)] # For some reason, maya returns these names with cmds.allNodeTypes(includeAbstract=True): # adskAssetInstanceNode_TlightShape # adskAssetInstanceNode_TdnTx2D # adskAssetInstanceNode_TdependNode # ...but they show up in parent hierarchies with a 'T' in front, ie: # cmds.nodeType(adskMaterial, isTypeName=True, inherited=True) # == [u'TadskAssetInstanceNode_TdependNode', u'adskMaterial'] # the 'T' form is also what is needed to use it as an arg to nodeType... # ...so, stick the 'T' in front... if node.startswith(_ASSET_PREFIX): node = 'T' + node abstractNodes.add(node) else: if not real: continue realNodes.add(node) elif real: realNodes.update(cmds.allNodeTypes()) if basePluginTypes: import pymel.api.plugins abstractNodes.update(pymel.api.plugins.pluginMayaTypes) if addAncestors or noManips: # There are a few nodes which will not be returned even by # allNodeTypes(includeAbstract=True), but WILL show up in the # inheritance hierarchies... # iterate over first real nodes, then abstract nodes... this lets us # take advantage of inheritance caching - especially pre-2012, where # inheritance chain of abstract nodes is not directly queryable - # since getInheritance will cache the inheritance chain of the given # node, AND all it's parents # make a copy of what we iterate over, as we will be modifying # realNodes and abstractNodes as we go... for mayaType in list(itertools.chain(realNodes, abstractNodes)): try: ancestors = getInheritance(mayaType, checkManip3D=noManips) except ManipNodeTypeError: realNodes.discard(mayaType) abstractNodes.discard(mayaType) except RuntimeError: # was an error querying - happens with some node types, like # adskAssetInstanceNode_TdnTx2D continue else: if addAncestors and ancestors: abstractNodes.update(set(ancestors) - realNodes) if noPlugins: for nodeSet in (realNodes, abstractNodes): # need to modify in place, so make copy of nodeSet... for node in list(nodeSet): if isPluginNode(node): nodeSet.remove(node) # we may have put nodes in realNodes or abstractNodes for info purposes... # make sure they are cleared before returning results, if needed... if not real: realNodes = set() if not abstract: abstractNodes = set() if returnRealAbstract: return realNodes, abstractNodes else: return realNodes | abstractNodes
''' import time import random as rand try: import maya.cmds as cmds import maya.OpenMaya as om import maya.mel as mel except: pass from multi_key_dict import multi_key_dict uAll_NODES = cmds.allNodeTypes() uALL_SHADING_NODES = cmds.listNodeTypes('shader') + \ cmds.listNodeTypes('texture') + \ cmds.listNodeTypes('light') + \ cmds.listNodeTypes('postProcess') + \ cmds.listNodeTypes('utility') UNPACK_TYPES = [u'short2', u'short3', u'long2', u'long3', u'float2', u'float3', u'double2', u'double3', u'matrix', u'pointArray', u'vectorArray', u'stringArray', u'cone', u'reflectanceRGB', u'spectrumRGB', u'componentList'] PACKED_TYPES = [u'Int32Array', u'doubleArray', u'attributeAlias'] TIME_VALS = ['hour','min','sec','millisec','game','film',
def _getMayaTypes(real=True, abstract=True, basePluginTypes=True, addAncestors=True, noManips=True, noPlugins=False, returnRealAbstract=False): '''Returns a list of maya types Parameters ---------- real : bool Include the set of real/createable nodes abstract : bool Include the set of abstract nodes (as defined by allNodeTypes(includeAbstract=True) basePluginTypes : bool Include the set of "base" plugin maya types (these are not returned by allNodeTypes(includeAbstract=True), and so, even though these types are abstract, this set shares no members with those added by the abstract flag addAncestors : bool If true, add to the list of nodes returned all of their ancestors as well noManips : bool | 'fast' If true, filter out any manipulator node types; if the special value 'fast', then it will filter out manipulator node types, but will do so using a faster method that may potentially be less thorough noPlugins : bool If true, filter out any nodes defined in plugins (note - if basePluginTypes is True, and noPlugins is False, the basePluginTypes will still be returned, as these types are not themselves defined in the plugin) returnRealAbstract : bool if True, will return two sets, realNodes and abstractNodes; otherwise, returns a single set of all the desired nodes (more precisely, realNodes is defined as the set of directly createdable nodes matching the criteria, and abstract are all non-createable nodes matching the criteria) ''' import maya.cmds as cmds # keep track of which nodes were abstract - this can be useful later, # especially pre-2012 abstractNodes = set() realNodes = set() if abstract or addAncestors: # if we want abstract, need to do extra processing to strip the # trailing ' (abstract)' raw = cmds.allNodeTypes(includeAbstract=True) for node in raw: if node.endswith(_ABSTRACT_SUFFIX): node = node[:-len(_ABSTRACT_SUFFIX)] # For some reason, maya returns these names with cmds.allNodeTypes(includeAbstract=True): # adskAssetInstanceNode_TlightShape # adskAssetInstanceNode_TdnTx2D # adskAssetInstanceNode_TdependNode # ...but they show up in parent hierarchies with a 'T' in front, ie: # cmds.nodeType(adskMaterial, isTypeName=True, inherited=True) # == [u'TadskAssetInstanceNode_TdependNode', u'adskMaterial'] # the 'T' form is also what is needed to use it as an arg to nodeType... # ...so, stick the 'T' in front... if node.startswith(_ASSET_PREFIX): node = 'T' + node abstractNodes.add(node) else: if not real: continue realNodes.add(node) elif real: realNodes.update(cmds.allNodeTypes()) if basePluginTypes: import pymel.api.plugins abstractNodes.update(pymel.api.plugins.pluginMayaTypes) # If we're doing addAncestors anyway, might was well get manips with the # more thorough method, using the inheritance chain, since we're doing that # anyway... if noManips == 'fast' and not addAncestors: manips = set(cmds.nodeType('manip3D', isTypeName=1, derived=1)) realNodes.difference_update(manips) abstractNodes.difference_update(manips) noManips = False if addAncestors or noManips: # There are a few nodes which will not be returned even by # allNodeTypes(includeAbstract=True), but WILL show up in the # inheritance hierarchies... # iterate over first real nodes, then abstract nodes... this lets us # take advantage of inheritance caching - especially pre-2012, where # inheritance chain of abstract nodes is not directly queryable - # since getInheritance will cache the inheritance chain of the given # node, AND all its parents # make a copy of what we iterate over, as we will be modifying # realNodes and abstractNodes as we go... for mayaType in list(itertools.chain(realNodes, abstractNodes)): try: ancestors = getInheritance(mayaType, checkManip3D=noManips) except ManipNodeTypeError: realNodes.discard(mayaType) abstractNodes.discard(mayaType) except RuntimeError: # was an error querying - happens with some node types, like # adskAssetInstanceNode_TdnTx2D continue else: if addAncestors and ancestors: abstractNodes.update(set(ancestors) - realNodes) if noPlugins: for nodeSet in (realNodes, abstractNodes): # need to modify in place, so make copy of nodeSet... for node in list(nodeSet): if isPluginNode(node): nodeSet.remove(node) # we may have put nodes in realNodes or abstractNodes for info purposes... # make sure they are cleared before returning results, if needed... if not real: realNodes = set() if not abstract: abstractNodes = set() if returnRealAbstract: return realNodes, abstractNodes else: return realNodes | abstractNodes
# This script searches all nodes for filepaths which begin with C:, R: or X: ... import maya.cmds as cmds def findFirstMatchInString(list, text): for part in list: if (part in text): return True # Found match return False # Did not find match errors = 0 # Start out with ALL nodes possible nodeTypes = cmds.allNodeTypes() nodeTypesFiltered = [] # Remove the following node types nodeTypes.remove('objectFilter') nodeTypes.remove('objectMultiFilter') nodeTypes.remove('objectNameFilter') nodeTypes.remove('objectScriptFilter') nodeTypes.remove('objectTypeFilter') nodeTypes.remove('containerBase') nodeTypes.remove('mesh') nodeTypes.remove('reference') nodeTypes.remove('deleteComponent') nodeTypes.remove('VRayMtl') nodeTypes.remove('transform') for nodeType in nodeTypes: if findFirstMatchInString(['poly', 'container', 'object', 'reference','VRayMtl', 'transform', 'mesh', 'component', 'group', 'nurbs', 'curve', 'motionPath', 'offset', 'selection'], nodeType):
import maya.cmds as cmds import pymel.api as api import pymel.internal.cmdcache as cmdcache import pymel.internal.apicache as apicache lsTypes = cmds.ls(nodeTypes=1) num = len(lsTypes) lsTypes = set(lsTypes) assert num == len(lsTypes) print num realTypes = lsTypes try: allTypes = cmds.allNodeTypes() except RuntimeError: allTypes = None realAndAbstract = lsTypes abstractTypes = None else: num = len(allTypes) allTypes = set(allTypes) assert num == len(allTypes) print num assert lsTypes == allTypes abstractSuffix = ' (abstract)' rawRealAndAbstract = cmds.allNodeTypes(includeAbstract=True) realAndAbstract = set()
def commands(self): from maya import cmds commands = [Command(c, c) for c in sorted(cmds.allNodeTypes())] return commands
def collect_dependencies(node_attrs): ''' Return a list of filepaths that the current maya scene has dependencies on. This is achieved by inspecting maya's nodes. Use the node_attrs argument to pass in a dictionary ''' assert isinstance( node_attrs, dict), "node_attrs arg must be a dict. Got %s" % type(node_attrs) # Note that this command will often times return filepaths with an ending "/" on it for some reason. Strip this out at the end of the function dependencies = cmds.file(query=True, list=True, withoutCopyNumber=True) or [] logger.debug("maya scene base dependencies: %s", dependencies) all_node_types = cmds.allNodeTypes() for node_type, node_attrs in node_attrs.iteritems(): if node_type not in all_node_types: logger.debug("skipping unknown node type: %s", node_type) continue for node in cmds.ls(type=node_type): for node_attr in node_attrs: plug_name = '%s.%s' % (node, node_attr) if cmds.objExists(plug_name): plug_value = cmds.getAttr(plug_name) # Note that this command will often times return filepaths with an ending "/" on it for some reason. Strip this out at the end of the function path = cmds.file(plug_value, expandName=True, query=True, withoutCopyNumber=True) logger.debug("%s: %s", plug_name, path) # ---- XGEN SCRAPING ----- # For xgen files, read the .xgen file and parse out the directory where other dependencies may exist if node_type == "xgmPalette": sceneFile = cmds.file(query=True, sceneName=True) path = os.path.join(os.path.dirname(sceneFile), plug_value) xgen_dependencies = parse_xgen_file(path, node) logger.debug("xgen_dependencies: %s", xgen_dependencies) dependencies += xgen_dependencies # ---- VRAY SCRAPING ----- if node_type == "VRayScene": vrscene_dependencies = parse_vrscene_file(path) logger.debug("vrscene dependencies: %s" % vrscene_dependencies) dependencies += vrscene_dependencies # ---- YETI SCRAPING ----- if node_type == "pgYetiMaya": yeti_dependencies = scrape_yeti_graph(node) logger.debug("yeti dependencies: %s" % yeti_dependencies) dependencies += yeti_dependencies # Check whether the node is reading from disk or not. # If it's not, then we shouldn't include the path as # a dependency if not cmds.getAttr('%s.fileMode' % node): logger.debug( "Skipping path because fileMode is disabled") continue dependencies.append(path) # ---- OCIO SCRAPING ----- ocio_dependencies = scrape_ocio_dependencies() logger.debug("ocio_dependencies: %s", ocio_dependencies) dependencies.extend(ocio_dependencies) # Strip out any paths that end in "\" or "/" Hopefully this doesn't break anything. return sorted(set([path.rstrip("/\\") for path in dependencies]))
def fillByTypeCMB(self): """fill combo box with types""" self.type_cmb.clear() allTypes = sorted( mc.allNodeTypes() ) allTypes.insert( 0, '' ) self.type_cmb.addItems( allTypes )
# maya node type hierarchy info #=============================================================================== cmds.file(new=1, f=1) lsTypes = cmds.ls(nodeTypes=1) num = len(lsTypes) lsTypes = set(lsTypes) assert num == len(lsTypes), "The result of ls(nodeTypes=1) contained duplicates" print(num) print('got ls(nodeTypes=1), confirmed no dupes') realTypes = lsTypes try: allTypesReal = cmds.allNodeTypes() except RuntimeError: print("Error calling allNodeTypes() !!") allTypesReal = None realAndAbstract = lsTypes abstractTypes = None else: num = len(allTypesReal) allTypesReal = set(allTypesReal) assert num == len(allTypesReal), "The result of allNodeTypes() contained duplicates" print(num) print('got allNodeTypes(), confirmed no dupes') assert lsTypes == allTypesReal, "ls(nodeTypes=1) and allNodeTypes() returned different result"
import maya.cmds as cmds from functools import partial import re widgets = {} typeList = cmds.allNodeTypes() # get all current node types in the scene def typeFinderUI(*args): if cmds.window("typeFinderWin", exists=True): cmds.deleteUI("typeFinderWin") widgets["win"] = cmds.window("typeFinderWin", w=400, h=400, t="zbw_typeFinder") widgets["mainCLO"] = cmds.columnLayout(w=400, h=400, bgc=(.2, .2, .2)) #---------------- right click on an item and get option to replace with parent or go down to shape cmds.text( l="Note: Rt-click on the below field to get suggestions from your sub-string" ) cmds.separator(h=10) widgets["typeTFBG"] = cmds.textFieldButtonGrp(l="Node Type", bl="Find", cal=[(1, "left"), (2, "left"), (3, "left")], cw=[(1, 75), (2, 250),
# This script searches all nodes for filepaths which begin with C:, R: or X: ... import maya.cmds as cmds def findFirstMatchInString(list, text): for part in list: if (part in text): return True # Found match return False # Did not find match errors = 0 # Start out with ALL nodes possible nodeTypes = cmds.allNodeTypes() nodeTypesFiltered = [] # Remove the following node types nodeTypes.remove('objectFilter') nodeTypes.remove('objectMultiFilter') nodeTypes.remove('objectNameFilter') nodeTypes.remove('objectScriptFilter') nodeTypes.remove('objectTypeFilter') nodeTypes.remove('containerBase') nodeTypes.remove('mesh') nodeTypes.remove('reference') nodeTypes.remove('deleteComponent') nodeTypes.remove('VRayMtl') nodeTypes.remove('transform') for nodeType in nodeTypes: if findFirstMatchInString([