@Danchyg1337 said in SendModelingCommand() in R20 and R21:
mcd.flags = MODELINGCOMMANDFLAGS::CREATEUNDO;
sorry I overlooked the issue, the main problem here is that you pass mcd.flags = MODELINGCOMMANDFLAGS::CREATEUNDO;
And creating an undo step in a threading environment (aka during the scene execution) is not allowed, so you should pass MODELINGCOMMANDFLAGS::NONE;
Now regarding your question, since I think he can still be valid one because of some modeling operator explicitly operate on the current object but also need a document (like CurrentStateToObject) here a very naive approach that may not work in all condition (e.g. no aliastrans, so link may be lost)
AutoAlloc<BaseDocument> basedocBuffer;
BaseObject* clonedOp = (BaseObject*)op->GetClone(COPYFLAGS::NONE, nullptr);
basedocBuffer->InsertObject(clonedOp, nullptr, nullptr);
basedocBuffer->ExecutePasses(thread, true, true, true, BUILDFLAGS::INTERNALRENDERER);
ModelingCommandData mcd;
BaseContainer bc;
bc.SetData(MDATA_DISCONNECT_PRESERVEGROUPS, false);
mcd.doc = basedocBuffer;
mcd.op = clonedOp;
mcd.mode = MODELINGCOMMANDMODE::POLYGONSELECTION;
mcd.flags = MODELINGCOMMANDFLAGS::NONE;
mcd.bc = &bc;
if (!SendModelingCommand(MCOMMAND_DISCONNECT, mcd))
ApplicationOutput("Disconnect error.");
clonedOp->CopyTo(op, COPYFLAGS::NONE, nullptr);
clonedOp->CopyMatrixTo(op);
clonedOp->CopyTagsTo(op, NOTOK, NOTOK, NOTOK, nullptr);
And why it was worked previously? I would say it didn't properly, but the CriticalStop wasn't there internally, so we simply returned without knowing there is an issue.
Hope it helps,
Cheers,
Maxime.