the story is… one of my clients found that “delete xref scene” button pressed second time causes an exception.
i’ve looked in my code guessing that i missed anything… but not. i am checking isdeleted (actually using my own safer version). Oops! and i’ve started digging… now i’m here
just want to say… of course i’ve found solution. but it’s a hack, what i don’t like
What was your hack to get around it other than using my string method?
Can reproduce in the latest beta build of max so there’s still a problem there.
Ah, works ok in 2017.1Update and later. I don’t see a way in earlier releases other than via something like try/catch.
The deletion check code is in maxsdk\include\maxscript\maxwrapper\mxsobjects.h and looks like the following, where val derives from MAXWrapper:
#define deletion_check_test(val)
( (val)->ref_deleted ||
( (val)->NumRefs() > 0 && ((val)->GetReference(0) == NULL) ) ||
( (val)->NumRefs() > 0 &&
(val)->GetReference(0)->TestAFlag(A_IS_DELETED) &&
( ((val)->GetReference(0)->GetInterface(INODE_INTERFACE)==NULL) ||
(((INode*)(val)->GetReference(0))->GetTMController() == NULL) ||
(((INode*)(val)->GetReference(0))->GetParentNode() == NULL)
)
)
)
There are certain times node values are handled via mxs while they are in the process of being created, deleted, or undo/redo of those. Thus some of the funkiness there…
no… it doesn’t work. the reference target for xrefscene is upper rootnode … xrefscene->root … current scene in our case. which is of course stays valid. the tree was gone. but there is no method to get it (not hacky way) without using indexing … but the index stays VALID as well and resets only … i don’t know how. in mxs case only after exception.
probably max 2017 handles it, because GC was changed. maybe it forces the update.
as i said above i’m using my safer method… the code shown has to be reviewed … it doesn’t take into account a situation where a node (animatable) is in ‘pre-deleted’ stage. when it also can’t be treated as a valid object. it happens for example at the moment of ‘predeleted’ node callback
do you think i am kidding?
(
resetmaxfile #noPrompt
b = box()
savemaxfile (file = getdir #temp + @"\xref_test.max")
resetmaxfile #noPrompt
xx = xrefs.addnewxreffile file quite:on
xs = xrefs.getxreffile 1
format "added... % > % == %
" xx xs (xx == xs)
delete xs
format "valid:% deleted:%
" (isvalidobj xs) (isdeleted xs)
)
/* output:
added... XRefScene:"xref_test.max" > XRefScene:"xref_test.max" == true
valid:true deleted:false
*/
if it works in 2017 or 2018 as i said, it doesn’t change anything…
i can write a mxs value that will work only on Monday. all other days it will be shown as “valid camper value”