ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
EKEthan Kinney20/06/2014

Hi All,

I was having trouble trying to do a batchget in EPDM to get the latest version of all files in a directory and I finally figured it out.

Here is the code I was using:

Try

            Dim Vault As New EdmVault5

            Vault.LoginAuto("Engineering", 0)

            Dim SubFolder As String = Vault.RootFolderPath & "\DirectoryToRefresh"

 

            Dim GetDirectory() As EdmSelItem = Nothing

            ReDim GetDirectory(0)

            GetDirectory(0).mlDocID = 0

            GetDirectory(0).mlProjID = Vault.GetFolderFromPath(SubFolder).ID

 

            Dim bg As IEdmBatchGet

            bg = Vault.CreateUtility(EdmUtility.EdmUtil_BatchGet)

            bg.AddSelection(Vault, GetDirectory)

            bg.CreateTree(0, EdmGetCmdFlags.Egcf_Nothing)

            bg.GetFiles(0, Nothing)

 

        Catch ex As Runtime.InteropServices.COMException

            MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + vbCrLf + ex.Message)

        Catch ex As Exception

            MessageBox.Show(ex.Message)

        End Try

For the longest time i was getting an "E_INVALIDARG" on the line "bg.AddSelection".

Finally I stumbled accross this page in the API Help Documentation:

http://help.solidworks.com/2014/English/api/epdmapi/Using_NET_Framework_in_Applications.htm

If you are developing in Visual Studio like I was and have a reference set to interop.edmLib you have to do the following:

Go to "My Project" > "References" > Click on PDMWorks Enterprise 20xx Type Library > and set the "Embed Interop Types" to False

Note: This is vaild if you are programming in 4.0 or 4.5! (I was programming in 4.5)

After I changed this value, then bingo, worked like a charm.

Hopefully this will help someone else out!

Cheers,

Ethan