-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathaddTcSoftIkSolverCallbacks.cpp
56 lines (48 loc) · 1.63 KB
/
addTcSoftIkSolverCallbacks.cpp
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
#include "addTcSoftIkSolverCallbacks.h"
#include <maya/MSelectionList.h>
#include <maya/MGlobal.h>
#include <maya/MSceneMessage.h>
MCallbackId addTcSoftIkSolverCallbacks::afterNewId;
MCallbackId addTcSoftIkSolverCallbacks::afterOpenId;
void *addTcSoftIkSolverCallbacks::creator()
{
return new addTcSoftIkSolverCallbacks;
}
void createIK2BsolverAfterNew(void *clientData)
//
// This method creates the ik2Bsolver after a File->New.
//
{
MSelectionList selList;
MGlobal::getActiveSelectionList( selList );
MGlobal::executeCommand("if(!`objExists tcSoftIkSolver`){createNode -n tcSoftIkSolver tcSoftIkSolver;};");
MGlobal::setActiveSelectionList( selList );
}
void createIK2BsolverAfterOpen(void *clientData)
//
// This method creates the ik2Bsolver after a File->Open
// if the ik2Bsolver does not exist in the loaded file.
//
{
MSelectionList selList;
MGlobal::getSelectionListByName("tcSoftIkSolver", selList);
if (selList.length() == 0) {
MGlobal::getActiveSelectionList( selList );
MGlobal::executeCommand("if(!`objExists tcSoftIkSolver`){createNode -n tcSoftIkSolver tcSoftIkSolver;};");
MGlobal::setActiveSelectionList( selList );
}
}
MStatus addTcSoftIkSolverCallbacks::doIt(const MArgList &args)
//
// This method adds the File->New and File->Open callbacks
// used to recreate the ik2Bsolver.
//
{
// Get the callback IDs so we can deregister them
// when the plug-in is unloaded.
afterNewId = MSceneMessage::addCallback(MSceneMessage::kAfterNew,
createIK2BsolverAfterNew);
afterOpenId = MSceneMessage::addCallback(MSceneMessage::kAfterOpen,
createIK2BsolverAfterOpen);
return MS::kSuccess;
}