我試圖通過Api在SolidWorks ePDM中的兩個文件之間添加和刪除引用。這是我如何在c#中根據幫助中的示例執行操作。你能告訴我我做錯了什麼嗎?Solidworks PDM API更新引用錯誤
using EPDM.Interop.epdm;
using EPDM.Interop.EPDMResultCode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Service.EPDM.Data.Test
{
[TestClass]
public class Class1
{
private EdmVault5 _Vault1 = null;
private IEdmVault15 _Vault2 = null;
[TestMethod]
public void Run()
{
try
{
_Vault1 = new EdmVault5();
_Vault1.LoginAuto("MyVault", 32);
_Vault2 = (IEdmVault15)_Vault1;
var file1 = "99-Test\\OFTEST1\\test1.lnk.cvd";
var file2 = "99-Test\\OFTEST1\\test2.lnk.cvd";
UpdateReferences(file1, new List<string>() { file2 }, null);
}
catch (Exception ex)
{
throw ex;
}
}
private void UpdateReferences(string iFilePath, List<string> iAddReferenceFilePath, List<string> iRemoveReferenceFilePath)
{
if (iAddReferenceFilePath != null && iRemoveReferenceFilePath != null)
throw new Exception("La liste des références à créer et supprimer est vide");
var rootPath = _Vault2.RootFolderPath;
IEdmFolder5 ppoRetParentFolder;
var theFile = _Vault2.GetFileFromPath(rootPath + "\\" + iFilePath, out ppoRetParentFolder);
var itemFile = (IEdmItem)theFile;
EdmItemRef[] addRefs = null;
addRefs = new EdmItemRef[iAddReferenceFilePath.Count];
int addCounter = 0;
foreach (var item in iAddReferenceFilePath)
{
IEdmFolder5 folder = null;
var file = _Vault2.GetFileFromPath(rootPath + "\\" + item, out folder);
addRefs[addCounter].moNamePathOrID = rootPath + "\\" + item;
addRefs[addCounter].mlEdmRefFlags = (int)EdmRefFlags.EdmRef_Static + (int)EdmRefFlags.EdmRef_File;
addRefs[addCounter].moParentNamePathOrItemID = itemFile.ID;
addCounter++;
}
EdmItemRef[] removeRefs = null;
removeRefs = null;
itemFile.UpdateReferences(addRefs, removeRefs);
}
}
}
而這是itemFile.UpdateReferences(addRefs, removeRefs)
方法的錯誤。
「不正確的參數,HRESULT:80070057(E_INVALIDARG)」