0 Replies Latest reply on Mar 31, 2018 12:28 PM by bob chen

    Get swGenericSaveError randomly during batch iges conversion

    bob chen

      I try to batch save prts as iges in EPDM while some of them get swGenericSaveError randomly. I already active prt by  ActivateDoc3 method before save them to EPDM destination folder.

      My code also including function to get iges object(if found, check out so that I could overwrite it) or check if iges file exist (haven't add to EPDM, e.g local cache,delete local cache so that iges could add normally) before execute save as operation.

       

      I am wondering how this error will occur randomly and how to troubleshooting this issue? (I am confirm that none  iges file object or local cache found when this error occur)If run program second time after error occur it could finished successfully.

       

      There is part of my code below, pls help to check and give me some suggestion.

       

       

      swApp.ActivateDoc3(filePath, true, (int)swRebuildOnActivation_e.swRebuildActiveDoc, errors);

      ...

      IModelDocExtension swExtension = swModel.Extension;

      //Refresh destination folder

      IEdmFolder5 destFolder5 = vault.GetFolderFromPath(outPutPath);

      destFolder5.Refresh();

       

      //check if iges file object exist

      IEdmFile5 oldConvertFile = vault.GetFileFromPath($@"{outPutPath}\{outPutDocumentName}", out IEdmFolder5 oldPdfFileFld);

       

      //if get igs object, try to check out it so that new ige could overwrite it

      if (oldConvertFile != null)

        {

                   if (!oldConvertFile.IsLocked)

                    {

                             oldConvertFile.LockFile(oldPdfFileFld.ID, 0);

                    }

           

         }

      //if igs local cache exist, try to delete it

      else if (File.Exists($@"{outPutPath}\{outPutDocumentName}"))

        {

                   File.Delete($@"{outPutPath}\{outPutDocumentName}");

        }

       

      var swConfMgr = swModel.ConfigurationManager;

      var vConfName = swConfMgr.ActiveConfiguration.Name;

      swModel.ShowConfiguration(vConfName);

      swModel.ClearSelection2(true);

       

      swApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swIGESComponentsIntoOneFile, true);

      swApp.SetUserPreferenceIntegerValue((int)swUserPreferenceIntegerValue_e.swIGESSystem, (int)swIGESPreferredSystem_e.swIGES_STANDARD);

                     

      //Save failed?

      var isSave =  iswExtension.SaveAs($@"{outPutPath}\{outPutDocumentName}", (int)swSaveAsVersion_e.swSaveAsCurrentVersion,

                              (int)swSaveAsOptions_e.swSaveAsOptions_Silent, "", ref convertErrors, ref warnings)