def filterByFaceCount(self, objectList, minCount=2): # '''path:Selection/filterByFaceCount()ONLYSE #icon:filtersOn.png #usage: #QM.filterByFaceCount(cmds.ls(sl=True),minCount=2) #objectList = cmds.listRelatives(cmds.ls(sl=True), ad=True, f=True, type='mesh') #resultList = QM.filterByFaceCount(objectList,minCount=2) #cmds.select(resultList[0], r=True) #''' if str(type(objectList)) == "<type 'str'>" or str( type(objectList)) == "<type 'unicode'>": objectList = [objectList] objectList = qm.childCheck02(objectList, 'mesh') minObj, maxObj, faceCountList = [], [], [] for object in objectList: objFaceCount = cmds.polyEvaluate(object, face=True) faceCountList.append([objFaceCount, object]) if objFaceCount < minCount: minObj.append(object) else: maxObj.append(object) print '%s objects in fist List. \n%s objects in secondary list' % ( len(minObj), len(maxObj)) return minObj, maxObj, faceCountList
def filterByPolyArea(self, objects, thresholdObject): # '''path:Selection/filterByPolyArea()ONLYSE #icon:filtersOn.png #usage: #objectList = cmds.listRelatives(cmds.ls(sl=True)[:-1], ad=True, f=True, type='mesh') #objectThreshold = cmds.ls(sl=True)[-1] #resultList = QM.filterByPolyArea(objectList,objectThreshold) #cmds.select(resultList[0], r=True) #''' if str(type(objects)) == "<type 'str'>" or str( type(objects)) == "<type 'unicode'>": objects = [objects] objects = qm.childCheck02(objects, 'mesh') gThan, lThan, polyAreaList = [], [], [] thrValue = cmds.polyEvaluate(thresholdObject, wa=True) for obj in objects: polyArea = cmds.polyEvaluate(obj, wa=True) polyAreaList.append([polyArea, obj]) if polyArea > thrValue: gThan.append(obj) else: lThan.append(obj) print '%s objects in fist List. \n%s objects in secondary list' % ( len(lThan), len(gThan)) return lThan, gThan, polyAreaList
def w01_rcL02_01_c(): objectList = qm.childCheck02( cmds.ls(sl=True, exactType='transform', l=True), 'mesh') bbsi = w01_filterObjByBBoxSize(objectList, cmds.ls(sl=True)[0])[2] bbsi.sort() count = w01_filterByFaceCount(objectList,minCount=2)[2] count.sort() area = w01_filterByPolyArea(objectList,objectList[0])[2] area.sort() return bbsi, count, area, objectList
def getDataFromSelectedObjs(self, *args): objectList = qm.childCheck02( cmds.ls(sl=True, exactType='transform', l=True), 'mesh') bbsi = self.filterObjByBBoxSize(objectList, cmds.ls(sl=True)[0])[2] bbsi.sort() count = self.filterByFaceCount(objectList, minCount=2)[2] count.sort() area = self.filterByPolyArea(objectList, objectList[0])[2] area.sort() self.w01_objectsData = (bbsi, count, area, objectList)