AnsweredAssumed Answered

Solidworks PDM API checkout

Question asked by Eero Luotio on Jan 20, 2021
Latest reply on Jan 21, 2021 by Eero Luotio

I'm getting error in checking out and checking in any file. Any idea what am I doing wrong with this CheckOut functions?

Any file that I try to check-in or check-out fails. Error message is something like: "You don't have permission to perform this action."

 

I have enough permissions(Admin) and file is in correct checked in / out state.

 

Imports EPDM.Interop.epdm

 

Public Class Form1
    Dim filename As String = "Filename.SLDPRT"
    Dim VaultName As String = "VAULTNAME"
    Dim vault1 As IEdmVault20 = New EdmVault5()

 


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

 


        LogIn(1)

 

        Dim searchresult As IEdmSearchResult5
        searchresult = Searchfile(filename)

 

        CheckOut(searchresult)
        CheckIn(searchresult)

 

    End Sub


    Function LogIn(autologin As Integer)
        If Not vault1.IsLoggedIn Then
            vault1.LoginAuto(VaultName, Me.Handle.ToInt32())
        End If
        Return 1
    End Function

    Function Searchfile(filename2 As String)
        Dim Search As IEdmSearch8
        Search = vault1.CreateUtility(EdmUtility.EdmUtil_Search)

        Search.FileName = filename
        Dim Result As IEdmSearchResult5
        Dim i As Integer = 0

        Result = Search.GetFirstResult
        Return Result
    End Function
    Function CheckOut(searchresults As IEdmSearchResult5)
        Dim afile As IEdmFile16
        afile = vault1.GetFileFromPath(searchresults.Path)
        afile.LockFile(searchresults.ID, Me.Handle.ToInt32(), CInt(EdmLockFlag.EdmLock_Simple))

 

        Return 1
    End Function

 

    Function CheckIn(searchresults As IEdmSearchResult5)
        Dim afile As IEdmFile16
        afile = vault1.GetFileFromPath(searchresults.Path)
        afile.UnlockFile(searchresults.ID, Me.Handle.ToInt32(), CInt(EdmLockFlag.EdmLock_Simple))
        Return 1
    End Function

End Class

 



Outcomes