PDA

View Full Version : Delete a node and all it's subnodes, just deletes one subnode?


gardin
09-03-2011, 08:48 PM
Hi all

I fell kinda stupid for asking such a simple question, but i couldn't find much about it around here.

If i have a transform node with a lot of sub nodes, when i click delete on the node, or in the outliner, or by calling delete, or even the MGlobal, MDGModifier::deleteNode, it does not delete the node, but deletes one of it's subnodes, subsequent deletes continues to delete subnodes, until there are none left, when it finally deletes the node itself.

Is this supposed to be a feature? Do i have to write some MEL script that iterates over all the child nodes and delete them or am i missing something, is there another command?

Thanks!
Johan

dbsmith
09-04-2011, 10:15 PM
Subnode is a bit vague...can you post up the specific objects that you are deleting and their children? Outliner screenshots even?

zoharl
09-06-2011, 08:10 AM
Please give an example.

gardin
09-08-2011, 11:23 PM
Hi!
Sorry for not responding earlier.

The transform nodes are parented below another transform node. I'm attaching a print screen of the outliner. The node selected, "forv_1" is a transform node. If i try to delete the "vHelix1" by selecting it and pressing delete, one of the "forv_*" or "rev_*" get deleted instead.

If i select a "forv_*" or "rev_*" and press delete (or use any MEL, C++-API commands) it will delete all its children, the next time i press delete it will delete itself.

I did try, however, to create two transforms in MEL with:

createNode transform; // named transform1
createNode -parent transform1 transform;
createNode -parent transform1 transform;

and when selecting and deleting transform1, it all got deleted instantly, so there's something different with the nodes i've created before?

I have a lot of attribute connections between the transformNodes named "forv_*" and "rev_*", does that affect anything?

Thanks!

zoharl
09-10-2011, 07:03 AM
Can you attach a scene file for demonstration?

Also, if you can't do it from the outliner, then it's some issue with maya, and maybe people from the main forum would help you better.

Also it seems that you use 2012. If you can, you should try and reproduce the bug on 2010.

gardin
09-11-2011, 09:23 PM
Sure, i'm attaching a ma-file here. I am using Maya 2011, i currently do not have access to Maya 2009 though, so i can't reproduce the problem.

But, i have tried the same program on an other computer and it's the same problem.

Thanks!

zoharl
09-12-2011, 06:14 AM
I am missing your helix plugin:

# Error: file: C:/7/helix.ma line 6: RuntimeError: file <maya console> line 1: Plug-in, "libvHelix-Native.mll", was not found on MAYA_PLUG_IN_PATH. # // Warning: file: C:/7/helix.ma line 67: Unrecognized node type 'vHelix'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 85: Unrecognized node type 'HelixLocator'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 87: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 449: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 453: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 474: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 495: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 516: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 537: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 558: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 579: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 600: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 621: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 642: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 663: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 684: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 705: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 726: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 747: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 768: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 789: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 810: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 831: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 852: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 873: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 894: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 915: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 936: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 957: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 978: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 999: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 1020: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 1041: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// Warning: file: C:/7/helix.ma line 1045: Unrecognized node type 'HelixBase'; preserving node information during this session. //
// File read in 1 seconds.
// Warning: line 0: Errors have occurred while reading this scene that may result in data loss.


Nevertheless I had the same tree object as yours (more or less), and I didn't have any problem deleting rev_* or vHelix1. You can see this for yourself if you remove your plugin from your path. My guess is that you have a bug in your plugin, and if you think how the delete process goes, it deletes a tree from bottom up. Meaning it first deletes the children first then the parent, up to the head of the tree. If one of the children is your problematic plugin, the delete process would be terminated, after it deleted only the children.
What would I do from here: First I'll verify which object exactly gives me trouble, and if it is indeed related to your plugin. Easy to do, just delete each object from the tree, and test if it causes the problem by deleting the whole tree. After that I'll go and debug the plugin. First I would enable an init log in the beginning of the plugin:

void init_log()
{
MGlobal::startErrorLogging("c:/prj/plug-ins/OpenMayaErrorLog.txt");
MStatus stat = MS::kSuccess;

time_t now = time(NULL);
tm *tnow = localtime(&now);
string log = "--------------------\n";
log += asctime(tnow);
MGlobal::doErrorLogEntry(log.c_str());
cout << log << endl;
}


Then I would check the log file. If I couldn't find anything interesting in the log, I'll start commenting things in the code until I find the culprit.
Good luck.

gardin
09-13-2011, 04:11 AM
Hi!

Thanks for your help, i did found the lines that caused this. It was in the connectionBroken part of my MPxTransform, (the forv and rev elements).

I've had some problems before with the code there, for example when the user selects "New File..." cause this breaks the Dag, and when the user deletes the node. In both these cases it seems as Maya has already begun to destroy the child nodes, but they're still returned when you query for them using a MFnDagNode on thisMObject().

What i do in the connectionBroken is that i look for aimConstraints belonging to this node and deleting them and when connections are made i create new ones. Searching for them and finding them always work, but it's the delete operation that messes up Maya and causes it to crash or in this case abort.

In the case of the "New File" operation, it was easily solved with a MFileIO::isNewFile or i forgot the name, anyhow this case seems a bit more problematic since there does not seem to be a way to see if a node is up for deletion or is deleted. Earlier someone suggested MObject::isNull but that does not work cause it's not null, the objects are there, but they're invalid..

If anyone has any idea and/or you want me to show some sample code i'm on it!!

Thanks!
//Johan

zoharl
09-13-2011, 06:43 AM
How about MNodeMessage:addNodeAboutToDeleteCallback() ?

gardin
01-27-2012, 05:59 AM
Sorry for not replying earlier as the project was set on hold there for a while.

MNodeMessage:addNodeAboutToDeleteCallback() was perfect though as i'm now able to avoid making any "dangerous" calls when the node is in fact being deleted. Thanks a lot for your help as you prob saved me many hours!!

CGTalk Moderation
01-27-2012, 05:59 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.