Maya Python如何以编程方式在MASH上设置输入网格?

2024-10-01 04:54:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在Maya中创建MASH,并使用Python API设置输入网格。这在GUI中非常简单,但我花了几个小时,不知道如何在API中工作。以下是我目前的代码:

from maya import cmds
import MASH.api as mapi

#create backplate
backplate = cmds.polyPlane(w=10,h=10)

#create cube
cube = cmds.polyCube(w=10,h=10)

#create mash
cmds.select(cube[0])
mashNetwork = mapi.Network()
mashNetwork.createNetwork()

#set mash to mesh distribution type
cmds.setAttr(mashNetwork.distribute + '.arrangement', 4)

这之后我该怎么办?我希望背板成为MASH的输入网格。我知道我需要设置的参数可以通过以下方式访问:mashNetwork.distribute+'.inputMesh'

但不管我怎么做,我都会出错。我试过setAttr,connectAttr,但都没有成功。有人知道怎么做吗


Tags: importapi网格createguidistributemashcmds
1条回答
网友
1楼 · 发布于 2024-10-01 04:54:44

您需要将shape节点的outMesh连接到MASH_DistributeinputMesh属性。您可以在“节点编辑器”(Node Editor)中检查手动创建的连接,以了解它在没有先编写脚本的情况下是如何工作的

cmds.connectAttr('pPlaneShape1.outMesh', mashNetwork.distribute + '.inputMesh')

相关问题 更多 >