Select Page

Shuffling MASH Points with the Python node

Say you want to create the above animation of random spokes moving about; to do this you’ll need to shuffle the MASH points, read on to find out why, and how.

Let’s start with a grid distribution:

As you can see, when MASH creates a grid distribution, all the points are in an order (0, 1, 2, 3, 4 across the top here). I’ve used the Points node to visualise the numbers here.

If we add a Trails node to create some lines between a single point and say, 30 MASH points, it will connect to the first 30 points. See below.

This is obviously not what we’re after so we need to add a Python node to shuffle our MASH points and put them into a random order. This means that even though the first 30 points are connected, they’re all in a random order.

You can copy and paste the below into a Python node. It will shuffle all the points in any MASH network.

As you can see, our ids are now shuffled.

You can animate this by ’rounding’ the seed. In this example, every 10 frames we change the seed (it’s rounded up in 10s). I’ve commented out a version that will change the seed every 20 frames so you can see how it works.

So there are actually 2 MASH networks here. The first one just has a grid of little dots. The second one is more interesting; the Instancer is empty, but it has the same grid in the Distribute node as the first network. The second network is the one with the Python and Trails nodes.

The reason there are two different networks is because in the animation the Trails wander about but the grid stays still. So, on the network with the Trails on it, as you’ve probably guessed, I added a Signal node to make the trails animate about.

The finishing touch was adding an Offset node and using the Low Clamp and High Clamp settings to clip the point positions and keep them inside the grid. Before and after below:

On the left are the clamp settings.

On the right is how the MASH Editor looks when we’re finished (ignore the Id node!).

Multiple looping animations with the Instancer

The Time node in MASH is really useful for creating looping or offset animations inherited from an input model. Check out this tutorial for more on that.

The problem is that the Time node is only available when MASH is creating an output mesh via the Repro node (this is MASH’s default mode). This mode can be impractical if you want to create thousands high polygon objects all with looping input animations. So, how do you do this if you’re using the Instancer with MASH?

If you’ve only got one model, the answer is simple, id cycling.

The Id node in MASH can do id cycling which is really useful for looping animations where each frame of the animation is a separate model on the Instancer (you set this up by creating an Animation Snapshot of your model). This is an age old technique that will be familiar to anyone who’s used the Particle Instancer with Maya’s nParticles.

However, what if you’ve got multiple models with different loop lengths (like different models of people cheering in a crowd). The answer here, ladies and gentleman, as with everything else so far on this blog, is the Python node which you would use instead of the Id node. The script is pretty short, take a look:

Getting Particle Positions with the MASH Python node

If for some reason you don’t want to plug your particle system directly into your MASH network you can get particle positions via the Python node like this.

You’ll need to edit the name of the particle system in the Python script, but other then that, you can just copy and paste this script into the Python node in order to use it.

Strange Attractors with MASH and Python

Here’s a quick and dirty implementation of a couple of strange attractors in MASH using the Python node. To use them simply copy and paste the Python into the Python node and click run (top right of the Python Editor).

I used the Trails node in Join the Dots mode to create the tube between all the points (I duplicated it, then got rid of the trails node, and smoothed the mesh). Make sure to have a zeroed distribution on the Distribute node and a few thousand points.

Strange Attractor

This one is a Lorenz System / Attractor. Check out this fantastic Behance page for some inspiration.

Lorenz Attractor

Random 90 Degree rotations in MASH

Add random 90 degree rotations to all MASH objects. To use the code, simply copy and paste it into the Python node.

The below variation will give you random Y rotation, you can use the same idea to adjust the X and Z rotations as well if you need to.

Maya Tip: In View Messages

Maya 2014 added some helpful in-view messages to aid users, here’s an example of how they can be used:

The built in messages are almost universally useless for professionals, however, if you’re a tool developer, you can make your own messages by using the inViewMessage command in MEL of Python.

MEL example from the Manual:


So, if you try them you’ll notice that the Python one looks much nicer, this is because the MEL one has a black background set, and the Python one uses this cool tag which highlights text in yellow.

Alongside this tag you can also use HTML to format your messages, this is extremely useful.

Some of the HTML tags that work are:

<em> – Italics
<hl> – Highlight (not HTML, but it works)
<small> – Small
<i> – Italics
<sub> – Subscript
<sup> – Superscript

<blockquote> – Indented Quote

<h1> – Large heading
<h2> – Medium heading
<h3> – Small heading

<br> – Line break
<p> – Paragraph

<span> – Allows you to set the font colour and size amongst other things.

Dont forget to close your tags like this </tag>

In my opinion these messages should replace a great many calls to ‘print’, ‘error’ and ‘warning’ in the command line.

This example in MEL creates the messages from the top image:


A GIF that didn’t make it into our MASH 3.0 folio.

Maya Tip: Select faces based on a map

I discovered this by accident today and it’s a real treat of a time saver.

To select components based on a map simply do the following:

1. Double click on the Pain Selection Tool.
2. Scroll down to Attribute Maps and roll it out.
3. Open the Import roll out.
4. Click Import… and select a map.


A major time saver as I’m sure you’ll agree