Ejemplo n.º 1
0
def iteratePolyToSubdiv(target=None,polys=1000,reps=1000,delete=False):
    
    counter = 0
    initPolyCount = polys
    currentPolyCount = initPolyCount
    finished = False
    
    if not target:
        target = mc.ls(sl=1)

    for i in range(0,len(target)):
            while(finished==False and counter < reps):
                try:
                    finished=True
                    mc.polyToSubdiv(target[i], maxPolyCount=currentPolyCount)

                except:
                    finished=False
                    counter+=1
                    currentPolyCount += initPolyCount
                    print "Failed using " + str(currentPolyCount - initPolyCount) + " polys; trying " + str(currentPolyCount) + " polys."
            if(finished==True):
                if(delete==True):
                    mc.delete(constructionHistory=True) # prevents deletion of polys from wrecking subdivs
                    mc.delete(target[i])
                print "Successfully converted " + str(target[i]) + " using < " + str(currentPolyCount) + " polys in " + str(counter+1) + " tries."
            else:
                print "Failed to convert " + str(target[i]) + " using < " + str(currentPolyCount) + " polys in " + str(counter+1) + " tries."
Ejemplo n.º 2
0
def iteratePolyToSubdiv(target=None, polys=1000, reps=1000, delete=False):

    counter = 0
    initPolyCount = polys
    currentPolyCount = initPolyCount
    finished = False

    if not target:
        target = mc.ls(sl=1)

    for i in range(0, len(target)):
        while (finished == False and counter < reps):
            try:
                finished = True
                mc.polyToSubdiv(target[i], maxPolyCount=currentPolyCount)

            except:
                finished = False
                counter += 1
                currentPolyCount += initPolyCount
                print "Failed using " + str(currentPolyCount - initPolyCount
                                            ) + " polys; trying " + str(
                                                currentPolyCount) + " polys."
        if (finished == True):
            if (delete == True):
                mc.delete(constructionHistory=True
                          )  # prevents deletion of polys from wrecking subdivs
                mc.delete(target[i])
            print "Successfully converted " + str(
                target[i]) + " using < " + str(
                    currentPolyCount) + " polys in " + str(counter +
                                                           1) + " tries."
        else:
            print "Failed to convert " + str(target[i]) + " using < " + str(
                currentPolyCount) + " polys in " + str(counter + 1) + " tries."
Ejemplo n.º 3
0
def meshToNurbs(mesh, rebuild=False, spansU=0, spansV=0, prefix=''):
    '''
	'''
    # Check prefix
    if not prefix: prefix = glTools.utils.stringUtils.stripSuffix(mesh)

    # Convert poly to subdiv
    subd = mc.polyToSubdiv(mesh, ch=False, preserveVertexOrdering=True)[0]

    # Full crease corner vertices
    cornerIds = glTools.utils.mesh.getCornerVertexIds(mesh)
    mc.select([subd + '.vtx[' + str(i) + ']' for i in cornerIds])
    mm.eval('FullCreaseSubdivSurface')

    # Convert subdiv to nurbs
    nurbsConvert = mc.subdToNurbs(subd, ch=False)[0]
    nurbs = mc.listRelatives(nurbs, c=True)

    # Cleanup
    mc.parent(nurbs, w=True)
    mc.delete(nurbsConvert)
    mc.delete(subd)

    # Return result
    return nurbs
Ejemplo n.º 4
0
def meshToNurbs(mesh, rebuild=False, spansU=0, spansV=0, prefix=''):
    """
    @param mesh:
    @param rebuild:
    @param spansU:
    @param spansV:
    @param prefix:
    """
    # Check prefix
    if not prefix:
        prefix = glTools.utils.stringUtils.stripSuffix(mesh)

    # Convert poly to subdiv
    subd = cmds.polyToSubdiv(mesh, ch=False, preserveVertexOrdering=True)[0]

    # Full crease corner vertices
    cornerIds = glTools.utils.mesh.getCornerVertexIds(mesh)
    cmds.select([subd + '.vtx[' + str(i) + ']' for i in cornerIds])
    mel.eval('FullCreaseSubdivSurface')

    # Convert subdiv to nurbs
    nurbsConvert = cmds.subdToNurbs(subd, ch=False)[0]
    nurbs = cmds.listRelatives(nurbs, c=True)

    # Cleanup
    cmds.parent(nurbs, w=True)
    cmds.delete(nurbsConvert)
    cmds.delete(subd)

    # Return result
    return nurbs
Ejemplo n.º 5
0
def setObjectAsCanvas(name):
	cmds.polyEvaluate(f=True)
	subdivSurface = cmds.polyToSubdiv(maxPolyCount=cmds.polyEvaluate(f=True), maxEdgesPerVert=32, ch=False)[0]
	liveSurface = cmds.subdToNurbs(subdivSurface, ot=0, ch=False)
	cmds.delete(subdivSurface)
	cmds.hide(liveSurface)
	cmds.makeLive(liveSurface)

	return liveSurface
Ejemplo n.º 6
0
def polyToSubdiv(*args, **kwargs):
    res = cmds.polyToSubdiv(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res