AddFile and FileAssocParams argument

AddFile and FileAssocParams argument

daniel_cadext
Advisor Advisor
1,549 Views
5 Replies
Message 1 of 6

AddFile and FileAssocParams argument

daniel_cadext
Advisor
Advisor

Hello,

I’m trying to use the add file method with FileAssocParams, but it seems I’m missing something as when I check the results in the thick client, I see an “Unknown status” icon, pseudo code.

 

 

Parent

foreach (child in children)

{

       childId = Vault.AddFile(null);

        Parent.addChildParam(FileAssocParam(childId))

 }

 Vault.AddFile(Parent,  Parent.FileAssocParams)

 

Do I need to link the children with the parent too?

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Accepted solutions (1)
1,550 Views
5 Replies
Replies (5)
Message 2 of 6

daniel_cadext
Advisor
Advisor

So, if I check the files out, then back in again, the status is ok. Do I need to call addFile and CheckinFile?

Or is there a way to update the status without re-sending the file?

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 6

Markus.Koechl
Autodesk
Autodesk

You can do this in one step by using FileManager.AddFile method. To get a better understanding of the FileAssocParam[] array, I suggest debugging a sample assembly file using GetLatestFileAssociationsByMasterIds. I recently created a sample doing this: 

 #region capture dependencies
                //we need to return all relationships during later check-in
                List<ACW.FileAssocParam> mFileAssocParams = new List<ACW.FileAssocParam>();
                ACW.FileAssocArray mFileAssocArray = mWsMgr.DocumentService.GetLatestFileAssociationsByMasterIds(new long[] { mFile.MasterId },
                    ACW.FileAssociationTypeEnum.None, false, ACW.FileAssociationTypeEnum.All, false, false, false, true).FirstOrDefault();
                if (mFileAssocArray.FileAssocs != null)
                {
                    foreach (ACW.FileAssoc item in mFileAssocArray.FileAssocs)
                    {
                        ACW.FileAssocParam mFileAssocParam = new ACW.FileAssocParam();
                        mFileAssocParam.CldFileId = item.CldFile.Id;
                        mFileAssocParam.ExpectedVaultPath = item.ExpectedVaultPath;
                        mFileAssocParam.RefId = item.RefId;
                        mFileAssocParam.Source = item.Source;
                        mFileAssocParam.Typ = item.Typ;
                        mFileAssocParams.Add(mFileAssocParam);
                    }
                }

                #endregion capture dependencies

....
// checkin new file version
                VDF.Currency.FilePathAbsolute vdfPath = new VDF.Currency.FilePathAbsolute(mLocalFileFullName);
                FileIteration mUploadedFile = null;
                try
                {
                    if (mFileAssocParams.Count > 0)
                    {
                        mUploadedFile = mConnection.FileManager.CheckinFile(mNewFileIteration, "Created by Custom Job executing iLogic : " + mAllRulesTextWrp,
                                                false, mFileAssocParams.ToArray(), null, true, null, mFileIteration.FileClassification, false, vdfPath);
                    }
                    else
                    {
                        mUploadedFile = mConnection.FileManager.CheckinFile(mNewFileIteration, "Created by Custom Job executing iLogic : " + mAllRulesTextWrp,
                                                false, null, null, false, null, mFileIteration.FileClassification, false, vdfPath);
                    }

                }
                catch
.....


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 4 of 6

daniel_cadext
Advisor
Advisor

Hello Markus,

Thank you for your reply,  mFileAssocArray.FileAssocs  from GetLatestFileAssociationsByMasterIds is NULL as I’m attempting to upload the children first, they are new files, and they are not associated with any other file.

 

I then try to upload the parent last, but because there are no associations, I have no way to assign RefId

It seems your sample is for files already on the server, and already have associations, is this correct?

 

Best regards

Daniel

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 5 of 6

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Hi Daniel,
Indeed, my sample code was meant to analyze existing parent-child dependencies to better understand the FileAssocParam. You need to upload from child to parent while capturing each id and other parameters to build the FileAssocParam.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 6 of 6

GeorgeWilliams
Advocate
Advocate

Via Fiddler, I can see that the Vault addin executes the GetLatestFilePathsByNames right before it prompts me to save a file before adding it to the Vault.  I am having sync issues adding Inventor files via the Vault API.  I am using the undocumented apprenctice call to get the refIds for the FileAssocParam objects but that is not solving the problem.  The expectedFilePath is correct as well.  The Vault addin resolver must be doing something that I'm not finding any information online to implement for a successful AddFile operation on Inventor assemblies.  Thoughts?

George Williams
D3 Technologies - Automation Solutions
************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
0 Likes