#include <maya/MFnPlugin.h>
#include <maya/MArgDatabase.h>
#include <maya/MPxCommand.h>
#include <maya/MGlobal.h>
#include <maya/MIOStream.h>
#include <maya/MSyntax.h>
#include <maya/MSelectionList.h>
#include <maya/MFnDependencyNode.h>
#define kFlagIcon "-i"
#define kFlagIconLong "-icon"
{
public:
nodeIcon();
virtual ~nodeIcon();
static void *creator();
};
nodeIcon::nodeIcon()
{
}
nodeIcon::~nodeIcon()
{
}
void *nodeIcon::creator()
{
return( new nodeIcon() );
}
bool nodeIcon::hasSyntax()
{
return( true );
}
{
kFlagIconLong,
return( syntax );
}
{
return( status );
}
bool queryUsed = argData.isQuery();
bool iconUsed = argData.isFlagSet( kFlagIcon );
status = argData.getObjects( sList );
"nodeIcon: could not query the selection list" );
}
"nodeIcon: you need to specify at least one node" );
}
if ( iconUsed ) {
kFlagIcon, 0, iconName ) );
} else if ( !queryUsed ) {
"nodeIcon: the -icon flag needs to be specified in edit mode" );
}
int i;
for ( i = 0; i < count; i++ ) {
"nodeIcon: only nodes can be selected" );
}
if ( queryUsed ) {
result = nodeFn.icon( &status );
"nodeIcon: could not query the icon assigned to the node" );
}
} else {
status = nodeFn.setIcon( iconName );
"nodeIcon: the filename specified by the -icon flag could not be opened" );
return( status );
}
result = iconName;
}
}
return( status );
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"10.0",
"Any" );
status = plugin.registerCommand( "nodeIcon", nodeIcon::creator,
nodeIcon::newSyntax );
if ( !status ) {
"nodeIcon: failed to register the plug-in" );
}
return( status );
}
{
status = plugin.deregisterCommand( "nodeIcon" );
if ( !status ) {
"nodeIcon: failed to deregister the plug-in" );
}
return( status );
}