#include <maya/MIOStream.h>
#include <maya/MFnPlugin.h>
#include <maya/MString.h>
#include <maya/MArgList.h>
#include <maya/MPxCommand.h>
#include <maya/MGlobal.h>
#include <maya/MItSelectionList.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MPxData.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MFnPluginData.h>
class blindDoubleData :
public MPxData
{
public:
blindDoubleData();
~blindDoubleData() override;
double value() const;
void setValue( double );
static void* creator();
private:
double fValue;
};
{
public:
blindDoubleDataCmd();
~blindDoubleDataCmd() override;
public:
static void* creator();
};
void* blindDoubleData::creator()
{
return new blindDoubleData;
}
blindDoubleData::blindDoubleData()
:fValue( 0 )
{
}
blindDoubleData::~blindDoubleData()
{}
double blindDoubleData::value() const
{
return fValue;
}
void blindDoubleData::setValue( double newValue )
{
fValue = newValue;
}
void blindDoubleData::copy (
const MPxData& other )
{
fValue = ((const blindDoubleData&)other).fValue;
}
MTypeId blindDoubleData::typeId()
const
{
return blindDoubleData::id;
}
MString blindDoubleData::name()
const
{
return blindDoubleData::typeName;
}
unsigned& lastParsedElement )
{
fValue = args.
asDouble( lastParsedElement++, &status );
return status;
} else {
return MS::kFailure;
}
}
MStatus blindDoubleData::writeASCII( ostream& out )
{
out << fValue << " ";
return MS::kSuccess;
}
MStatus blindDoubleData::readBinary( istream& in,
unsigned )
{
in.read( (char*) &fValue, sizeof( fValue ));
return in.fail() ? MS::kFailure : MS::kSuccess;
}
MStatus blindDoubleData::writeBinary( ostream& out )
{
out.write( (char*) &fValue, sizeof( fValue));
return out.fail() ? MS::kFailure : MS::kSuccess;
}
const MTypeId blindDoubleData::id( 0x80003 );
const MString blindDoubleData::typeName(
"blindDoubleData" );
void* blindDoubleDataCmd::creator()
{
return new blindDoubleDataCmd;
}
blindDoubleDataCmd::~blindDoubleDataCmd()
{
}
blindDoubleDataCmd::blindDoubleDataCmd()
{
}
{
if ( MS::kSuccess == stat )
stat = redoIt();
return stat;
}
MStatus blindDoubleDataCmd::redoIt()
{
for ( ; !iter->isDone(); iter->next() )
{
if ( MS::kSuccess != iter->getDependNode( dependNode ) ) {
cerr << "Error getting the dependency node" << endl;
continue;
}
if ( MS::kSuccess != stat ) {
cerr << "Error creating MFnDependencyNode" << endl;
continue;
}
const MString fullName(
"blindDoubleData" );
if( !fnDN.findPlug( fullName, true ).isNull() ) {
continue;
}
blindDoubleData::id );
MPlug plug( dependNode, newAttr );
blindDoubleData * newData = new blindDoubleData;
newData->setValue( 3.2 );
stat = plug.setValue( newData );
stat = plug.getValue( sData );
if ( stat != MS::kSuccess ) {
cerr << "error getting value off plug" << endl;
continue;
}
blindDoubleData* data = ( blindDoubleData* ) pdFn.constData( &stat );
if ( NULL == data ) {
cerr << "error: failed to retrieve data." << endl;
}
}
return MS::kSuccess;
}
MStatus blindDoubleDataCmd::undoIt()
{
return MS::kSuccess;
}
bool blindDoubleDataCmd::isUndoable() const
{
return true;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any" );
status = plugin.registerData("blindDoubleData", blindDoubleData::id,
blindDoubleData::creator);
if (!status) {
status.
perror(
"registerData");
return status;
}
status = plugin.registerCommand("blindDoubleData",
blindDoubleDataCmd::creator);
if (!status) {
plugin.deregisterData( blindDoubleData::id );
status.
perror(
"registerCommand");
return status;
}
return MS::kSuccess;
}
{
status = plugin.deregisterCommand( "blindDoubleData" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
status = plugin.deregisterData( blindDoubleData::id );
if (!status) {
status.
perror(
"deregisterData");
return status;
}
return status;
}