Hi, everyone
in my scenarion the automatic save (MS_DGNAUTOSAVE) is deactivated. Now I'm activating a reference, change it and deactivate it. The reference has now pending changes. If I close MicroStation I get the question if I would save the change to the reference, undo the change or cancel the closing process. I want to code the same question for my own functions but don't know how. I thought it could go like this: (Code simplified)
mdlModelRefIterator_create(&mrIterator, modelP, MRITERATE_Root | MRITERATE_PrimaryChildRefs, 0); while (NULL != (modelP = mdlModelRefIterator_getNext(mrIterator))) { DgnFileP pRefFile = NULL; pRefFile = mdlModelRef_getDgnFile(modelP); if (pRefFile && TRUE == mdlDgnFileObj_hasPendingChanges(pRefFile)) { if (Save) { iRet = mdlWorkDgn_saveChanges(modelP); } else { iRet = mdlWorkDgn_discardFile(modelP); } } } mdlModelRefIterator_free(&mrIterator);
mdlWorkDgn_saveChanges works fine but mdlWorkDgn_discardFile does not. I tried to reload the changed reference but then MicroStation comes in with the same question again (Save/Undo/Cancel). Do I have to call another function after discardFile?
ThanksMarcel
Marcel Pradel said:mdlWorkDgn_saveChanges works fine but mdlWorkDgn_discardFile does not
Check the return value iRet. I'm surprised either of those functions works, because the reference model has not been opened as a work DGN.
iRet
Regards, Jon Summers LA Solutions
Hi Marcel,
is there any reason to use "old mdlXYZ_" functions in C++ API, available in MicroStation CE?
I agree with Jon the code is weird, because you mix model reference and work DGN. Even though technically they both work with DGN and models, they target different scenarios and situations.
I would prefer to use objects like DgnAttachment (together with DgnAttachmentArray) and first of all DgnFile, allowing to query file state like whether there are pending changes etc.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jon,
both functions return 0. So I guess they mean SUCCESS.
Kind regardsMarcel
Hi Jan,
I use them because they are available an the mdlWorkDgn functions take DgnModelRefP as arguments. I get them from mdlModelRefIterator functions.But I will check your suggestion with DgnFile/DgnAttachment as well.
Just changed my weird code to:
DgnModelRefR model = *ISessionMgr::GetActiveDgnModelP(); if (NULL != model.GetDgnAttachmentsP()) { for each (DgnAttachmentP attachment in *model.GetDgnAttachmentsP()) { bool bChanged = attachment->GetDgnFileP()->HasPendingChanges(); if (bChanged) { //how to undo changes? } } }
But now I don`t know how to undo the changes. I only could find the function mdlWorkDgn_discardFile. Is there an other way to do it?
Marcel Pradel said:But now I don`t know how to undo the changes
I am not sure, but maybe to call SetAbandonChangesFlag() may help? After that, to call ProcessChanges() makes sense, not sure whether you should care about closing the file (it depends on context, but I guess it's MicroStation responsibility).
But it depends whether the changes were saved already or not ... which I guess not, as you wrote the continuous saving is switched off.
Regards,