python - 在 Maya API 中选择顶点到边缘选择?
问题描述
我正在尝试将选择顶点转换为 Maya api 中的边选择……您有什么建议吗?
就像 cmds 中的 polyListComponentConversion 一样?:)
多谢!!
解决方案
一种方法是使用MItMeshVertex
和收集连接的边:
import maya.api.OpenMaya as om
# Assume we've created a poly cube and selected vertices 2, 3, 5.
selection = om.MGlobal.getActiveSelectionList()
assert selection.length() == 1
node, component = selection.getComponent(0)
edges = set()
it = om.MItMeshVertex(node, component)
while not it.isDone():
connected_edges = it.getConnectedEdges()
edges.update(connected_edges)
it.next()
print(edges)
这应该打印:
set([1, 2, 4, 5, 6, 7, 9])
polyListComponentConversion
应该给出相同的结果:
cmds.select('pCube1.vtx[2:3]', replace=True)
cmds.select('pCube1.vtx[5]', add=True)
edges = cmds.polyListComponentConversion(fromVertex=True, toEdge=True)
print(edges)`
[u'pCube1.e[1:2]', u'pCube1.e[4:7]', u'pCube1.e[9]']
这扩展到同一组索引。
推荐阅读
- c# - 为 Visual Studio 定义模板时,是否可以指定光标(插入符号)位置?
- r - R. 在目录中的许多数据帧列表上运行 lm 函数。错误:“字符”类型的“环境”参数无效
- continuous-integration - 基于正则表达式的规则子句在 GitLab CI 中不起作用
- unit-testing - 使用 spy 模拟在测试的类中创建的完整对象
- sas - 处理 Proc Transpose 中的重复问题或文本
- api - prometheus 查询返回不一致的结果
- javascript - 带有两个按钮的录音功能,一个用于开始录音,另一个用于停止录音
- blazor - 初始连接时 Blazor 服务器端应用程序黑屏
- python - Wagtail:如何在 ModelAdmin 中使用 view_restrictions 过滤查询集?
- javascript - React Redux 中的 DispatchToProps() 方法