Maya Python - How to set input mesh on MASH programmatically?

1.2k views Asked by At

I'm trying to create a MASH in Maya and set the input mesh using the Python API. This is incredibly simple in the GUI but I've spent hours and can't figure out how to make it work in the API. Here's my code so far:

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)

What do I do after this? I want the backplate to be the input mesh to the MASH. I know the parameter I need to set can be accessed by this: mashNetwork.distribute + '.inputMesh'

But no matter what I try I get an error. I've tried setAttr, connectAttr, all with no luck. Anyone know how to do this?

1

There are 1 answers

0
ababak On

You need to connect an outMesh of the shape node to the inputMesh attribute of the MASH_Distribute. You can inspect the manually created connections in the Node Editor to see how it works without scripting first.

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