[Closed] intercept user action and propogate MAXScript using plugin
here is my code to intercept node creation, but i always get a runtime error when try to get information from the newly created node:
static void DoNotifyNodeCreated(void *param, NotifyInfo info)
{
int code = info->intcode;
CharStream out = thread_local(current_stdout);
out->printf(_T(“Co3dsMax new node created!
“));
INode node = (INode)param;
TSTR s;
int i = node->NumberOfChildren();
//node->GetClassName( s );
}
RegisterNotification(DoNotifyNodeCreated, this, NOTIFY_NODE_CREATED);
for the 2nd parameter of RegisterNotification, when should i use (1) NULL, (2) this, or
(3) INode* node;
Register…(…, (void *)node, … )
if i use (1) or (3), i get NULL for param in DoNotifyNodeCreated(), if i use (2) and i get runtime error when i try to get number of children in DoNotifyNodeCreated()
also,
i need to pass MAXScript of user actions to a remote site, i think i can use MacroRecorder to force emit some kind of actions not normally emitted, but I don’t know how to access the logged script strings, can help me on that?
Thanks very much!
The docs say
void *param
A pointer to a parameter which will be passed to the callback function
Which would suggest to me that the param is unimportant…it is just something that is passed into the function that you can use…SOOOO, if you don’t need to interact with any other information, then it can be null. It is an optional parameter that can be anything you think you might need to use inside the function call…
Now, here’s the important part, the docs say:
NOTIFY_NODE_CREATED This option is available in release 4.0 and later only.
Sent when a node is created (callParam is pointer to node)
callParam is variable INSIDE the NotifyInfo structure…
SOOOO…you would probably actually want to say…
INode *node = (INode*)param->callParam;
(I think)
hey thanks, i tried
INode * newNode = (INode*)info->callParam;
TSTR s;
int i = newNode->NumberOfChildren();
but still got a error when i try to access NumberOfChildren…