Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objSESP As SolidEdgeFramework.SolidEdgeInsightXT = Nothing 'Note the existence of the InsightXT nonenclature
Dim objSEApp As SolidEdgeFramework.Application = Nothing
'hook up the to SESP automation object
objSEApp = GetObject(, "SolidEdge.Application")
objSESP = objSEApp.SolidEdgeInsightXT
'are we currenlty in SESP manged mode or not?
Dim blnSESPMode As Boolean = False
objSESP.GetInsightXTMode(blnSESPMode)
Try
If blnSESPMode = True Then
Dim strPartNumber As String = "PRT-00581"
Dim strRevisionNumber As String = "A"
Dim blnFileExists As Boolean = False
Dim ListOfFileNamesInPartRevision As Object = Nothing
Dim ListOfLinkedFileNames(0 To 1) As Object
Dim intnumberofFiles As Integer = 0
Dim dwDownloadOption As Integer = 0
Dim bstrItemContentType As String
Dim bstrItemRevContentType As String
Dim bstrItemId As String = String.Empty
Dim bstrItemRev As String = String.Empty
objSESP.DoesInsightXTFileExists(strPartNumber, strRevisionNumber, blnFileExists)
If blnFileExists = True Then
objSESP.GetListOfFilesFromInsightXTServer(strPartNumber, strRevisionNumber, ListOfFileNamesInPartRevision, intnumberofFiles)
If intnumberofFiles > 0 Then
'loop through the array to fine the SE document help in the part revision
Dim ii As Integer = 0
For ii = 1 To intnumberofFiles
Dim strFilename As String = ListOfFileNamesInPartRevision(ii - 1)
If oIsSolidEdgeAssemblylFile(strFilename) = True Then
objSESP.DownladDocumentsFromServerWithOptions(strPartNumber, strRevisionNumber, strFilename, "Latest", "", True, True, dwDownloadOption, ListOfLinkedFileNames)
'now open the file from the cache folder
Dim strCachePath As String = String.Empty
objSESP.GetPDMCachePath(strCachePath)
objSEApp.Documents.Open(strCachePath + "\" + ListOfFileNamesInPartRevision(ii - 1))
bstrItemContentType = "Part"
bstrItemRevContentType = "Part-Revision"
objSESP.SESP_GetItemAndRevisionNo(bstrItemContentType, bstrItemRevContentType, bstrItemId, bstrItemRev)
Exit For
End If
Next ii
Do While objSEApp.Documents.Count <> 0
objSEApp.ActiveDocument.save()
objSEApp.ActiveDocument.close() 'close checks in the document.... if option is set!
Loop
End If
End If
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class