本文整理汇总了Python中maya.cmds.polyEditUV函数的典型用法代码示例。如果您正苦于以下问题:Python polyEditUV函数的具体用法?Python polyEditUV怎么用?Python polyEditUV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polyEditUV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CentreUVs
def CentreUVs():
objSel = cmds.ls(sl=True)
try:
for item, x in enumerate(objSel):
cmds.select('%s.map[*]' %objSel[item])
mm.eval("PolySelectConvert 4;")
mm.eval('TranslateToolWithSnapMarkingMenu')
objPiv = cmds.getAttr('%s.uvPivot' %objSel[0])
mm.eval('MarkingMenuPopDown')
objCenterU = 0.5 - objPiv[0][0]
objCenterV = 0.5 - objPiv[0][1]
cmds.polyEditUV(u=objCenterU, v=objCenterV, r=1)
cmds.select(objSel)
except ValueError:
objQuery = cmds.listRelatives(objSel[0], ap=True)
cmds.select('%s.map[*]' %objQuery[0])
mm.eval("PolySelectConvert 4;")
mm.eval('TranslateToolWithSnapMarkingMenu')
objPiv = cmds.getAttr('%s.uvPivot' %objQuery[0])
mm.eval('MarkingMenuPopDown')
objCenterU = 0.5 - objPiv[0][0]
objCenterV = 0.5 - objPiv[0][1]
cmds.polyEditUV(u=objCenterU, v=objCenterV, r=1)
cmds.select(objQuery)
示例2: setUpClass
def setUpClass(cls):
standalone.initialize('usd')
cmds.loadPlugin('pxrUsd')
if not UsdMaya.WriteUtil.WriteUVAsFloat2():
cmds.file(os.path.abspath('UsdExportUVSetsTest.ma'), open=True,
force=True)
else:
cmds.file(os.path.abspath('UsdExportUVSetsTest_Float.ma'), open=True,
force=True)
# Make some live edits to the box with weird UVs for the
# testExportUvVersusUvIndexFromIterator test.
cmds.select("box.map[0:299]", r=True)
cmds.polyEditUV(u=1.0, v=1.0)
usdFilePath = os.path.abspath('UsdExportUVSetsTest.usda')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
shadingMode='none',
exportColorSets=False,
exportDisplayColor=False,
exportUVs=True)
cls._stage = Usd.Stage.Open(usdFilePath)
示例3: unfoldBandUVs
def unfoldBandUVs(object, divisions=1, history=True):
"""
This definition unfolds object band UVs.
:param object: Object. ( String )
:param divisions: Extrusion divisions. ( Integer )
:param history: Keep construction history. ( Boolean )
"""
edgesCount = cmds.polyEvaluate(object, edge=True)
edges = cmds.ls(object + ".e[0:" + str(edgesCount - 1) + "]", fl=True, l=True)
cmds.select(object)
cmds.polySelectConstraint(m=3, t=0x8000, w=1)
cmds.polySelectConstraint(m=0)
for i in range(divisions):
mel.eval("GrowPolygonSelectionRegion();")
bandEdges = cmds.ls(sl=True, fl=True, l=True)
bandFaces = cmds.ls(cmds.polyListComponentConversion(bandEdges, fe=True, tf=True), fl=True)
cmds.select(bandFaces)
cmds.polyForceUV(unitize=True)
cmds.polySelectConstraint(m=3, t=0x8000, sm=1)
seamsEdges = cmds.ls(sl=True, fl=True, l=True)
weldEdges = list(set(bandEdges).difference(set(seamsEdges)))
cmds.polyMapSewMove(weldEdges)
cmds.polyLayoutUV(bandFaces, scale=1, rotateForBestFit=0, layout=1)
uvs = cmds.polyListComponentConversion(bandFaces, toUV=1)
cmds.polyEditUV(uvs, u=1, v=0)
not history and cmds.delete(object, ch=True)
示例4: layoutUVsToUDIM
def layoutUVsToUDIM(self, *args):
sels = cmds.ls(sl=1)
for i, x in enumerate(sels):
x = cmds.listRelatives(x,s=True)[0]
cmds.select('{0}.map[:]'.format(x), r=1)
cmds.polyEditUV(u=i % 10, v=int(math.floor(i / 10)))
cmds.select(sels, r=1)
示例5: prescaleUVsShells
def prescaleUVsShells(object):
"""
This definition prescales object UVs shells.
:param objects: Object. ( String )
:return: Definition succes. ( Boolean )
"""
uvs = getUVsFromComponents(object)
uMin, vMin, uMax, vMax = getComponentsBoundingBox(uvs)
uCenter, vCenter = (uMin + uMax) / 2.0, (vMin + vMax) / 2.0
width, height = uMax - uMin, vMax - vMin
scale = max(width, height)
cmds.polyMultiLayoutUV(object, lm=0, sc=1, rbf=0, fr=False, ps=0.2, l=2, psc=True)
currentUMin, currentVMin, currentUMax, currentVMax = getComponentsBoundingBox(uvs)
currentUCenter, currentVCenter = (currentUMin + currentUMax) / 2.0, (currentVMin + currentVMax) / 2.0
currentWidth, currentHeight = currentUMax - currentUMin, currentVMax - currentVMin
currentScale = max(currentWidth, currentHeight)
scaleFactor = scale / currentScale
cmds.polyEditUV(uvs, u=uCenter - currentUCenter, v=vCenter - currentVCenter)
scaleComponentsUVs(uvs, su=scaleFactor, sv=scaleFactor)
return True
示例6: flipUVsByLocal
def flipUVsByLocal(*args):
sel = cmds.ls(sl=True, fl=True, long=True)
u = 0.0
for i in sel:
uv = cmds.polyEditUV(i, relative=False, q=True, uValue=True)
u += uv[0]
uAve = u / len(sel)
u_tile = int(str(uAve)[0])
flipAxis = u_tile + 0.5
cmds.polyEditUV(relative=False, pivotU=flipAxis, scaleU=-1)
示例7: moveComponentsUVs
def moveComponentsUVs(components, u=0, v=0):
"""
This definition moves given components UVs.
:param components: Components. ( Tuple / List )
:param u: U value. ( Float )
:param v: V value. ( Float )
:return: Definition succes. ( Boolean )
"""
uvs = getUVsFromComponents(components, flatten=False)
cmds.polyEditUV(uvs, u=u, v=v)
return True
示例8: getUVFaceNormal
def getUVFaceNormal( facepath ):
uvs = getWindingOrder(facepath)
if len(uvs) < 3: return (1,0,0) #if there are less than 3 uvs we have no uv area so bail
#get edge vectors and cross them to get the uv face normal
uvAPos = cmd.polyEditUV(uvs[0], query=True, uValue=True, vValue=True)
uvBPos = cmd.polyEditUV(uvs[1], query=True, uValue=True, vValue=True)
uvCPos = cmd.polyEditUV(uvs[2], query=True, uValue=True, vValue=True)
uvAB = Vector( [uvBPos[0]-uvAPos[0], uvBPos[1]-uvAPos[1], 0] )
uvBC = Vector( [uvCPos[0]-uvBPos[0], uvCPos[1]-uvBPos[1], 0] )
uvNormal = uvAB.cross( uvBC ).normalize()
return uvNormal
示例9: centerComponentsUVs
def centerComponentsUVs(components):
"""
This definition centers given components UVs.
:param components: Components. ( Tuple / List )
:return: Definition succes. ( Boolean )
"""
uvs = getUVsFromComponents(components)
uMin, vMin, uMax, vMax = getComponentsBoundingBox(uvs)
uCenter, vCenter = (uMin + uMax) / 2.0, (vMin + vMax) / 2.0
uTargetCenter, vTargetCenter = math.floor(uCenter), math.floor(vCenter)
cmds.polyEditUV(uvs, u=uTargetCenter - uCenter + 0.5, v=vTargetCenter - vCenter + 0.5)
return True
示例10: alignUVs
def alignUVs(doU, minU, doV, inV):
"""
align selected uvs based on the one most on top, bottom, left, right
"""
# get the selected UVs from current selection
selectedItems = cmds.filterExpand(ex=False, sm=35) # 35 means UVs
uvMin = []
uvMax = []
# get the 3d bounding box of selection
uvInfo = cmds.polyEvaluate(bc2=True)
uvMin[0] = uvInfo[0]
uvMin[1] = uvInfo[2]
uvMax[0] = uvInfo[1]
uvMax[1] = uvInfo[3]
if doU:
if minU:
cmds.polyEditUV(r=False, u=uvMin[0])
else:
cmds.polyEditUV(r=False, u=uvMax[0])
if doV:
if minV:
cmds.polyEditUV(r=False, v=uvMin[1])
else:
cmds.polyEditUV(r=False, v=uvMax[1])
示例11: mirrorGeometry
def mirrorGeometry(*args, **keywords):
# Mirror geometry together with UV. The UV of character can be splited into a number of U regions.
# usage: select geometry which is present in the +x side and UVs in U=0.5-1 region (and U=1.5-2, U=2.5-3, ...)
meshes = cmds.listRelatives(s=True, type="mesh", ni=True, f=True)
if meshes == None:
raise Exception, "No mesh selected"
results = []
for mesh in cmds.listRelatives(meshes, p=True, f=True):
verticesInRegion = {}
parent = cmds.listRelatives(mesh, p=True, f=True, pa=True)
mesh1 = cmds.duplicate(mesh)
mesh2 = cmds.duplicate(mesh)
cmds.scale(-1, 1, 1, mesh2, r=True)
# detect uv regions
# scan all vertices
vertices = cmds.ls(cmds.polyListComponentConversion(mesh2, tuv=True), fl=True)
for vertex in vertices:
uv = cmds.polyEditUV(vertex, query=True)
region = math.ceil(uv[0]) - 1
if region < 0:
region = 1
if not verticesInRegion.has_key(region):
verticesInRegion[region] = []
verticesInRegion[region].append(vertex)
# choose vertices in regions
# flip uv upon middle of regions
for region,vertices in verticesInRegion.iteritems():
cmds.select(vertices, r=True)
cmds.polyEditUV(pu=(region + 0.5), pv=0.5, su=-1, sv=1)
# combine objects and merge vertices
combined = cmds.polyUnite(mesh1, mesh2, ch=False)
if parent:
results += cmds.parent(combined, parent)
else:
results += combined
cmds.polyMergeVertex(d=0.005, ch=0)
cmds.select(results, r=True)
return results
示例12: createFollicle
def createFollicle():
sel = cmds.ls(sl = True,fl = True)
for i in range(len(sel)):
surfaceTransform = sel[i].split('.')[0]
surfaceShape = cmds.listRelatives(surfaceTransform,type = 'shape')[0]
uvPoint = sel[i]
uvValues = cmds.polyEditUV(uvPoint,query = True)
uValue = uvValues[0]
vValue = uvValues[1]
follicle = cmds.createNode('follicle')
follicleTransform = cmds.listRelatives(follicle,parent = True)[0]
cmds.connectAttr('%s.outTranslate'%follicle,'%s.translate'%follicleTransform)
cmds.connectAttr('%s.outRotate'%follicle,'%s.rotate'%follicleTransform)
cmds.setAttr('%s.parameterU'%follicle,uValue)
cmds.setAttr('%s.parameterV'%follicle,vValue)
cmds.connectAttr('%s.outMesh'%surfaceShape, '%s.inputMesh'%follicle,f = True)
cmds.connectAttr('%s.worldMatrix[0]'%surfaceShape, '%s.inputWorldMatrix'%follicle)
示例13: flatten_marvelous_shells
def flatten_marvelous_shells(shells):
"""
Usage:
flatten_marvelous_shells(mc.ls(sl=True))
"""
for obj in shells:
start_vert, end_vert = mc.ls(
mc.polyListComponentConversion(cmds.ls(obj + ".e[0]")[0], fe=True, tv=True), fl=True
)
start_scale = distance.euclidean(
mc.xform(start_vert, q=True, t=True, ws=True), mc.xform(end_vert, q=True, t=True, ws=True)
)
for uv in cmds.ls(obj + ".map[:]", fl=True):
uv_pos = mc.polyEditUV(uv, q=True)
uv_index = re.findall("\[([0-9]+)\]", uv)[0]
vertex = mc.polyListComponentConversion(uv, fuv=True, tv=True)[0]
mc.xform(vertex, t=[uv_pos[0]] + [0] + [uv_pos[1]], ws=True)
# Finally, scale it
end_scale = distance.euclidean(
mc.xform(start_vert, q=True, t=True, ws=True), mc.xform(end_vert, q=True, t=True, ws=True)
)
scale_by = start_scale / end_scale
mc.xform(mc.ls(obj + ".vtx[:]"), s=[scale_by, scale_by, scale_by], ws=True)
示例14: udimFromNode
def udimFromNode(node):
uPos, vPos = cmds.polyEditUV(node+'.map[1]', q=True)
uTile = int(math.floor(uPos))
vTile = int(math.floor(vPos))
udim = 1000+(uTile+1)+(vTile*10)
return udim, uTile, vTile
示例15: testPolyUVs
def testPolyUVs(self):
MayaCmds.polyCube(name = 'cube')
cubeObj = getObjFromName('cubeShape')
fnMesh = OpenMaya.MFnMesh(cubeObj)
# get the name of the current UV set
uvSetName = fnMesh.currentUVSetName()
uArray = OpenMaya.MFloatArray()
vArray = OpenMaya.MFloatArray()
fnMesh.getUVs(uArray, vArray, uvSetName)
newUArray = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, -1, -1]
newVArray = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 1 , 0, 1]
for i in range(0, 14):
uArray[i] = newUArray[i]
vArray[i] = newVArray[i]
fnMesh.setUVs(uArray, vArray, uvSetName)
self.__files.append(util.expandFileName('polyUvsTest.abc'))
MayaCmds.AbcExport(j='-uv -root cube -file ' + self.__files[-1])
# reading test
MayaCmds.AbcImport(self.__files[-1], mode='open')
MayaCmds.select('cube.map[0:13]', replace=True)
uvs = MayaCmds.polyEditUV(query=True)
for i in range(0, 14):
self.failUnlessAlmostEqual(newUArray[i], uvs[2*i], 4,
'map[%d].u is not the same' % i)
self.failUnlessAlmostEqual(newVArray[i], uvs[2*i+1], 4,
'map[%d].v is not the same' % i)