[Closed] nodePreDelete Callback Problem
I need to delete the children of an object when the user delete that object. I used the node predelete callback with the callbacks.notificationparams() ans some filtering to catch that kind of event.
I succeded in a way for i get the object to be deleted, but for a reason i don’t understand i can’t access to th children of the object.
Here is the simplified function i use
fn preDelete =
(
local nodeToBeDeleted = callbacks.notificationparams() –return the node
delete nodeToBeDeleted.children[1] – return UNDEFINED !!!
)
I’ve tried too assuming nodeToBeDeleted is an array writing
Could sommeone give a hint ?
fn preDelete =
(
local nodeToBeDeleted = callbacks.notificationparams() –return the node
delete nodeToBeDeleted[1].children[1] – return unknown Property: “children” in SubAnim:Visibility
)
Since you’re deleting nodes in the callback function itself, your function causes the callback to be executed recursively (until the script errors out as the last node would not have any children). One way around this would be to first disable the callback, then delete the children, and then enable the callback again.
Martijn
This is because the internal broadcast notification is sent too late. What happens is the children are detached, and then the notification is sent.
I want to add a preprenodedelete callback to maxscript, since this is an obvious limitation. The present callback needs it’s documentation updated to reflect the current scene state. That is something that Bobo should update in the docs.
Chris J.
Thank you for answering.
I thought someting like this was happening and wanted to try a nodeunlinked, but it seems impossible to make the nodepredelete and nodeunlinked to work together.
But is it possible for example to store an array of the children’ s node just before the actual delete of the parent’s node occurs ?
I’ve tried the proposition of Magicsm, but it doesn’t seem to work. I removed the callback directly inside the function, but when i do this the callback isn’t triggered anymore…