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.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.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.