Here is something to start with. It writes the model paths which have missing flat patterns to a .txt file in the same location and with the same name as the Assembly you're running this code from. It also creates the flat patterns if they don't exist.
Dim oCompDef As SheetMetalComponentDefinition
Dim ErrorList As New ArrayList
ErrorCount = 0
'name TXT file by this assembly name and path
oFile = ThisDoc.PathAndFileName(False) & " - Checking for flat patterns" & ".txt"
'clear TXT file
System.IO.File.WriteAllText(oFile, "")
For Each oDoc As Document In ThisApplication.ActiveDocument.AllReferencedDocuments
Dim oExists As Boolean = True
If oDoc.IsModifiable = False Then Continue For
If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
oCompDef = oDoc.ComponentDefinition
If oCompDef.SurfaceBodies.Count = 0 Then Continue For
If oCompDef.HasFlatPattern = True Then Continue For
If oCompDef.HasFlatPattern = False Then ThisApplication.Documents.Open(oDoc.FullFileName, True)
oExists = False
Try
oCompDef.Unfold
oCompDef.FlatPattern.ExitEdit
oDoc.Save
Catch
ErrorList.Add(oDoc.DisplayName)
ErrorCount += 1
Finally
oDoc.Close(True)
End Try
End If
'Open And append To an existing Text file
Dim oAppend As System.IO.StreamWriter
oAppend = IO.File.AppendText(oFile)
If oExists = False Then
oAppend.WriteLine(oDoc.FullDocumentName)
oOpenTxtFile = True
End If
oAppend.Flush()
oAppend.Close()
Next
If oOpenTxtFile = True Then
MessageBox.Show("Opening Text File With Details", "You Have Some Missing Flat Patterns")
ThisDoc.Launch(oFile)
Else
MessageBox.Show("All components have flat patterns", "Great!")
End If
If ErrorCount > 0 Then
oWrite = System.IO.File.CreateText(ThisDoc.PathAndFileName(False) + " Flat Pattern Errors.txt")
oWrite.WriteLine(iProperties.Value("Project", "Part Number") + " Flat Pattern Errors")
oWrite.WriteLine()
For Each i In ErrorList
oWrite.WriteLine(i)
Next
oWrite.Close
Process.Start("notepad.exe", ThisDoc.PathAndFileName(False) + " Flat Pattern Errors.txt")
End If
'MessageBox.Show("All Flat Patterns Completed", "Flat Pattern Extractor", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)