aboutsummaryrefslogtreecommitdiff
path: root/mayaPlug/isSharedCmd.cpp
blob: 18881ebaa9f48260a845001c30d15220440133d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

#include "shaveIO.h"

#include <maya/MArgDatabase.h>
#include <maya/MArgList.h>
#include <maya/MDagPath.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MGlobal.h>
#include <maya/MSelectionList.h>
#include <maya/MSyntax.h>
#include <maya/MString.h>

#include "isSharedCmd.h"

const MString isSharedCmd::commandName("isShared");
const MString shaveRepair::commandName("shaveRepair");
const MString shavePurge::commandName("shavePurge");


isSharedCmd::isSharedCmd()	{}
isSharedCmd::~isSharedCmd()	{}


void* isSharedCmd::createCmd()
{
	return new isSharedCmd();
}


MSyntax isSharedCmd::createSyntax()
{
	MSyntax	syntax;

	syntax.enableEdit(false);
	syntax.enableQuery(false);

	syntax.setObjectType(MSyntax::kSelectionList, 1, 1);
	syntax.useSelectionAsDefault(false);

	return syntax;
}


MStatus isSharedCmd::doIt(const MArgList& argList)
{
	MStatus 		status;
	MArgDatabase	args(syntax(), argList, &status);

	if (!status) return status;

	//
	// Get the shaveNode to be operated on.
	//
	// Note that if no node was specified on the command line, then
	// getObjects() will return whatever is currently selected.
	//
	MSelectionList	selection;
	args.getObjects(selection);

	MObject	node(MObject::kNullObj);
	selection.getDependNode(0, node);

	MFnDependencyNode	nodeFn(node, &status);

	if (node.isNull() || !status)
	{
		status = MS::kInvalidParameter;
	}
	else
	{
		bool result = nodeFn.isShared();
		setResult(result);
	}

	return status;
}