#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MPointArray.h>
#include <maya/MDoubleArray.h>
#include <maya/MPoint.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MItCurveCV.h>
#include <maya/MGlobal.h>
#include <maya/MDagPath.h>
#include <maya/MString.h>
#include <maya/MPxCommand.h>
#include <maya/MArgList.h>
{
public:
helix2();
virtual ~helix2();
static void* creator();
private:
double radius;
double pitch;
};
{
for (
unsigned i = 0; i < args.
length(); i++ ) {
{
double tmp = args.
asDouble( ++i, &status );
pitch = tmp;
}
{
double tmp = args.
asDouble( ++i, &status );
radius = tmp;
} else {
displayError( msg );
}
}
cerr << "doIt: could not create selection list iterator\n";
return status;
}
if (list.isDone()) {
cerr << "doIt: no curve has been selected\n";
}
list.getDagPath( fDagPath, fComponent );
return redoIt();
}
{
unsigned i, numCVs;
numCVs = curveFn.numCVs();
status = curveFn.getCVs( fCVs );
{
cerr << "redoIt: could not get cvs status: " << status << endl;
}
for (i = 0; i < numCVs; i++)
points[i] =
MPoint( radius * cos( (
double)i ),
pitch * (double)i,
radius * sin( (double)i ) );
status = curveFn.setCVs( points );
{
cerr << "redoIt: could not setCVs status: " << status << endl;
return status;
}
status = curveFn.updateCurve();
{
cerr << "redoIt: updateCurve() failed status: " << status << endl;
return status;
}
}
{
status = curveFn.setCVs( fCVs );
{
cerr << "undoIt: array length is " << fCVs.length()
<< "bad status: " << status << endl;
return status;
}
status = curveFn.updateCurve();
{
cerr << "undoIt: updateCurve() failed status: " << status << endl;
return status;
}
}
void* helix2::creator()
{
return new helix2();
}
helix2::helix2()
: radius( 4.0 ),
pitch( 0.5 ),
fComponent()
{}
helix2::~helix2()
{
fCVs.clear();
}
bool helix2::isUndoable() const
{
return true;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerCommand( "helix2", helix2::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "helix2" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return status;
}