[Closed] Callback/when construct if patch changes?
Hi,
How can i create some kind of callback or when-construct when ANYTHING in a path changes? I mean in a line or sth. Like when i add vertices, change the path in his length or whatever.
Have a look in the Max help for the geometryChanged callback in the Node Event System.
It might be what you’re looking for.
Thank you! I implemeted that and wanted to call an already existing function when the callback is true. The problem is that as it seems the callback itself supplies two parameters to the function which is called then. But the function I call doesnt need or expect two parameters, it expects non. How can I tell the callback that it should not supply any parameters to the function called?
You can’t tell the callback not to supply the 2 parameters however you can edit your existing function to expect 2 parameters and edit your existing code to supply 2 dummy parameters when using this function. You don’t need to use these parameters for anything.
As far as I know functions called by the ‘Node Event System’ need to be able to accept two parameters.
From the Max help…
Important:
The callback functions always take two parameters: the first is the event name that triggered the function call, the second is a list of node AnimHandles.
The GetAnimByHandle() method must be used to get the node itself.
If the specified function does not expect two arguments, an error will be thrown. For example, if the function ObjFn is passed but it does not provide any arguments, the error will look like
>> MAXScript NodeEventCallback Exception: – Argument count error: ObjFn wanted 0, got 2 <<
From the text of the error one could incorrectly assume that the function was correct and the callback was wrong, but this is not the case.
The callback always passes the two arguments, but if the function is unable to accept them, the error message simply reflects that fact as it has no knowledge what called the function and why it passed two parameters to it.
In the past I’ve had the same problem as Sowiedu and solved it by writing the function to accept two parameters that weren’t used.
well … my bad. i thought that we talk about when construct
because it was my fault that i didn’t read whole post carefully here is a sample how to use when construct for catching geometry change…
delete objects
deleteAllChangeHandlers id:#patch4test
p = quadPatch name:"patch4test" lengthsegs:3 widthsegs:3 length:20 width:20 isselected:on
when geometry p changes id:#patch4test obj do format "geometry: %
" obj
/*
-- or use topology change event:
when topology p changes id:#patch4test obj do format "topology: %
" obj
*/
modPanel.addModToSelection (Edit_Patch()) ui:on
when construct is much faster than Node Event System callbacks because you can define node(s) which you want to check. Node Event System fires events for all scene objects and has the specific priority of event processing …
Ok, I thought we were answering slightly different questions
Thanks for the code snippet, I think… the problem with reading your posts is it makes me want to go back and rewrite stuff that already works… :hmm:
Nah, the function that is called when the callback is true! But I solved it now like the post before yours, i Just faked that parameters in my function
an expression in when construct might be a single expression or block expression, and it might not specify any function or number of function’s parameters.
the callback function and the number of its parameters for when construct doesn’t make any sense.
so you shouldn’t fake anything to make the when construct work right.