PDM User-defined File References

Programming and macros
MMartens
Posts: 36
Joined: Wed Apr 28, 2021 10:01 am
Answers: 6
Location: Shawano, WI USA
x 6

PDM User-defined File References

Unread post by MMartens »

I am writing a process for my add-in that will automatically create a user-defined file reference during the check in process. My code creates the references just fine. I know because I see the references when I click the "Custom References" button on the Contains tab.

The issue I am having is it doesn't show the references in the Bill of Materials or Contains tab and the referencing file doesn't show up in the Where Used of the referencing files. It also doesn't show the referenced files when I try to check out or transition the referencing file.

I tried a couple of different methods for adding the references: the IEdmAddCustomRefs2 & IEdmEnumeratorCustomReference7 interfaces. It feels like I am missing something in order to get the contains & where used trees to build.

'Use the previously obtained filenames to create a custom reference to the project file
Dim addCustRefs As IEdmAddCustomRefs2 = iVault.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs)
addCustRefs.AddReferencesPath2(iFile.ID, sRefFilenames, iRefQtys)
addCustRefs.CreateTree(CInt(EdmCreateReferenceFlags.Ecrf_Nothing))
addCustRefs.CreateReferences()

OR

Dim iCustRef As IEdmEnumeratorCustomReference7 = iFile
Dim iRefFile As IEdmFile18 = iVault.GetFileFromPath(sRefFilenames(i))
Dim iFolder As IEdmFolder13 = iVault.GetFolderFromPath(iFolderPath)
iCustRef.AddReference3(iRefFile.ID, iFolder.ID, 1, True)
User avatar
AlexB
Posts: 501
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 28
x 268
x 445

Re: PDM User-defined File References

Unread post by AlexB »

I'm actually doing this in some of my API code and it's most similar to your first block of code using the IEdmAddCustomRefs2 utility.

The file associations won't be visible until the file is checked in. Have you verified if they show up on the Contains or Where Used tabs after the file the reference was added to is checked in?
// c# code
//
customRefs = _vault.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs) as IEdmAddCustomRefs2;
customRefs.AddReferencesPath(pdmFile.PDMFileId, paths.ToArray());
customRefs.CreateTree((int)EdmCreateReferenceFlags.Ecrf_Nothing);
bRet = customRefs.ShowDlg(0);
if (bRet)
bRet = customRefs.CreateReferences();
MMartens
Posts: 36
Joined: Wed Apr 28, 2021 10:01 am
Answers: 6
Location: Shawano, WI USA
x 6

Re: PDM User-defined File References

Unread post by MMartens »

I think my issue is I am relying on my addin to create the references during the PreUnlock command. When I use a menu command to create the references and go straight into the check in dialog, the bill of materials, contains, and where used tabs get updated.
Post Reply