connect_attrs

MPlugs: Connecting Plugs

Connecting two MPlugs together is fairly simple and is accomplished with MDGModifier.connect(). Lets connect two polygon spheres together such that translating one on X will translate the other on Y.

sphere_connect

First create the spheres and get them as MObjects.

Now we can write a function that makes use of MDGModifier.connect() to hook the spheres together. Connect takes two inputs Рsource MPlug and destination MPlug. In a previous post I covered how to get an MPlug on a node which will come in handy here.

Here’s everything together.

sphere_connect_node