I have a solidwork add-in which is reading and writing 3rd party data into the files with the help of IModelDoc2::IGet3rdPartyStorage and ModelDoc.Save3 methods.
Everything is working fine but the users who are also using Solidworks PDM, getting the error while writing with save3.
I know it is possible to lock and unlock file with the EPDM.Interop.epdm library but when I tried to lock (check out) file which is checked In by PDM, I am getting following error.
- {"An attempt was made to access a file that is exclusively opened by another application."}
I know, I am getting the correct errors as I am trying to accessing files as a 3rd party and my add-in is not a PDM add-in.
Is it possible to lock file with normal Solidworks API or Document Manager API ?

Lock and unlock are PDM features and only available in PDM API. Check this article, it should solve your problem: Check-out active SOLIDWORKS model using SOLIDWORKS and PDM API
If this is an assembly you need to release lock for all components as well.
While try to check out files in SW use API ,I found that reloadOrreplace could excute success when FileAttributes is Normal.
so ,I added code which to set FileAttributes from read only to Normal when checked out
After that ,I can edit and check in file normally.
e.g.
string _filepath = kvp.Value;
if(File.Exists(_filepath))
{
File.SetAttributes(_filepath, FileAttributes.Normal);
}
I have met this problem too,When I check out file with merhod IEdmBatchGet batchGetter and set the CreateTree Method (IEdmBatchGet) lEdmGetCmdFlags value is 256(Mark:Egcf_SkipOpenFileChecks 256 = Skips checking whether the file is open in another application)
but the assembly still readonly after excute code (check out and reloadorreplace) .
Is there a method to check out files similar to check out using PDM add-in.
... it seems that he absolutely does not want to use the PDM API ...
1. You have to get the file
2. You have to check-out the file
3. You can edit the file
4. You have to check-in the file
If you don't do this in that order, you can do whatever you want, but the file won't keep the changes.
Thanks for this reference: Check-out active SOLIDWORKS model using SOLIDWORKS and PDM API
I have tried the following code but getting https://www.screencast.com/t/34GyKnqVOR
ModelDoc.ForceReleaseLocks();
var isVisible = SourceComponent.Document.IsVisibleInSOLIDWORKS();
if (ModelDoc.Visible)
{
ModelDoc.ReloadOrReplace(false, ModelDoc.LocalPath, true);
}
After performing above steps, once I tried to check
readOnly = ModelDoc.IsOpenedReadOnly();
It is still read only and I am not able to write anything with ModelDoc.Save3 because of write access.