#include <string.h>
#include <maya/MIOStream.h>
#include <math.h>
#include <maya/MPxNode.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
{
public:
arcLen();
~arcLen() override;
static void* creator();
public:
};
arcLen::arcLen() {}
arcLen::~arcLen() {}
void* arcLen::creator()
{
return new arcLen();
}
{
if( plug == output )
{
if( !status ) {
status.
perror(
"ERROR getting data");
} else {
if( !status ) {
status.
perror(
"ERROR creating curve function set");
} else {
double result = curveFn.length();
outputHandle.
set( result );
}
}
} else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
{
inputCurve = typedAttr.
create(
"inputCurve",
"in",
&status );
if( !status ) {
status.
perror(
"ERROR creating arcLen curve attribute");
return status;
}
output = numericAttr.
create(
"output",
"out",
&status );
if( !status ) {
status.
perror(
"ERROR creating arcLen output attribute");
return status;
}
status = addAttribute( inputCurve );
if( !status ) {
status.
perror(
"addAttribute(inputCurve)");
return status;
}
status = addAttribute( output );
if( !status ) {
status.
perror(
"addAttribute(output)");
return status;
}
status = attributeAffects( inputCurve, output );
if( !status ) {
status.
perror(
"attributeAffects(inputCurve, output)");
return status;
}
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode( "arcLen", arcLen::id, arcLen::creator,
arcLen::initialize);
if (!status) {
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode( arcLen::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}