THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/02/2003 at 11:48, xxxxxxxx wrote:
That's cool! 
Now, I'm having some difficulty setting a group of existing objects as children of a Null Object. The only thing that I'm succeeding in is crashing C4D.
It doesn't seem to like the InsertUnder() function (at the end of the code section). If this in the incorrect approach to doing this or you find anything else strange, please let me know. Here's the code:
{ ...
// Prepare to create .obj file path
ObjFile_Filename = new(Filename);
ObjFile_Filename->SetFullString(stradd(configuration->GetPath(), token));
println("ObjFile ", ObjFile_Filename->GetFullString());
// Load .obj file into Cinema4D (New Document)
if(!LoadDocument(ObjFile_Filename))
{
errdlgType = ERRDLG_NOREADFILE;
errdlgText = ObjFile_Filename->GetFullString();
var d = new(Error_GeModalDialog);
d->Open(-1,-1);
return FALSE;
}
baseDocument = GetActiveDocument();
// Create a list array of objects loaded
var object = baseDocument->GetFirstObject();
if (object == NULL)
{
errdlgType = ERRDLG_NOOBJECTS;
errdlgText = ObjFile_Filename->GetFullString();
var d = new(Error_GeModalDialog);
d->Open(-1,-1);
return FALSE;
}
var objectArray;
var numObjects;
var i;
// Count number of objects
for (numObjects = 0; object != NULL; numObjects++) object = object->GetNext();
println("NumObjects = ", numObjects);
objectArray = new(array, numObjects);
// Insert objects into array
objectArray[0] = baseDocument->GetFirstObject();
for(i = 1; i < numObjects; i++) objectArray[i] = (objectArray[i-1])->GetNext();
// Ask user how to handle object
var d = new(ObjectSettings_GeModalDialog);
d->Open(-1,-1);
if (d->GetResult())
{
// Perform object modification
if (d->GROUP == d->GetSet())
{
objectSet = d->GROUP;
// Insert a Null Object into Document
mainObject = new(NullObject);
baseDocument->InsertObject(mainObject, NULL, NULL);
GeEventAdd(DOCUMENT_CHANGED);
// Set NullObject name if user gave one
if (d->GetSetname()) mainObject->SetName(d->GetName());
// Set all other objects as children of mainObject
for (i = 0; i < numObjects; i++)
{
(objectArray[i])->InsertUnder(mainObject);
GeEventAdd(DOCUMENT_CHANGED);
}
}
...}