コード例 #1
0
def separateIntoPlanarElements(name):
    # Use the automatic UV tool to do the heavy lifting in breaking up the 3d mesh for us
    cmds.polyAutoProjection('%s.f[0:%i]' % (name, cmds.polyEvaluate(name, f=True)), o=1, p=12)
    shells = getUVShells(name)
    for shell in shells: cmds.polyChipOff(shell)
    elements = cmds.polySeparate( name )[:-1]
    cmds.delete(elements[0])    # Delete the duplicate mesh
    return elements[1:]
コード例 #2
0
ファイル: mk_autoUV.py プロジェクト: ghost3d/MayaTools
def mkAutoUv():
    mkObjList = cmds.ls(sl=True)
    mkAutoList = len(mkObjList)
    mkAutoV = cmds.floatFieldGrp(mkAuto, query=True, value1=True)
    for i in range(0, mkAutoList, 1):
        cmds.polyAutoProjection(mkObjList[i],
                                planes=mkAutoV,
                                layout=2,
                                ch=True)
コード例 #3
0
ファイル: solidify.py プロジェクト: KelSolaar/Snippets
def solidifyObject(object, height=1, divisions=2, history=True):
	"""
	Solidifies given object.

	:param object: Object.
	:type object: str
	:param height: Extrusion height.
	:type height: float
	:param division: Extrusion divisions.
	:type division: float
	:param history: Keep construction history.
	:type history: bool
	"""

	if hasBorderEdges(object):
		transform = getTransform(object)
		vertices = cmds.ls(cmds.polyListComponentConversion(object, toVertex=True), fl=True)

		barycenters = cmds.xform(vertices, q=True, t=True, ws=True)
		barycenter = getAverageVector([(barycenters[i], barycenters[i + 1], barycenters[i + 2]) for i in range(0, len(barycenters), 3)])

		normals = cmds.polyNormalPerVertex(cmds.polyListComponentConversion(object, toVertexFace=True), q=True, xyz=True)
		normals = [(normals[i], normals[i + 1], normals[i + 2]) for i in range(0, len(normals), 3)]
		averageNormal = vectorMatrixMultiplication(normalize(getAverageVector(normals)), cmds.xform(transform, query=True, matrix=True, worldSpace=True))

		facesCount = cmds.polyEvaluate(object, face=True)
		faces = object + ".f[0:" + str(facesCount - 1) + "]"
		extrude = cmds.polyExtrudeFacet(faces, constructionHistory=1, keepFacesTogether=1, divisions=divisions)
		cmds.setAttr(extrude[0] + ".localTranslateZ", height)
		borderEdges = cmds.polyListComponentConversion(faces, te=True, bo=True)
		cmds.polyMapCut(borderEdges)
		uvs = cmds.polyListComponentConversion(object + ".f[0:" + str(facesCount - 1) + "]", toUV=1)
		cmds.polyEditUV(uvs, u=0, v=-5)

		extendedFaces = cmds.ls(faces, fl=True)
		for i in range(divisions):
			adjacentEdges = cmds.polyListComponentConversion(extendedFaces, ff=True, te=True)
			extendedFaces.extend(cmds.ls(cmds.polyListComponentConversion(adjacentEdges, fe=True, tf=True), fl=True))

		borderFaces = list(set(extendedFaces).difference(set(cmds.ls(faces, fl=True))))
		cmds.select(borderFaces)
		cmds.polyAutoProjection(borderFaces, t=barycenter, ry=getAngle((0, 0, 1), averageNormal), rz=getAngle((1, 0, 0), averageNormal))
		uvs = cmds.polyListComponentConversion(borderFaces, toUV=1)
		cmds.polyEditUV(uvs, u=0, v=-5)

		not history and cmds.delete(object, ch=True)
コード例 #4
0
 def pack_vert_uvs(mesh, progressBar, progressStep):  # 151
     # cm.polyTriangulate(mesh, ch=0) # move to smooth_copy() by Hiura
     anim_uvs = cm.polyUVSet(mesh, create=1, uvSet="anim_map")
     cm.polyUVSet(mesh, currentUVSet=1, uvSet=anim_uvs[0])
     cm.polyAutoProjection(mesh,
                           lm=0,
                           pb=0,
                           ibd=1,
                           cm=0,
                           l=2,
                           sc=1,
                           o=1,
                           p=6,
                           ps=0.2,
                           ws=0,
                           ch=0)
     cm.polyMapSewMove(mesh)
     lastProgress = 0  # added by Hiura
     for i in range(self.vert_count):
         current_position = (float(i) + 0.5) / self.vert_count
         # cm.polyColorPerVertex(mesh, rgb=[current_position, .5, 0]) # deleted by Hiura
         # >>>> modified by Hiura ( based on bryan_smyth'post )
         # cm.polyEditUV(mesh + ".map[" + str(i) + "]", u=current_position, v=.501961, r=0)
         vertex_u, vertex_v = get_vertex_uv(i)
         cm.polyEditUV(mesh + ".map[" + cm.polyListComponentConversion(
             mesh + ".vtx[%d]" % i, fv=True,
             tuv=True)[0].split("[")[-1][:-1] + "]",
                       u=vertex_u,
                       v=vertex_v,
                       r=0)
         # <<<< modified by Hiura
         self.vertex_uv_position.append(vertex_u)
         # >>>> added by Hiura
         nowProgress = int(
             float(progressStep) * float(i) / float(self.vert_count))
         if nowProgress > lastProgress:
             cm.progressBar(progressBar,
                            edit=True,
                            step=int(nowProgress - lastProgress))
             lastProgress = nowProgress
コード例 #5
0
ファイル: fbExport.py プロジェクト: jonntd/dmptools
def exportSelection(selection, filepath):    
    # combine if selection is more than 1 mesh
    if len(selection) > 1:
        selection = modeling.combine()
    # get asset name
    base = os.path.basename(filepath)
    assetname = os.path.splitext(base)[0]
    
    # auto unwrap uvs
    cmds.select(selection)
    cmds.polyAutoProjection()

    # create groups
    cmds.select(clear=True)
    main_group = cmds.group(n=assetname, empty=True)
    geo_group = cmds.group(n=assetname+'_main', empty=True, p=main_group)
    lod0_group = cmds.group(n=assetname+'_lod0', empty=True, p=geo_group)
    col_group = cmds.group(n=assetname+'_collision', empty=True, p=main_group)
    
    # parent the geo to the lod0 group
    cmds.parent(selection, lod0_group)
    # create the collision
    collision = cmds.duplicate(selection)
    cmds.parent(collision, col_group)

    # rename meshes
    cmds.rename(selection, 'part_state0')
    cmds.rename(collision, 'part_state0_Mesh1')

    # select main group
    cmds.select(main_group, r=True)
    
    # set fbx settings
    mel.eval('FBXExportFileVersion "FBX201300"') 
    #mel.eval('FBXConvertUnitString "m"')
    mel.eval('FBXExportSmoothingGroups -v true')
    mel.eval('FBXExportUpAxis "Y"')
    # export selection
    mel.eval('FBXExport -f "'+filepath+'" -s')
コード例 #6
0
def cleanScene():
    boolUv1 = False
    boolUv2 = False
    #List of objects (geometry only)
    objList = cmds.ls(geometry=True)
    #List of objects transforms
    transforms = cmds.listRelatives(objList, p=True, path=True)
   
    #hard edge
    for i in objList:        
        cmds.select(i)
        cmds.polySoftEdge(a=0)
        #UV automatic
        if(cmds.checkBoxGrp(checkUv,q=1,v1=1)):
            boolUv1 = True 
        if(cmds.checkBoxGrp(checkUv,q=1,v2=1)):
            boolUv2 = True
            cmds.polyUVSet( create=True, uvSet='map2')

        if boolUv1 or boolUv2 is True:
            cmds.polyAutoProjection( i + '.f[*]' )

    #placement pivot
    for j in transforms: 
        bbox = cmds.exactWorldBoundingBox(j)
        bottom = [(bbox[0] + bbox[3])/2, bbox[1], (bbox[2] + bbox[5])/2]
        cmds.select(j)
        cmds.xform(piv = bottom, ws=True)
        #snap à zéro
        pivot = cmds.getAttr(j+".scalePivot")
        #freeze transform for new position
        cmds.makeIdentity(j, apply=True) 
        pivot = cmds.xform(j,q=1,ws=1,rp=1)      
        cmds.move(-pivot[0], -pivot[1], -pivot[2])
        #delete all by type
        cmds.delete(ch=True)
        #freeze transform in origin
        cmds.makeIdentity(apply=True) 
コード例 #7
0
def CreateLightmapUVSet():
    selectionList = Cmds.ls(sl=True)
    for selection in selectionList:
        if not "Lightmap" in Cmds.polyUVSet(
                selection, query=True, allUVSets=True):
            Cmds.polyAutoProjection(selection,
                                    lm=1,
                                    pb=False,
                                    ibd=True,
                                    cm=True,
                                    l=2,
                                    sc=2,
                                    o=1,
                                    p=6,
                                    uvSetName="Lightmap",
                                    ps=0.2,
                                    ws=True)
            Cmds.polyUVSet(selection, luv=True)
        else:
            print "Lightmap UV set already exists"

    Cmds.confirmDialog(title="SceneExporter",
                       message="Lightmap UV set generation complete!",
                       button=["Yay!"])
コード例 #8
0
ファイル: escha_craft.py プロジェクト: magma2/yamimayapython
    mc.polyExtrudeEdge(ty=r * 0.055)
mc.polyExtrudeEdge(sx=0, sz=0, ty=0.02 * r)
mc.polyMergeVertex(d=0.001 * r)
bs = mc.blendShape(kliao, craft_bon)[0]

# สร้าง uv ให้แต่ละส่วนแยกกัน โดยจัดทำ uv ที่โหนดวัตถุเบลนด์เชป แล้วค่อยคัดลอกมาที่วัตถุหลัก
at = 'pcx pcy pcz rx ry rz phs pvs'.split()
ppj1 = mc.polyProjection(kliao + '.f[%d:%d]' % (nf1, nf2 - 1),
                         t='spherical')[0]
ppj2 = mc.polyProjection(kliao + '.f[%d:%d]' % (nf2, nf3 - 1),
                         t='spherical')[0]
for a, k1, k2 in zip(at, [0, 5, 0, 90, 0, 0, 130, 130],
                     [0, -2, 0, -90, 0, 0, 160, 160]):
    mc.setAttr(ppj1 + '.' + a, k1)
    mc.setAttr(ppj2 + '.' + a, k2)
mc.polyAutoProjection(kliao + '.f[%d:%d]' % (nf3, nf4 - 1), ps=0.4)[0]
mc.polyTransfer(craft_bon, uv=1, ao=kliao, ch=0)
mc.delete(kliao)

# ใส่สีให้แต่ละหน้าต่างๆกัน
mc.select(craft_bon + '.f[%d:%d]' % (nf1, nf2 - 1))
mc.hyperShade(a=phiu_nuea_nai)
mc.select(craft_bon + '.f[%d:%d]' % (nf2, nf3 - 1))
mc.hyperShade(a=phiu_thian)
mc.select(craft_bon + '.f[%d:%d]' % (nf3, nf4 - 1))
mc.hyperShade(a=phiu_sai_thian)

# ลบหน้าส่วนล่างที่ไม่ได้ใช้
mc.delete(craft_bon + '.f[0:%d]' % (nf1 - 1))
mc.select([craft_bon + '.e[%d]' % i for i in range(121, 166, 4)])
mc.move(0, 0.05 * r, r=1)
コード例 #9
0
def BakeLightsToVertex():
    folderdir = str(
        cmds.fileDialog2(caption="Select a Folder to save Textures",
                         fileMode=2)[0])
    # Ask user what texture size to use
    result = cmds.promptDialog(title='Vertex Light Baker',
                               message='Texture Size',
                               button=['OK', 'Cancel'],
                               defaultButton='OK',
                               cancelButton='Cancel',
                               dismissString='Cancel')

    if result == 'OK':
        texturesize = int(cmds.promptDialog(query=True, text=True))
        selected = cmds.ls(selection=True)
        for obj in selected:
            # Delete any extra uvsets
            ClearExtraUVSets(obj)
            # Create new automatic uv set
            shapes = cmds.listRelatives(obj, shapes=True)
            cmds.select(obj)
            cmds.polyUVSet(create=True, uvSet='automatic')
            # Automatic unwrap the object
            cmds.polyAutoProjection(obj,
                                    layoutMethod=False,
                                    projectBothDirections=False,
                                    insertBeforeDeformers=True,
                                    scaleMode=True,
                                    optimize=True,
                                    planes=6,
                                    uvSetName="automatic",
                                    percentageSpace=0.2,
                                    worldSpace=False)
            uvSetName = cmds.polyUVSet(query=True, currentUVSet=True)
            # Render the lighting to a texture
            cmds.arnoldRenderToTexture(filter="gaussian",
                                       filter_width=2.0,
                                       aa_samples=3,
                                       r=texturesize,
                                       folder=folderdir,
                                       uv_set=str(uvSetName[0]))
            # create a shader
            shader = cmds.shadingNode("surfaceShader", asShader=True)
            #a file texture node
            file_node = cmds.shadingNode("file", asTexture=True, icm=True)
            Texture2D = cmds.shadingNode("place2dTexture", asUtility=True)
            # connect the texture to the shader of the object
            cmds.connectAttr("{0}.coverage".format(Texture2D),
                             "{0}.coverage".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.translateFrame".format(Texture2D),
                             "{0}.translateFrame".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.rotateFrame".format(Texture2D),
                             "{0}.rotateFrame".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.mirrorU".format(Texture2D),
                             "{0}.mirrorU".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.mirrorV".format(Texture2D),
                             "{0}.mirrorV".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.stagger".format(Texture2D),
                             "{0}.stagger".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.wrapU".format(Texture2D),
                             "{0}.wrapU".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.wrapV".format(Texture2D),
                             "{0}.wrapV".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.repeatUV".format(Texture2D),
                             "{0}.repeatUV".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.offset".format(Texture2D),
                             "{0}.offset".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.rotateUV".format(Texture2D),
                             "{0}.rotateUV".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.noiseUV".format(Texture2D),
                             "{0}.noiseUV".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.vertexUvOne".format(Texture2D),
                             "{0}.vertexUvOne".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.vertexUvTwo".format(Texture2D),
                             "{0}.vertexUvTwo".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.vertexUvThree".format(Texture2D),
                             "{0}.vertexUvThree".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.vertexCameraOne".format(Texture2D),
                             "{0}.vertexCameraOne".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.outUV".format(Texture2D),
                             "{0}.uv".format(file_node),
                             force=True)
            cmds.connectAttr("{0}.outUvFilterSize".format(Texture2D),
                             "{0}.uvFilterSize".format(file_node),
                             force=True)
            # a shading group
            shading_group = cmds.sets(renderable=True,
                                      noSurfaceShader=True,
                                      empty=True)
            cmds.setAttr('{0}.fileTextureName'.format(file_node),
                         folderdir + "/" + str(shapes[0]) + ".exr",
                         type="string")
            cmds.sets(obj, edit=True, forceElement=shading_group)
            cmds.uvLink(uvSet=shapes[0] + ".uvSet[1].uvSetName",
                        texture=file_node)
            # Multiply Divide node to fix uv seems
            multiply_divide = cmds.shadingNode('multiplyDivide',
                                               asUtility=True)
            cmds.connectAttr('{0}.outColor'.format(file_node),
                             '{0}.input1'.format(multiply_divide),
                             force=True)
            cmds.connectAttr('{0}.outAlpha'.format(file_node),
                             '{0}.input2X'.format(multiply_divide),
                             force=True)
            cmds.connectAttr('{0}.outAlpha'.format(file_node),
                             '{0}.input2Y'.format(multiply_divide),
                             force=True)
            cmds.connectAttr('{0}.outAlpha'.format(file_node),
                             '{0}.input2Z'.format(multiply_divide),
                             force=True)
            #connect shader to sg surface shader
            cmds.connectAttr('{0}.outColor'.format(shader),
                             '{0}.surfaceShader'.format(shading_group),
                             force=True)
            #connect multiply_divide node to shader's color
            cmds.connectAttr('{0}.output'.format(multiply_divide),
                             '{0}.outColor'.format(shader),
                             force=True)
            cmds.setAttr('{0}.operation'.format(multiply_divide), 2)
            cmds.select(obj, r=True)
            # bake the texture into the object's vertex color
            cmds.polyGeoSampler(ids=True,
                                sf=1,
                                su=True,
                                cdo=True,
                                colorBlend="overwrite",
                                alphaBlend="overwrite")
            ClearExtraUVSets(obj)
コード例 #10
0
cmds.polyEvaluate( b=True )
# Result: ((-1.3974823703620598, 1.39748217791327), (-1.7164316223605844, -1.7164316223605844), (-1.6512467204212007, 1.6512465272260637)) #
cmds.polyEvaluate( b=True, ae=True )
# Result: ((-1.3974823951721191, 1.39748215675354), (-1.4071073532104492, -1.4071073532104492), (-1.3598332405090332, 1.3598330020904541)) #

# 地方和世界空间区
cmds.polyCube( w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 0, 1), cuv=1, ch=1 )
cmds.setAttr( 'pCube1.scaleY', 2 )
cmds.polyEvaluate( a=True )
# Result: 6
cmds.polyEvaluate( wa=True )
# Result: 10

# UV Shell 信息
cmds.polySphere( sx=20, sy=20 )
cmds.polyAutoProjection()
cmds.hilite()
cmds.select( 'pSphere1.f[282]', 'pSphere1.f[189:192]', replace = True )

#  UV shells的数量
cmds.polyEvaluate( uvShell=True )
# Result: 6

# 可用 UV Shells
cmds.polyEvaluate( activeUVShells=True )
# Result: [1, 4, 5]

# UV shell IDs for selected faces
cmds.polyEvaluate( uvShellIds=True )
# Result: [1, 1, 1, 4, 5]
コード例 #11
0
def create(name, positionList):
    '''
    This will create a bindmesh based on the give N amount of positions. 
    .. note::
        Bindmesh is a bunch of polygon plane's that are combined with rivets at the center
        of each of them.

    :param positionList: An N amount array of 3 point array's.
    :type positionList: tuple | list

    :return: The bindmesh and the follicle information 
    :trype: tuple
    '''
    # Check if the bindmesh has already been created.
    # If it exists return existing bindmesh and follicle names
    #
    newGeoName = "{0}_bindmesh".format(name)
    if mc.objExists(newGeoName):
        follicleNameList = list()
        for i in xrange(len(positionList)):
            follicleName = "{0}_{1}_follicle".format(name, i)
            follicleNameList.append(follicleName)
        return newGeoName, follicleNameList

    # define variables we will be mutating
    geoList = list()
    follicleList = list()
    pointList = list()
    # iterate through the cvList and create the plane's and follicles for each plane.
    for i, position in enumerate(positionList):
        geo, createNode = mc.polyPlane()
        for attr in ["subdivisionsHeight", "subdivisionsWidth"]:
            mc.setAttr("{0}.{1}".format(createNode, attr), 1)
        for attr in ["height", "width"]:
            mc.setAttr("{0}.{1}".format(createNode, attr), .02)
        mc.xform(geo, ws=True, t=position)
        geoList.append(geo)
        pointList.append(om.MPoint(*position))

        mc.select(cl=True)

    # combine the plane's into one piece of geometry.
    newGeo = mc.polyUnite(geoList, ch=False, n="{0}_bindmesh".format(name))[0]
    newGeoFaces = mc.ls("{0}.f[*]".format(newGeo))
    mc.polyAutoProjection(newGeoFaces,
                          ch=False,
                          lm=False,
                          pb=False,
                          ibd=True,
                          cm=False,
                          l=2,
                          sc=1,
                          o=1,
                          p=6,
                          ps=0.2,
                          ws=0)
    mc.select(newGeo, r=True)
    selList = om.MGlobal.getActiveSelectionList()
    newGeoDagPath = selList.getDagPath(0)
    newGeoFn = om.MFnMesh(newGeoDagPath)
    newGeoShape = mc.listRelatives(newGeo, c=True, shapes=True)[0]
    # iterate through the cv points and connect the follictles to the bindmesh.
    for i, point in enumerate(pointList):
        uPosition, vPosition = newGeoFn.getUVAtPoint(point)[:-1]
        follicle = mc.createNode("transform",
                                 n="{0}_{1}_follicle".format(name, i))
        constraint = mc.pointOnPolyConstraint(newGeoDagPath.fullPathName(),
                                              follicle)[0]
        u, v, id = newGeoFn.getUVAtPoint(point, om.MSpace.kWorld)
        mc.setAttr(
            "{}.{}U0".format(constraint, newGeoDagPath.partialPathName()), u)
        mc.setAttr(
            "{}.{}V0".format(constraint, newGeoDagPath.partialPathName()), v)
        follicleList.append(follicle)
    # return the bindmesh
    return newGeo, follicleList
コード例 #12
0
def addUVNodeToSVG(svgTransform, svgExtruder):
    cmds.select(svgTransform)
    autoProj = cmds.polyAutoProjection( lm =0 ,pb =0 ,ibd = 0 ,cm =0 ,l =2 ,sc =1 ,o =1 ,p =6 ,ps =0.2 ,ws =0, n="svgPolyAutoProj#")
コード例 #13
0
def solidifyObject(object, height=1, divisions=2, history=True):
    """
	Solidifies given object.

	:param object: Object.
	:type object: str
	:param height: Extrusion height.
	:type height: float
	:param division: Extrusion divisions.
	:type division: float
	:param history: Keep construction history.
	:type history: bool
	"""

    if hasBorderEdges(object):
        transform = getTransform(object)
        vertices = cmds.ls(cmds.polyListComponentConversion(object,
                                                            toVertex=True),
                           fl=True)

        barycenters = cmds.xform(vertices, q=True, t=True, ws=True)
        barycenter = getAverageVector([(barycenters[i], barycenters[i + 1],
                                        barycenters[i + 2])
                                       for i in range(0, len(barycenters), 3)])

        normals = cmds.polyNormalPerVertex(cmds.polyListComponentConversion(
            object, toVertexFace=True),
                                           q=True,
                                           xyz=True)
        normals = [(normals[i], normals[i + 1], normals[i + 2])
                   for i in range(0, len(normals), 3)]
        averageNormal = vectorMatrixMultiplication(
            normalize(getAverageVector(normals)),
            cmds.xform(transform, query=True, matrix=True, worldSpace=True))

        facesCount = cmds.polyEvaluate(object, face=True)
        faces = object + ".f[0:" + str(facesCount - 1) + "]"
        extrude = cmds.polyExtrudeFacet(faces,
                                        constructionHistory=1,
                                        keepFacesTogether=1,
                                        divisions=divisions)
        cmds.setAttr(extrude[0] + ".localTranslateZ", height)
        borderEdges = cmds.polyListComponentConversion(faces, te=True, bo=True)
        cmds.polyMapCut(borderEdges)
        uvs = cmds.polyListComponentConversion(object + ".f[0:" +
                                               str(facesCount - 1) + "]",
                                               toUV=1)
        cmds.polyEditUV(uvs, u=0, v=-5)

        extendedFaces = cmds.ls(faces, fl=True)
        for i in range(divisions):
            adjacentEdges = cmds.polyListComponentConversion(extendedFaces,
                                                             ff=True,
                                                             te=True)
            extendedFaces.extend(
                cmds.ls(cmds.polyListComponentConversion(adjacentEdges,
                                                         fe=True,
                                                         tf=True),
                        fl=True))

        borderFaces = list(
            set(extendedFaces).difference(set(cmds.ls(faces, fl=True))))
        cmds.select(borderFaces)
        cmds.polyAutoProjection(borderFaces,
                                t=barycenter,
                                ry=getAngle((0, 0, 1), averageNormal),
                                rz=getAngle((1, 0, 0), averageNormal))
        uvs = cmds.polyListComponentConversion(borderFaces, toUV=1)
        cmds.polyEditUV(uvs, u=0, v=-5)

        not history and cmds.delete(object, ch=True)
コード例 #14
0
ファイル: mk_autoUV.py プロジェクト: ghost3d/MayaTools
def mkAutoUv():
 	mkObjList = cmds.ls (sl = True)
	mkAutoList = len(mkObjList)
	mkAutoV = cmds.floatFieldGrp(mkAuto,query = True, value1 = True)
	for i in range (0,mkAutoList,1):
		cmds.polyAutoProjection (mkObjList[i],planes = mkAutoV, layout = 2, ch = True)
コード例 #15
0
import maya.cmds as mc

allSelected = mc.ls(sl=True)
for selected in allSelected:
    mc.select(selected)
    if 'PosToUV' in mc.polyUVSet(query=True, allUVSets=True):
        mc.polyUVSet(delete=True, uvSet='PosToUV')
    mc.polyAutoProjection(createNewMap=True, uvSetName="PosToUV")
    mc.polyUVSet(currentLastUVSet=True)

    uvs = mc.polyListComponentConversion(tuv=True)
    mc.select(uvs)

    objPos = mc.xform(str(selected), q=1, ws=1, rp=1)
    mc.polyEditUV(relative=False, uValue=objPos[0], vValue=objPos[2])