0 Replies Latest reply on Jan 30, 2017 10:10 AM by Isaac Ross

    ISWDmDocument13::GetAllExternalReferences4 - brokenRefVar statuses always swDmReferenceStatusNotBroken?

    Isaac Ross

      I'm using the SolidWorks Document Manager 2017 API to check drawings for broken external references, and I think I'm either misunderstanding something or have encountered a bug. Even when I permanently delete a part referenced in a drawing, I'm still getting swDmReferenceStatusNotBroken. Here's some example code from a small test project (just create a new VB Windows Forms project in VS2015, add a reference to SwDocumentMgr, and add a button to the form if you want to try to reproduce this):

      Imports SwDocumentMgr
      
      
      Public Class Form1
          Dim licenseKey As String = "your_license_key"
          Dim dmClassFact As New SwDMClassFactory
          Dim dmDocMgr As SwDMApplication4 = dmClassFact.GetApplication(licenseKey)
          Dim searchOption As SwDMSearchOption = dmDocMgr.GetSearchOptionObject()
      
      
          Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
              Dim fbrowser As New OpenFileDialog
              If fbrowser.ShowDialog = DialogResult.OK Then
                  checkSlddrwXref(fbrowser.FileName)
                  MessageBox.Show("Finished checking references", fbrowser.FileName)
              End If
          End Sub
      
      
          Private Sub checkSlddrwXref(fileName As String)
              Dim brokenrefs() As SwDmReferenceStatus = Nothing
              Dim isVirtual() As Boolean = Nothing
              Dim timeStamps() As Integer = Nothing
      
      
              Dim status As SwDmDocumentOpenError
      
      
              Dim doc As SwDMDocument18 = dmDocMgr.GetDocument(fileName, SwDmDocumentType.swDmDocumentDrawing, True, status)
      
      
              If Not (doc Is Nothing) Then
                  Dim refs As String() = doc.GetAllExternalReferences4(searchOption, brokenrefs, isVirtual, timeStamps)
      
      
                  For i As Integer = 0 To UBound(brokenrefs)
                      Dim msg As String = "Path: " & refs(i) & Environment.NewLine
                      Select Case brokenrefs(i)
                          Case SwDmReferenceStatus.swDmReferenceStatusBroken
                              msg &= "Reference status: swDmReferenceStatusBroken" & Environment.NewLine
                          Case SwDmReferenceStatus.swDmReferenceStatusNotBroken
                              msg &= "Reference status: swDmReferenceStatusNotBroken" & Environment.NewLine
                          Case SwDmReferenceStatus.swDmReferenceStatusUnknown
                              msg &= "Reference status: swDmReferenceStatusUnknown" & Environment.NewLine
                      End Select
      
      
                      msg &= "File exists: " & New IO.FileInfo(refs(i)).Exists.ToString
      
      
                      MessageBox.Show(msg, fileName)
                  Next
              End If
      
      
              doc.CloseDoc()
          End Sub
      End Class
      

      As I said before, even when I intentionally delete a referenced part, it always returns not broken; despite the fact that SolidWorks, SolidWorks Explorer, and eDrawings all show that the references are broken. Is this a bug, or am I simply misunderstanding how this is supposed to behave?

       

      Thanks for your help.