Select Page

Good news, MASH only uses Maya’s default data types, so all MASH data can be accessed via normal Maya APIs.

Ordinarily this isn’t needed as MASH provides two built in ways to extract data:

  1. For the non scripter there’s the Breakout node, which can feed MASH data into float/vector attributes in Maya via connections.
  2. The Python node gives users access to the raw data which they can extract and manipulate in any way they like.

However, for the performance conscious, or for those wanting to write their own MASH nodes or export MASH data in some custom/ game engine format, it might help to know a few things about Maya’s data types and APIs, so here are some simple recipes to get you going. In the following example we’ll get a MASH node (a Waiter), get it’s output data, and print a list of all the channels it contains along with the MASH point positions.

Before we get started, please remember, data getting/setting in Maya should only be done with connections otherwise Parallel Evaluation performance will suffer, so what I’m about to show you should never be run in an expression node.

MASH Data can only be extracted with either the CAPI or PyAPI 1.0. The PyAPI 2.0 isn’t finished yet and thus can’t be used with MASH.

Step 1: Get the MObject for the MASH node.

Step 2: Get a list of channel data and print it.

Step 3: Get a specific channel. In C++ getting the channel data type is trivial, however I’ve never managed to do this in Python (it seems the data type enum get’s mangled when the Python API is auto-generated), so a bit of educated guessing on your part may be needed.

A. Double channel eg. Visibility.

B. Vector array, e.g. Position.
First we need a function to copy the MVectorArray into a Python list:

Now we can use that to get the data:

And you’re done. In C++, everything’s easier, you would check the channel data type first like so and then just copy the array:

Any questions let me know.