#include <maya/MIOStream.h>
#include <maya/MPxCommand.h>
#include <maya/MFnPlugin.h>
#include <maya/MArgList.h>
#include <maya/MIntArray.h>
#include <maya/MSelectionList.h>
#include <maya/MGlobal.h>
#include <maya/MPlug.h>
#include <maya/MNodeMessage.h>
#include <maya/MCallbackIdArray.h>
void userCB( MNodeMessage::AttributeMessage msg,
MPlug & plug,
MPlug & otherPlug,
void* )
{
if ( msg & MNodeMessage::kConnectionMade ) {
cout << "Connection made ";
} else if ( msg & MNodeMessage::kConnectionBroken ) {
cout << "Connection broken ";
} else {
return;
}
if ( msg & MNodeMessage::kOtherPlugSet ) {
if ( msg & MNodeMessage::kIncomingDirection ) {
cout <<
" <-- " << otherPlug.
info();
} else {
cout <<
" --> " << otherPlug.
info();
}
}
cout << endl;
}
{
public:
nodeMessageCmd() {};
~nodeMessageCmd() override;
static void* creator();
};
nodeMessageCmd::~nodeMessageCmd() {}
void* nodeMessageCmd::creator()
{
return new nodeMessageCmd();
}
{
MCallbackId id;
for (
unsigned int i=0; i<list.
length(); i++ )
{
userCB,
NULL,
&stat);
if ( stat ) {
} else {
cout << "MNodeMessage.addCallback failed\n";
}
}
return stat;
}
{
return plugin.registerCommand( "nodeMessage", nodeMessageCmd::creator );
}
{
for (
unsigned int i=0; i<callbackIds.
length(); i++ ) {
}
return plugin.deregisterCommand( "nodeMessage" );
}