我想用Python编写一个用于Maya的脚本,它允许您在平视显示中看到顶点的数值转换。在
因此,如果拾取一个顶点并将其沿轴移动,则在平视显示中应显示该顶点的起始世界位置的移动值。在
例如,世界位置是顶点的'20,20,50',我把它移动到'20,20,30'在平视显示应该显示'0 0 20'。在
我离得很远,但这是我到现在为止所做的。在
import maya.cmds as cmds
selection = cmds.ls(sl=True)
for obj in selection:
vertexWert = cmds.pointPosition( obj , w=True)
print vertexWert
您可以使用对象的
attributeChanged
属性上的attributeChanged
脚本作业来获取有关更改的通知,以便在编辑网格时激发脚本。但是,这不知道为什么网格会改变:例如,如果旋转顶点选择而不是移动它,它将被触发。你必须存储一份垂直位置的副本,并将新位置与旧位置进行比较,以获得实际差异。在下面是一个使用prints的非常基本的示例(headsUpDisplay命令非常冗长,所以我将其排除在外)。我还使用了一个全局变量,这通常是一个坏主意,但听起来向问题中添加类会使演示变得更困难:“正确”的做法是创建一个可调用的类来管理网格差异。在
这并不是Maya擅长通过脚本来做的事情:在大网格上,这会非常慢,因为你要处理大量的数字。不过,对于小例子来说,它应该是有效的。在
相关问题 更多 >
编程相关推荐