Hi, everybody!
I have an issue to unlock new added file
var vault1 = new EdmVault5();
vault1.LoginAuto(“PDM”, 0);
string ProductFile = ProductFolderName + “.SLDASM”;
IEdmFolder6 folderObj = (IEdmFolder6)vault1.GetFolderFromPath(ModelFolder.LocalPath);
folderObj.AddFile(0, TemplatePath, ProductFile, (int)EdmAddFlag.EdmAdd_Simple);
folderObj.Refresh();
IEdmFile5 ModelFile = folderObj.GetFile(ProductFile);
if (ModelFile != null)
if (ModelFile.IsLocked)
{
ModelFile.UnlockFile(0, “Auto imported.”);
}
The new file adding successfully, but when i’m trying to unlock file PDM return error HRESULT = 0x80040229 The file format is not recognized
The file is normal, i can it open in Solidworks and Unlock manual
I was able to reproduce this issue. To solve this, you will need to edit your project properties in visual studio and make sure that “Prefer 32-bit” is un-checked on the “Build” tab.
While you’re at it, make sure that the “Embed Interop Types” for your PDM .dll files are set to False
A tip with the code, AddFile
provides the new file ID when it finishes. You can then use this to obtain a reference to the file rather than having to keep track of the name.
var vault = new EdmVault5() as IEdmVault21;
if(!vault.IsLoggedIn)
{
vault.LoginAuto(vaultName, 0);
}
var pdmFolder = vault.GetFolderFromPath(destinationFolderPath);
var newFileId = pdmFolder.AddFile(0, sourceFilePath, "AddedFileName.sldprt", (int)EdmAddFlag.EdmAdd_Simple);
var addedModel = vault.GetObject(EdmObjectType.EdmObject_File, newFileId) as IEdmFile17;
if(addedModel != null)
{
if(addedModel.IsLocked)
{
addedModel.UnlockFile(0, "Automatically Checked In", (int)EdmUnlockFlag.EdmUnlock_Simple);
}
}
Hello!
check if ModelFile is nothing before ModelFile.UnlockFile()
adding of new files can take some time…
if file is nothing, insert Threading.Thread.Sleep(25000) before “.getfile”