def doRenameHeir(obj, sceneUnique=False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Names an object's heirarchy below ARGUMENTS: obj(string) - the object we'd like to startfrom RETURNS: newNames(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ ### input check assert mc.objExists(obj) is True, "'%s' doesn't exist" % obj #children = mc.listRelatives(obj,allDescendents=True,type='transform') # Create a tmp group to store out objects to so that we can get them back even if heirarchal names change tmpGroup = mc.group(em=True) attributes.storeInfo(tmpGroup, ('name' + str(0)), obj) newNames = [] childrenList = [] children = mc.listRelatives(obj, allDescendents=True, fullPath=True) children.reverse() cnt = 1 for c in children: attributes.storeInfo(tmpGroup, ('name' + str(cnt)), c) cnt += 1 toNameAttrs = attributes.returnUserAttributes(tmpGroup) mayaMainProgressBar = guiFactory.doStartMayaProgressBar( len(toNameAttrs), 'Naming') for attr in toNameAttrs: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True): break objectToName = (attributes.returnMessageObject(tmpGroup, attr)) mc.progressBar(mayaMainProgressBar, edit=True, status=("Naming '%s'" % objectToName), step=1) buffer = doNameObject(objectToName, sceneUnique) if buffer: newNames.append(buffer) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) mc.delete(tmpGroup) return newNames
def doRenameHeir(obj,sceneUnique = False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Names an object's heirarchy below ARGUMENTS: obj(string) - the object we'd like to startfrom RETURNS: newNames(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ ### input check assert mc.objExists(obj) is True, "'%s' doesn't exist" %obj #children = mc.listRelatives(obj,allDescendents=True,type='transform') # Create a tmp group to store out objects to so that we can get them back even if heirarchal names change tmpGroup = mc.group(em=True) attributes.storeInfo(tmpGroup,('name'+str(0)),obj) newNames = [] childrenList = [] children = mc.listRelatives(obj,allDescendents=True,fullPath=True) children.reverse() cnt = 1 for c in children: attributes.storeInfo(tmpGroup,('name'+str(cnt)),c) cnt += 1 toNameAttrs = attributes.returnUserAttributes(tmpGroup) mayaMainProgressBar = guiFactory.doStartMayaProgressBar(len(toNameAttrs),'Naming') for attr in toNameAttrs: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break objectToName = (attributes.returnMessageObject(tmpGroup,attr)) mc.progressBar(mayaMainProgressBar, edit=True, status = ("Naming '%s'"%objectToName), step=1) buffer = doNameObject( objectToName,sceneUnique ) if buffer: newNames.append(buffer) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) mc.delete(tmpGroup) return newNames
def uiNameObject(self, sceneUnique): selected = mc.ls(sl=True, flatten=True, long=True) newNames = [] if not selected: guiFactory.warning('Must have something selected') return elif len(selected) > 1: tmpGroup = mc.group(em=True) cnt = 1 for o in selected: attributes.storeInfo(tmpGroup, ('name' + str(cnt)), o) cnt += 1 toNameAttrs = attributes.returnUserAttributes(tmpGroup) mayaMainProgressBar = guiFactory.doStartMayaProgressBar( len(toNameAttrs), 'Naming...') for attr in toNameAttrs: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True): break objectToName = (attributes.returnMessageObject(tmpGroup, attr)) mc.progressBar(mayaMainProgressBar, edit=True, status=("Naming '%s'" % objectToName), step=1) try: buffer = NameFactoryOld.doNameObject(objectToName, sceneUnique) except: guiFactory.warning("'%s' failed" % objectToName) if buffer: newNames.append(buffer) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) mc.delete(tmpGroup) else: NameFactoryOld.doNameObject(selected[0], sceneUnique) if newNames: print("The following were named: %s" % ','.join(newNames))
def uiNameObject(self,sceneUnique): selected = mc.ls(sl=True,flatten=True,long=True) newNames = [] if not selected: guiFactory.warning('Must have something selected') return elif len(selected) > 1: tmpGroup = mc.group(em=True) cnt = 1 for o in selected: attributes.storeInfo(tmpGroup,('name'+str(cnt)),o) cnt += 1 toNameAttrs = attributes.returnUserAttributes(tmpGroup) mayaMainProgressBar = guiFactory.doStartMayaProgressBar(len(toNameAttrs),'Naming...') for attr in toNameAttrs: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break objectToName = (attributes.returnMessageObject(tmpGroup,attr)) mc.progressBar(mayaMainProgressBar, edit=True, status = ("Naming '%s'"%objectToName), step=1) try: buffer = NameFactoryOld.doNameObject( objectToName,sceneUnique ) except: guiFactory.warning("'%s' failed"%objectToName) if buffer: newNames.append(buffer) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) mc.delete(tmpGroup) else: NameFactoryOld.doNameObject(selected[0],sceneUnique) if newNames: print ("The following were named: %s" %','.join(newNames))
def locMeCVsOfCurve(curve): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Places locators on the cv's of a curve ARGUMENTS: curve(string) RETURNS: locList(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ if mc.objExists(curve): locList = [] cvList = [] shapes = mc.listRelatives(curve, shapes=True, fullPath=True) for shape in shapes: cvList = (mc.ls([shape + '.cv[*]'], flatten=True)) if cvList: mayaMainProgressBar = guiFactory.doStartMayaProgressBar( len(cvList)) for cv in cvList: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True): break mc.progressBar(mayaMainProgressBar, edit=True, status=("Procssing '%s'" % str(cv)), step=1) locList.append(locMeObject(cv)) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) else: guiFactory.warning('Curve does not exist') success = False return False if locList: return locList
def locMeCVsOfCurve(curve): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Places locators on the cv's of a curve ARGUMENTS: curve(string) RETURNS: locList(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ if mc.objExists (curve): locList = [] cvList = [] shapes = mc.listRelatives(curve,shapes=True,fullPath=True) for shape in shapes: cvList = (mc.ls ([shape+'.cv[*]'],flatten=True)) if cvList: mayaMainProgressBar = guiFactory.doStartMayaProgressBar(len(cvList)) for cv in cvList: if mc.progressBar(mayaMainProgressBar, query=True, isCancelled=True ) : break mc.progressBar(mayaMainProgressBar, edit=True, status = ("Procssing '%s'"%str(cv)), step=1) locList.append(locMeObject(cv)) guiFactory.doEndMayaProgressBar(mayaMainProgressBar) else: guiFactory.warning ('Curve does not exist') success = False return False if locList: return locList