PDA

View Full Version : intercept user action and propogate MAXScript using plugin


nathan7
01-14-2008, 03:36 PM
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!\n"));

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!

RustyKnight
01-15-2008, 05:11 AM
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()
The docs sayvoid *param
A pointer to a parameter which will be passed to the callback functionWhich 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)

nathan7
01-15-2008, 06:23 AM
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...

scorpion007
01-15-2008, 08:20 AM
and what error is that?

CGTalk Moderation
01-15-2008, 08:20 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.