#include <maya/MFnPlugin.h>
#include <maya/MPxCommand.h>
#include <maya/MArgDatabase.h>
#include <maya/MArgList.h>
#include <maya/MPlug.h>
#include <maya/MSelectionList.h>
#include <maya/MSyntax.h>
#define kIndexFlag "-i"
#define kIndexFlagLong "-index"
{
public:
multiPlugInfo();
~multiPlugInfo() override;
static void* creator();
private:
bool isIndex;
};
multiPlugInfo::multiPlugInfo()
: isIndex (false)
{}
multiPlugInfo::~multiPlugInfo() {}
void* multiPlugInfo::creator()
{
return new multiPlugInfo;
}
{
return syntax;
}
bool multiPlugInfo::hasSyntax()
{
return true;
}
{
if (status != MS::kSuccess)
return status;
if (argData.isFlagSet(kIndexFlag))
isIndex = true;
argData.getObjects(slist);
(slist.
getPlug(0, fPlug) != MS::kSuccess))
{
displayError("Must specify an array plug in the form <nodeName>.<multiPlugName>.", false);
return MS::kFailure;
}
return MS::kSuccess;
}
{
if (parseArgs(args) != MS::kSuccess)
return MS::kFailure;
if (stat != MS::kSuccess)
{
displayError("Could not get the plug value.", false);
return MS::kFailure;
}
if (stat != MS::kSuccess)
{
displayError("Could not create the array data handle.", false);
fPlug.destructHandle(dh);
return MS::kFailure;
}
unsigned int i;
for (i=0; i<adh.elementCount(); i++, adh.next())
{
unsigned int indx = adh.elementIndex(&stat);
if (stat != MS::kSuccess)
continue;
if (isIndex)
appendToResult((int)indx);
else
{
{
{
break;
appendToResult((
int)(h.
asShort()));
break;
appendToResult(h.
asInt());
break;
appendToResult((
double)(h.
asFloat()));
break;
break;
default:
displayError("This sample command only supports boolean, integer, and floating point values.", false);
stat = MS::kFailure;
break;
}
}
}
}
fPlug.destructHandle(dh);
return stat;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"1.0",
"Any");
status = plugin.registerCommand( "multiPlugInfo",
multiPlugInfo::creator,
multiPlugInfo::cmdSyntax);
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "multiPlugInfo" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return status;
}