def reTopoPush(*args): confirmB = cmds.confirmDialog( title='Re-Topo', message= 'Re-Topo funciona mejor despues de hacer un Re-Mesh\n\nesta accion puede tomar mucho tiempo en un mesh con errores o demasiados poligonos', messageAlign='center', button=['Continuar', 'Detener'], defaultButton='Continuar', cancelButton='Detener', dismissString='No') if confirmB == "Continuar": cmds.polyRetopo() else: print "Re-Topo cancelado" return () print 'reTopoPush pushed.'
def fMImport_Retopo(arg): path = mc.textField( 'fMtextField', q=True, fi=True, ) if path.find('.obj') < 0: mc.error('select OBJ mesh') else: belist = mc.ls(type="transform") test = mc.file(path, i=True, type="OBJ", ra=True, mergeNamespacesOnClash=True, namespace="OrigFlatten", options="mo=1,lo=0") aflist = mc.ls(type="transform") #seperate pieces origFMlist_root = list(set(aflist) - set(belist)) origFMlist_temp = [] origFMlist = [] for fm in origFMlist_root: mc.select(fm) mc.SeparatePolygon() mc.DeleteHistory() sep_list = [] sep_templist = mc.ls(sl=True) for sep in sep_templist: mc.select(sep) sep_list.append(mc.rename('OrigFlatten_01')) mc.pickWalk(direction='up') mc.Ungroup() origFMlist_temp.append(sep_list) for x in origFMlist_temp: for y in x: origFMlist.append(y) #create set or add into existing one original flatten mesh if mc.objExists('OrigFlatMeshes_set'): mc.sets(origFMlist, forceElement='OrigFlatMeshes_set') else: newSet1 = cmds.sets(name='OrigFlatMeshes_set') mc.sets(origFMlist, forceElement='OrigFlatMeshes_set') #polyRetopo imported meshes pRlist = [] for u in origFMlist: mc.select(u) mc.ConvertSelectionToEdgePerimeter(u) mc.planarSrf( n='Surface' + str(u)) # reikia variable pavadinima ivesti jog sukurtu mc.nurbsToPoly(ch=True, f=0, pt=1, pc=1000, chr=0.9, ft=0.01, mel=0.001, d=0.1, n='nurbsToPoly' + str(u)) chpoly = mc.polyEvaluate(shell=True) #check if mesh has several pieces if chpoly > 1: mc.SeparatePolygon() mc.DeleteHistory() chlist = mc.ls(sl=True) #check if mesh is in the group if len(chlist) > 1: mc.pickWalk(direction='up') mc.Ungroup() o = mc.ls(sl=True) if len(o) == 1: mc.polyRetopo('nurbsToPoly' + str(u)) mc.rename('Retopo_mesh_01') #add new polyRetopo mesh to list pRsl = mc.ls(sl=True) pRlist.append(pRsl) else: for y in o: mc.select(y, r=True) mc.polyRetopo(y) mc.sets(fe='initialShadingGroup') mc.rename('Retopo_mesh_01') #add new polyRetopo mesh to list pRsl = mc.ls(sl=True) pRlist.append(pRsl) sfrlist = mc.select('Surface' + str(u)) mc.Delete(sfrlist) #hide Original mesh accordingly if check box is on or off mc.select('OrigFlatMeshes_set') listObjectsInSet = mc.ls(sl=True) for objOnSet in listObjectsInSet: visValue = mc.getAttr(str(objOnSet) + '.visibility') checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True) if visValue is False or checkBoxStatus is True: mc.setAttr((objOnSet + '.visibility'), 0) #transfer uvs from Marvelous mesh to new polyRetopo meshes iterpRlist = iter(pRlist) for fm in origFMlist: mc.select(fm) mc.select(next(iterpRlist), add=True) mc.transferAttributes(transferPositions=0, transferNormals=0, transferUVs=2, transferColors=0, sampleSpace=0, sourceUvSpace="map1", targetUvSpace="map1", searchMethod=3, flipUVs=0, colorBorders=1) #adapt faceCount of new created polyRetopo meshes mc.select(d=True) for pRmesh in pRlist: mc.select(pRmesh, add=True) adaptPoly()
def polyRetopo(*args, **kwargs): res = cmds.polyRetopo(*args, **kwargs) if not kwargs.get('query', kwargs.get('q', False)): res = _factories.maybeConvert(res, _general.PyNode) return res
def m_polyretopo(): selected = mc.ls(sl=True) pRlist = [] #create set or add into existing one original flatten mesh if mc.objExists('OrigFlatMeshes_set'): mc.sets(selected, forceElement='OrigFlatMeshes_set') else: newSet1 = cmds.sets(name='OrigFlatMeshes_set') mc.sets(selected, forceElement='OrigFlatMeshes_set') for u in selected: mc.select(u) mc.ConvertSelectionToEdgePerimeter(u) mc.planarSrf(n='Surface' + str(u)) # reikia variable pavadinima ivesti jog sukurtu mc.nurbsToPoly(ch=True, f=0, pt=1, pc=1000, chr=0.9, ft=0.01, mel=0.001, d=0.1, n='nurbsToPoly' + str(u)) chpoly = mc.polyEvaluate(shell=True) #check if mesh has several pieces if chpoly > 1: mc.SeparatePolygon() mc.DeleteHistory() chlist = mc.ls(sl=True) #check if mesh is in the group if len(chlist) > 1: mc.pickWalk(direction='up') mc.Ungroup() o = mc.ls(sl=True) if len(o) == 1: mc.polyRetopo('nurbsToPoly' + str(u)) mc.rename('Retopo_mesh_01') #add new polyRetopo mesh to list pRsl = mc.ls(sl=True) pRlist.append(pRsl) else: for y in o: mc.select(y, r=True) mc.polyRetopo(y) mc.sets(fe='initialShadingGroup') mc.rename('Retopo_mesh_01') #add new polyRetopo mesh to list pRsl = mc.ls(sl=True) pRlist.append(pRsl) sfrlist = mc.select('Surface' + str(u)) mc.Delete(sfrlist) #hide Original mesh accordingly if check box is on or off mc.select('OrigFlatMeshes_set') listObjectsInSet = mc.ls(sl=True) for objOnSet in listObjectsInSet: visValue = mc.getAttr(str(objOnSet) + '.visibility') checkBoxStatus = mc.checkBox('fMOrigCheckBox', q=True, v=True) if visValue is False or checkBoxStatus is True: mc.setAttr((objOnSet + '.visibility'), 0)