This one is highly geeky...
Based on this statement found in EPDM 2010 Programmer's Reference Guide:
"An item is basically a file without the file. i.e. all the meta data but without any physical bits and bytes on the archive server. Most of the existing API's that work for files have therefore been adjusted so they also work for items. Only a few new item-specific interfaces had to be created."
Following this statement, I built the following code to check out an item but it was always failing at the LockFile...
Dim epdmVault As IEdmVault7 = New EdmVault5
Dim pdmFile As IEdmFile6
Dim parentFolder As IEdmFolder5
epdmVault.LoginAuto("VAULT", Me.Handle.ToInt32)
parentFolder = epdmVault.GetFolderFromPath("C:\VAULT\
pdmFile = parentFolder.GetFile("ITEMNAME.
pdmFile.LockFile(parentFolder.ID, Me.Handle.ToInt32, EdmLockFlag.EdmLock_Simple)
One might ask why is it failling using the regular file calls?
With the help of apisupport@solidworks.com two solutions were found.
Solution 1:
Add the following code before the LockFile call to retrieve the item's interface:
Dim pdmItem As IEdmItem
pdmItem = epdmVault.GetObject(EdmObjectType.EdmObject_Item, pdmFile.ID)
Change the LockFile call to:
pdmItem.LockFile(parentFolder.ID, Me.Handle.ToInt32, EdmLockFlag.EdmLock_Simple)
Solution 2:
Replace the GetFolderFromPath and GetFile with:
pdmFile = epdmVault.GetFileFromPath("C:\VAULT\
Add the following code:
Dim pdmItem As IEdmItem
pdmItem = pdmFile
Change the LockFile call to:
pdmItem.LockFile(parentFolder.ID, Me.Handle.ToInt32, EdmLockFlag.EdmLock_Simple)
Why is it working now? Let's look at which type of object each call returns.
GetFolderFromPath returns parentFolder as EdmObject_Folder {2}
GetFile returns pdmFile as EdmObject_File {1}
The original LockFile call was using regular folder and file objects to check out an item...
Solution 1:
Using the GetObject call on pdmFile.ID provides the appropriate object type for the LockFile.
Solution 2:
GetFileFromPath returns parentFolder as EdmObject_ItemRootFolder {18}
GetFileFromPath returns pdmFile as EdmObject_Item {16}
The objects are directly set to the proper type and can directly be used with LockFileon the item.
Complete snippets:
Solution 1:
Dim epdmVault As IEdmVault7 = New EdmVault5
Dim pdmFile As IEdmFile6
Dim parentFolder As IEdmFolder5
epdmVault.LoginAuto("VAULT", Me.Handle.ToInt32)
parentFolder = epdmVault.GetFolderFromPath("C:\VAULT\
pdmFile = parentFolder.GetFile("ITEMNAME.
Dim pdmItem As IEdmItem
pdmItem = epdmVault.GetObject(EdmObjectType.EdmObject_Item, pdmFile.ID)
pdmItem.LockFile(parentFolder.ID, Me.Handle.ToInt32, EdmLockFlag.EdmLock_Simple)
Solution 2:
Dim epdmVault As IEdmVault7 = New EdmVault5
Dim pdmFile As IEdmFile6
Dim parentFolder As IEdmFolder5
epdmVault.LoginAuto("VAULT", Me.Handle.ToInt32)
pdmFile = epdmVault.GetFileFromPath("C:\VAULT\
Dim pdmItem As IEdmItem
pdmItem = pdmFile
pdmItem.LockFile(parentFolder.ID, Me.Handle.ToInt32, EdmLockFlag.EdmLock_Simple)
Have fun!
-Sylvain
SolidworksSolidworks Pdm enterprise Pdm