THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/08/2012 at 15:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R13
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;
---------
Guys is it possible to insert an object already in the scene hierarchy as a child of another object ?
I tried this and Cinema crashed.
I think this is not possible using the insertObject() method because there can't be 2 instances of the same unique object in two different positions in the same hierarchy.
This is my code (I use with a shorcut) where I had to clone the obj first to avoid crashing:
main(doc,op)
{
var myObj = doc->GetActiveObject(); // Gets the Selected Object
if(!myObj) {
return;
}
var myObjParent = myObj->GetUp(); // Gets the Parent
if(myObjParent) {
if(myObjParent->GetType() == 1007455) { // Is HyperNurbs ?
/*
Snippet to activate/deactivate visibilty on HyperNurbs Object
*/
if (myObjParent#ID_BASEOBJECT_GENERATOR_FLAG == TRUE) { // Active ?
myObjParent#ID_BASEOBJECT_GENERATOR_FLAG = FALSE;
}
else {
myObjParent#ID_BASEOBJECT_GENERATOR_FLAG = TRUE;
}
return;
}
}
// If no parent Hypernurbs Object Found - Create One
CallCommand(1007455); // Create an HyperNurbs Object
var myHPN = doc->GetActiveObject(); // And Select that
if(!myHPN) {
return;
}
var newObj = myObj->GetClone(0);
doc->InsertObject(newObj, myHPN, NULL); // Need an Alternative
doc->SetActiveObject(myObj);
}
Is there any way to access a method that instead of inserting the objects just move that in the hierarchy to avoid cloning ?
And do you guys know the method to delete an object fron the hierarchy, programmatically, not by selecting it and deleting with CallCommand(100004787); // Delete
The script is made to improve workflow in SDS modeling, to get a similar behaviour like in Modo.
Thanks for the attention.
EDIT: I've found how to delete the object (obj->Remove()).
But that is not what I want basically because the behaviour I want to implement will make the tool selected or the selected geometry(Polygon,Edges,Points), remain selected.