使用 maya.cmds,我想选择 y = 0 以下的所有顶点,以便我可以删除它们。我将如何实现这一点?此外,我正在处理大量 .obj 网格,因此我需要遍历每个网格并执行相同的操作。要遍历每个文件,我应该使用什么技术?
import maya.cmds as cmds
import maya.api.OpenMaya as om2
# Select all objects
selection = cmds.select(all = True)
# Rotate -90 degrees on the x axis
# cmds.rotate(-90)
def vertexOm2():
"""
Using Maya Python API 2.0
"""
#___________Selection___________
# 1 # Query the selection list
selectionLs = om2.MGlobal.getActiveSelectionList()
# 2 # Get the dag path of the first item in the selection list
selObj = selectionLs.getDagPath(0)
#___________Query vertex position ___________
# create a Mesh functionset from our dag object
mfnObject = om2.MFnMesh(selObj)
return mfnObject.getPoints()
vertexOm2()
这将返回“类型错误:项目不是 DAG 路径”
或者使用 cmds:
def vertexCmds():
"""
Using Maya Cmds
"""
#___________Selection___________
# query the currently selected object
selTemp = str(cmds.ls(selection=True))
# edit retrieved string so we can feed it into commands
sel = selTemp.split("'")[1]
#___________Query vertex position ___________
# use the xform command with the ".vtx[*]" to retrieve all vertex positions at once
vertPosTemp = cmds.xform(sel + '.vtx[*]', q=True, ws=True, t=True)
# split the resulting list into sets of 3
vertPos = zip(*[iter(vertPosTemp)]*3)
return vertPos
我从这里得到了这两个。
慕桂英546537
相关分类