maya中用python获取选定模型的点的blendshape值
时间: 2023-10-07 20:08:24 浏览: 102
在Maya中获取选定模型的点的Blendshape值,可以通过以下步骤实现:
1. 获取当前选中模型的名称:
```python
import maya.cmds as cmds
selected_obj = cmds.ls(selection=True)[0]
```
2. 获取模型的Blendshape节点名称:
```python
blendshape_node = cmds.listConnections(selected_obj, type='blendShape')[0]
```
3. 获取Blendshape节点的目标(Target)名称:
```python
target_list = cmds.listAttr(blendshape_node + ".w", multi=True)
```
4. 获取每个目标的权重(Weight)值:
```python
for target in target_list:
weight = cmds.getAttr(blendshape_node + "." + target)
```
5. 获取每个目标的顶点坐标和Blendshape值:
```python
for target in target_list:
weight = cmds.getAttr(blendshape_node + "." + target)
for i in range(num_verts):
vert_pos = cmds.xform(selected_obj + ".vtx[" + str(i) + "]", query=True, translation=True, worldSpace=True)
bs_value = cmds.pointPosition(selected_obj + ".vtx[" + str(i) + "]", world=True)
```
这样就可以获取选中模型的每个顶点的Blendshape值了。
阅读全文