When object deleted, delete children. Huh?


#81

are you talking about a deleting of deleted?


#82

Hm. I guess not?

Well what about as MaxObjects then? I never did figure out how setting this up using weak referencing was supposed to work.


#83

Rather than punish someone for deleting a critical node or nodes (stupid or not…) could you not use a #nodePreDelete or #selectedNodesPreDelete [font=Verdana]in a callback mechanism to protect your rig components from being deleted? [/font]

EDIT: Or what about this suggestion…

Wrap your entire rig in a Character Assembly… then when the user attempts to delete a component of the rig… simply use a callback script to:

  1. “Select” the Character Assembly node.
  2. “Lock” the Character Assembly node.
  3. “Destroy” the Character Assembly node.

Because according to the help docs:

Destroying a character deletes the character assembly node. If the character assembly is locked, the entire assembly is deleted. If the assembly is unlocked, the members of the assembly and any animation on the members are unaffected. This command is available only when a character assembly node is selected.


#84

of course you have to use Weak References. Other way you will get a lot limitations related to the Dependency Loop issue.
but… trust me… the when delete construct and tabChanged with #refDeleted will not work with weak references.
so… you have use global callbacks system.
#1 on predelete callback collect all nodes that have to be deleted with the deleting node
#2 on postdelete callback check the list of nodes that have to be deleted, remove all already deleted and delete the rest.


#85

Trying to understand what you mean. These are additional callbacks that will need to be added, or…?

To clarify: what I mean is, are you referring to the #nodePreDelete and #nodePostDelete general callbacks, or something else?


#86

I actually know next to nothing about character assemblies, and the first hit I got when I googled (maxscript “character assembly”) was http://forums.cgsociety.org/showthread.php?t=393967

I realize it’s a somewhat older thread… have changes been made to the way character assemblies work since then?


#87

#1 on predelete callback collect all nodes that have to be deleted with the deleting node
#2 on postdelete callback check the list of nodes that have to be deleted, remove all already deleted and delete the rest.

Sorry, I don’t think I’m getting it…

Specifically, how do I use callbacks to collect nodes??


#88

here is what i am talking about:

callbacks.removescripts id:#delete_same_class

global NodesForDeletion = #()
fn preDeleteWholeClass =
(
	node = callbacks.notificationParam()
	if isvalidnode node do
	(
		NodesForDeletion = for n in (getclassinstances (classof node) astrackviewpick:on) where isvalidnode n.client and n != n.client collect n.client
	)
)
fn postDeleteWholeClass = 
(
	for n in NodesForDeletion where isvalidnode n do delete n
	NodesForDeletion = #()
)

callbacks.addscript #nodePreDelete "preDeleteWholeClass()" id:#delete_same_class
callbacks.addscript #nodePostDelete "postDeleteWholeClass()" id:#delete_same_class

delete objects 
for k=0 to 4 do box pos:[k*30,0,0] widht:20 length:20 height:20
for k=0 to 4 do cylinder pos:[k*30,40,0] radius:10
for k=0 to 4 do sphere pos:[k*30,80,0] radius:10

we style have the issue with REDO and deleting already deleted. but … it can be fixed now :wink:


#89

All right, I’ll see what I can do with this!


#90

Um… you said it can be fixed, but how?

Before, you offered the solution of

#1 on predelete callback collect all nodes that have to be deleted with the deleting node
#2 on postdelete callback check the list of nodes that have to be deleted, remove all already deleted and delete the rest.

But the code you provided already does that and it’s still crashing. So… huh?? What am I missing?


#91

let’s fix the easier part… redo issue.
do you remember when you’ve asked about my ‘voodoo’ with theHold? ok…
change the last code to:

fn preDeleteWholeClass = if not theHold.Redoing() do ...

#92

the next is how to avoid deleting of what was already deleted… any ideas?


#93

I /was/ actually talking about the redo issue.

And my first impulse would be

		if isValidNode n do
		(
			if (isDeleted n) then
			(
				deleteItem nodesForDeletion i
			)
			else
			(
				delete n
			)
		)

But that does not work.


#94

is the REDO issue fixed now? yes, it is. so… you can trust me that “double-del” issue will be solved as well
i’ve asked about any ideas how to do it…
i have three:
#1
ask your company software engineers for support… they probably will help you. but they might ask you for … hmm… dance, kiss… but it’s too offensive
#2


#95

#2
sit and learn c++ and max SDK. but it might take a long time
and … the #3


#96

#3 is … think
that’s what i prefer to do

our idea is perfect. we are collecting all nodes which have to be deleted after their target nodes were deleted, and delete them
sounds good. right? our problem is how to filter nodes those have already been deleted


#97

c’mon! think!


#98

where is the problem of using the pair “node pre deleted/node post deleted”?
we NEED AN EVENT THAT SAYS THAT ALL NODES OF CURRENT DELETING SESSION WERE DELETED
and use this event to delete all nodes associated with deleted


#99

First off… delete something, undelete, redo, using the code you gave me (the one with the rows-of-like-objects), still crashes Max.

Second, shouldn’t (isDeleted obj) be the method used to determine if something has been deleted??


#100

that’s the max global bug. ISDELETED doesn’t work… according to the max nodes are not deleted at the pre-deleted stage and … technically can be deleted