#include <math.h>
#include <maya/MPxCommand.h>
#include <maya/MStatus.h>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MObject.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MObjectArray.h>
#include <maya/MPlugArray.h>
#include <maya/MFnCharacter.h>
#include <maya/MFnClip.h>
#include <maya/MFnAnimCurve.h>
#include <maya/MDGModifier.h>
#include <maya/MIOStream.h>
#define CheckError(stat,msg) \
if ( MS::kSuccess != stat ) { \
displayError(msg); \
continue; \
}
{
public:
createClip();
~createClip() override;
static void* creator();
private:
};
createClip::createClip()
{
}
createClip::~createClip() {}
void* createClip::creator()
{
return new createClip;
}
bool createClip::isUndoable() const
{
return true;
}
{
return status;
}
{
bool charNameUsed = 0;
const MString charFlagLong (
"-char");
for (
unsigned int i = 0; i < args.
length(); i++ ) {
if (!stat)
continue;
if ( arg == charFlag || arg == charFlagLong ) {
arg += ": must specify a character name";
displayError(arg);
return MS::kFailure;
}
i++;
charNameUsed = 1;
}
else {
arg += ": unknown argument";
displayError(arg);
return MS::kFailure;
}
}
if (charNameUsed) {
for ( ; !iter.isDone(); iter.next() ) {
iter.getDependNode(node);
fCharacter = node;
break;
}
}
if (fCharacter.isNull()) {
MString errMsg(
"Character flag must specify a character node.");
displayError(errMsg);
return MS::kFailure;
}
}
return stat;
}
{
if (stat != MS::kSuccess) {
return stat;
}
unsigned int count = 0;
if (fCharacter.isNull()) {
if (0 == activeList.
length()) {
MString errMsg(
"No character was specified, and no objects were selected.");
displayError(errMsg);
return MS::kFailure;
}
if (stat != MS::kSuccess) {
MString errMsg(
"Failed to create character using the selection.");
displayError(errMsg);
return MS::kFailure;
}
} else {
}
for (count = 0; count < plugs.
length(); ++count) {
}
for (count = 0; count < plugs.
length(); ++count) {
MPlug animPlug = plugs[count];
fnCharacter.
addCurveToClip(clipCurves[count],sourceClip,animPlug,fMod);
}
schedStart,
fMod,
&stat);
schedStart.setValue(30.0);
schedStart,
fMod,
&stat);
return stat;
}
{
return status;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"4.0",
"Any");
status = plugin.registerCommand( "createClip", createClip::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "createClip" );
if (!status) {
status.
perror(
"deregisterCommand");
}
return status;
}