#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/MDagPath.h>
#include <maya/MItSelectionList.h>
#include <maya/MSelectionList.h>
#include <maya/MString.h>
#include <maya/MPoint.h>
#include <maya/MItCurveCV.h>
#include <maya/MItSurfaceCV.h>
#include <maya/MItMeshVertex.h>
#include <maya/MIOStream.h>
{
public:
cvPos();
~cvPos() override;
static void* creator();
private:
};
cvPos::cvPos() :
point(0.0, 0.0, 0.0)
{
}
cvPos::~cvPos() {}
void* cvPos::creator()
{
return new cvPos;
}
bool cvPos::isUndoable() const
{
return true;
}
{
return MS::kSuccess;
}
{
for (
unsigned int i = 0; i < args.
length (); i++)
{
else
componentName = argStr;
}
if (!componentName.
length ()) {
if (iter.isDone ()) {
displayError ("No components selected");
return MS::kFailure;
} else {
iter.getDagPath (dagPath, component);
iter.next ();
if (!iter.isDone ()) {
displayError ("More than one component is selected");
return MS::kFailure;
}
}
} else {
if (! list.
add( componentName ) ) {
componentName += ": no such component";
displayError(componentName);
return MS::kFailure;
}
iter.getDagPath( dagPath, component );
}
displayError("not a component");
return MS::kFailure;
}
{
point = curveCVIter.position(transformSpace );
curveCVIter.next();
if (!curveCVIter.isDone()) {
displayError ("More than one component is selected");
return MS::kFailure;
}
break;
}
{
point = surfCVIter.position(transformSpace );
surfCVIter.next();
if (!surfCVIter.isDone()) {
displayError ("More than one component is selected");
return MS::kFailure;
}
break;
}
{
point = vertexIter.position(transformSpace );
vertexIter.next();
if (!vertexIter.isDone()) {
displayError ("More than one component is selected");
return MS::kFailure;
}
break;
}
default:
cerr <<
"Selected unsupported type: (" << component.
apiType()
}
return redoIt();
}
{
clearResult();
appendToResult( point.x );
appendToResult( point.y );
appendToResult( point.z );
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerCommand( "cvPos", cvPos::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "cvPos" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return status;
}