InsertObject with existing BaseObjects
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2010 at 12:37, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.514
Platform:
Language(s) : C++ ;---------
Hello,I am writing a plugin to save and restore geometry groupings in the BaseDocument for a major visual effect studio in Los Angeles.
The reason being is that our texture artists have to regroup their geometry for each new model version they receive to paint. I have created a plugin which saves the hierarchy to an xml file and can restore it.
I am having an issue with using BaseObject::InsertUnder(BaseObject * ) with existing BaseObjects in the scene.
Basically, I am trying to move existing polygon shapes / Null objects to new locations in the scenegraph.After I call
obj- >InsertUnder( parentObj );
the object lives in 2 locations in the scenegraph, it's original location and the new spot.
When you select either of the same name objects, both are highlighted.
If you attempt to move the NULL objects above, c4d crashes. It only becomes stable, if I manually parent the 'old location' object to it's new location. Then, I am left with only one object in the proper location.The other issue is after I call 'obj- >InsertUnder( parentObj );', and get 2 copies of obj,
if I attempt to traverse the scenegraph (w obj- >GetNext() / obj->GetDown ),
I have a circular loop in the graph.###############
I am wondering if I need to issue a command to trigger the BaseDocument to refresh or flush the object from its original location.
I have tried this : **
obj- >InsertUnder( parentObj );
obj->Message(MSG_UPDATE);
doc->Message(MSG_UPDATE);
doc->SetChanged();
EventAdd(); **with no luck.
I have also tried adding Undos :
**
StopAllThreads();
doc->StartUndo();
doc->AddUndo(UNDO_NEW, returnObj);//add an undo for the insertion
doc->EndUndo();**but, no luck.
Is there something that I'm missing?
################Please note, this is only w/ existing objects.
If I Alloc a new object, I am able to parent it with InsertObject / InsertUnder just fine.Thanks for the Help!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2010 at 14:55, xxxxxxxx wrote:
Howdy,
Originally posted by xxxxxxxx
...I am trying to move existing polygon shapes / Null objects to new locations in the scenegraph. After I call
obj- >InsertUnder( parentObj );
the object lives in 2 locations in the scenegraph, it's original location and the new spot....Hmmmm, did you first remove the object from its original location with:
obj->Remove();
... before trying to insert it in the new location?
Adios,
Cactus Dan -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2010 at 15:29, xxxxxxxx wrote:
No, I did not try that.
So, using InsertUnder actually makes a new object?
I see....Thanks for the response - let me try it out.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2010 at 15:40, xxxxxxxx wrote:
That's it, sir. Works like a charm!
I didn't realize that everytime you call an 'Insert' command you build a copy of the object in the document. Interesting...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 15/07/2010 at 15:41, xxxxxxxx wrote:
Howdy,
No. InsertUnder() doesn't make a new object. Using InsertUnder() on an existing object without first removing it with Remove() causes a discrepancy in where the object is really located, and that's probably why Cinema 4D crashed on you.
You must always remove an object first from it's current location in a hierarchy before inserting it into another hierarchy. Using obj->Remove() only removes the object from its current hierarchy, but the object is still in memory.
Adios,
Cactus Dan