protected override void DoAction() { foreach (ModelDoc2 doc in SolidWorksWrapper.GetOpenDocuments()) { if (SaveChanges) { const int options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent | (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced; int errs = 0, warnings = 0; bool saved = doc.Save3(options, ref errs, ref warnings); if (!saved || errs != 0) { throw new SolidWorksActionException(this); } } if (doc.GetSaveFlag()) { AskEventEnums.DialogResult result = Ask(string.Format("Closing {0} without saving changes.", SolidWorksDoc.GetPathName()), "Closing document", AskEventEnums.AskType.OKCancel); if (result == AskEventEnums.DialogResult.Cancel) { return; } } SolidWorksDoc.Quit(); } }
protected override void DoAction() { Message("Closing file: \"" + SolidWorksDoc.GetTitle() + "\""); if (SaveChanges) { const int options = (int)swSaveAsOptions_e.swSaveAsOptions_Silent | (int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced; int errs = 0, warnings = 0; bool saved = SolidWorksDoc.Save3(options, ref errs, ref warnings); if (!saved || errs != 0) { throw new SolidWorksActionException(this); } } if (SolidWorksDoc.GetSaveFlag()) { AskEventEnums.DialogResult result = Ask(string.Format("Closing {0} without saving changes.", SolidWorksDoc.GetPathName()), "Closing document", AskEventEnums.AskType.OKCancel); if (result == AskEventEnums.DialogResult.Cancel) { return; } } SolidWorksDoc.Quit(); SolidWorksDoc = null; }