Solved Creating object in CommandData does not update Object Manager

I'm on 2023.2.2 in C++.

My CommandData plugin creates a cube and inserts it into the document yet the object manager does not show the cube until I select it in the viewport.

Code:

Bool MyCommand::Execute(BaseDocument* doc, GeDialog* parentManager)
{
    auto cube = BaseObject::Alloc(Ocube);
    doc->InsertObject(cube, nullptr, nullptr, false);
    EventAdd();

    return true;
}

I was hoping the call to EventAdd would fix that but it doesn't.

2f99c27d-370f-41e6-b8b2-8c3262635047-Cinema_4D_4a6urI6jaQ.gif

What does work however is making the cube the active object after inserting it.

Bool MyCommand::Execute(BaseDocument* doc, GeDialog* parentManager)
{
    auto cube = BaseObject::Alloc(Ocube);
    doc->InsertObject(cube, nullptr, nullptr, false);
    doc->SetActiveObject(cube);

    return true;
}

Note how apparently I don't even need to call EventAdd anymore.

fd0ba8b8-fb13-484f-8dfd-6b0bcd3b468c-Cinema_4D_WErbfmttGk.gif

Then again if I want to support undo I do need EventAdd again or the object manager won't update anymore.

Bool MyCommand::Execute(BaseDocument* doc, GeDialog* parentManager)
{
    auto cube = BaseObject::Alloc(Ocube);
    doc->StartUndo();
    doc->InsertObject(cube, nullptr, nullptr, false);
    doc->AddUndo(UNDOTYPE::NEWOBJ, cube);
    doc->EndUndo();

    doc->SetActiveObject(cube);
    EventAdd();

    return true;
}

My question is: Why does the first code not update the object manager?

Hi sadly this is a known issue, see EventAdd is not working.

Cheers,
Maxime.

Hi sadly this is a known issue, see EventAdd is not working.

Cheers,
Maxime.