在 Maya 中使用 python 将平面法线转换为管方向

Convert plane normal to tube orientation with python in Maya

在 Maya 中:我有一个管子,其枢轴位于旋转的平面上,但枢轴不在顶点上。 我想围绕其枢轴旋转管子,使其与离管子枢轴最近的面的法向量完美对齐。

我尝试使用 closestPointOnMesh(您可以在 Constrain > Closest Point 下找到它)来获取面部的法线,但我无法让它工作。 我想 使用 normalConstraint 并在之后删除它,因为它们非常慢,我打算在很多复杂的对象上这样做。

我现在正在使用 normalConstraint 但在删除它之前我断开了 $constraintName.$target + 'W0' 和 $constraintName + '.target[0].targetWeight'

和 $targetShape + '.worldMesh[0]' 和 $constraintName + '.target[0].targetGeometry'

(这些连接是 normalConstraint 创建的默认连接)

通过在删除约束之前断开属性,我将删除时间缩短了将近一半! 不知道为什么!

Maya API 法线约束: https://help.autodesk.com/cloudhelp/2019/ENU/Maya-Tech-Docs/CommandsPython/normalConstraint.html