Does anyone have any thoughts on this?
I tried setting the read-only file attribute to enabled, checking in the file, checking out the file, and then resetting the read-only attribute back to disabled. This doesn't work because SW and EPDM still consider the file in use when the read-only attribute is enabled, so the file can't be check in or out.
I find it hard to believe that this can't be done, because it's easily possible to do it manually through the user interface. You just save the document in the vault. Right click on the file in the SW tree and choose check in and then either enable to keep checked out flag or check out the file afterwards.
Am I thinking about this all wrong? Is there an easier way to do this. All I want is for a new file to be automatically checked in when it's saved from SW.
There is a Force Release locks call that may help. Look this up in the API help.
value = compModel.ForceReleaseLocks()
AWESOME! Thanks Jeff. I had it working with SetReadOnlyState, but it didn't work nearly as well. I appreciate the help.
Use the API_GB.chm(API Help Booklet for EPDM) in the EPDM folder in program files ****NOT MANY PEOPLE KNOW THIS****. It comes with EPDM automatically just in kind of a weird location. And for what you are trying to do use solidworks SaveAs3 Method(Saves the Drawing), use the vault login then use the EPDM IEdmFile5 Interface and specifically the UnlockFile method(Checks In File). Hope this helps here is a sample of how to do it in C#
using SolidWorks.Interop.sldworks; //Solidworks Reference
using SolidWorks.Interop.swconst; //Solidworks Constant Reference
using EdmLib; //PDM Library
longstatus = swDoc.SaveAs3("File Location and File Name", 0, 4); //4 saves all files references
//Create a file vault interface and log in to a vault.
EdmVault5 vault = default(EdmVault5);
vault = new EdmVault5();
//Get the vault's root folder interface.
IEdmFile5 file = default(IEdmFile5);
IEdmFolder5 folder = default(IEdmFolder5);
folder = vault.RootFolder;
//Check in FIle
file = vault.GetFileFromPath("file location", out folder); //Get File
file.UnlockFile(0, "Checked In By Me", 8, null); //Check In File
file.ChangeState("Check ENG Design", folder.ID, "Created By Me", 0, 0); //Change State
Russell, thanks for the input. Jeff's comment is more what I was looking for though. I had the rest working. I appreciate the help.