6 Replies Latest reply on Aug 9, 2018 3:23 AM by Jerome De San Nicolás

    2097154 Error when opening a file using swApp.OpenDoc6 - API

    Eric Snyder

      This error number does not seem to be documented. What is it?

        • Re: 2097154 Error when opening a file using swApp.OpenDoc6 - API
          Danniel Sims



          I'm guessing based on your previous question: Getting 2097152 error when loading file using swapp.OpenDoc6

          Are you trying to use the same code from the previous question to open a part or drawing file?

          The document type has to be specified before executing the line and it has to match the type it is expecting.


          2017 SOLIDWORKS API Help - swDocumentTypes_e Enumeration


          When I use this code I usually try to capture the extension and use a if/then to output the correct document type into the string.


          More info or code would help, but maybe gets you in the right direction.

          • Re: 2097154 Error when opening a file using swApp.OpenDoc6 - API
            Eric Snyder

            Thanks for the Answers/Questions.


            No, this is not related to my previous post about error number 2097154. I am past that thanks to your help. I have been successfully loading files in Solidworks for a while now using OpenDoc6 in another context.


            I am using Document Manager to iterate through a large number of documents and fix missing references. When I load some files (200 out of 20,000) and try to get the array of configurations I am getting and XML error. See this post for details. I am trying to automate the repair of the files when that error happens since I have hundreds of files to repair. That is when I am having the issue.


            When I get the XML error I run LoadAndFixFile().


            My VB.NET code looks like this:

                Sub LoadAndFixFile()

                    Dim errors As swFileLoadError_e

                    Dim warnings As swFileLoadWarning_e

                    Dim swModel As ModelDoc2

                    swModel = swApp.OpenDoc6(FileData.Path, GetFileType(FileData.DocumentType), swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)

                    If errors = 0 Then

                        swModel.Save3(1, errors, warnings)


                        swModel = Nothing

                    End If

                End Sub


                Function GetFileType(swdmdoctype As SwDmDocumentType) As swDocumentTypes_e

                    Select Case swdmdoctype

                        Case SwDmDocumentType.swDmDocumentAssembly

                            Return swDocumentTypes_e.swDocASSEMBLY

                        Case SwDmDocumentType.swDmDocumentPart

                            Return swDocumentTypes_e.swDocPART

                        Case Else

                            Return swDocumentTypes_e.swDocNONE

                    End Select

                End Function


            I am currently just trying to understand what the error number 2097154 is since it is not documented in the 2018 API help for swFileLoadError_e Enumeration. I am thinking if I knew what that error meant then I'd have a better chance of figuring what the issue is.

            • Re: 2097154 Error when opening a file using swApp.OpenDoc6 - API
              Eric Snyder

              This is weird. I found the issue. I was using a mapped network resource path rather than the actual network resource path.

              Did not work:



              \\Network share\SolidworksFile.sldprt

              Also, it looks like all the files that had the XML error issue were part files that have an Imported solid in them.