THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/02/2011 at 10:48, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10+
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
---------
Howdy,
Is there a bug or something in the MCOMMAND_JOIN modeling command?
It seems that if I try to connect 2 object with MCOMMAND_JOIN it fails if the 2 objects have different parent objects. So I tried creating a temporary document and copying the object to be joined into that document each one on the root level, then using the command on the temporary document, and bring the result back into the active document. The join failed. The resulting mesh is only one of the selected meshes.
Here's my test code:
Bool CDTestCommand::Execute(BaseDocument *doc)
{
StopAllThreads(); // so the document can be safely modified
AutoAlloc<AtomArray> objects; if (!objects) return FALSE;
doc->GetActiveObjects(objects,FALSE);
// temporary storage
AutoAlloc<AtomArray> joinOps; if (!joinOps) return FALSE;
AutoAlloc<BaseDocument> tempDoc; if(!tempDoc) return FALSE;
LONG i, oCnt = objects->GetCount();
if(oCnt > 1)
{
for(i=0; i<oCnt; i++)
{
BaseObject *mrg = static_cast<BaseObject*>(objects->GetIndex(i));
if(mrg)
{
BaseObject *cln = (BaseObject* )mrg->GetClone(COPY_NO_HIERARCHY|COPY_NO_ANIMATION,NULL);
if(cln)
{
tempDoc->InsertObject(cln,NULL,NULL);
cln->SetMg(mrg->GetMg());
joinOps->Append(cln);
}
else GePrint("GetClone() failed");
}
else GePrint("merge object "+LongToString(i)+" = NULL");
}
doc->StartUndo();
ModelingCommandData mcd;
mcd.doc = tempDoc;
mcd.arr = joinOps;
if(SendModelingCommand(MCOMMAND_JOIN, mcd))
{
BaseObject *newOp = static_cast<BaseObject*>(mcd.result->GetIndex(0));
if(newOp)
{
doc->StartUndo();
doc->InsertObject(newOp,NULL,NULL);
newOp->SetName("Joined Objects");
doc->AddUndo(UNDO_NEW,newOp);
newOp->SetMg(Matrix());
doc->SetActiveObject(newOp);
doc->EndUndo();
}
}
EventAdd(EVENT_FORCEREDRAW);
}
return TRUE;
}
Is something wrong with my code?
Adios,
Cactus Dan