How to get via API all File Properties and their Values for all Files from the selected Assembly File?

How to get via API all File Properties and their Values for all Files from the selected Assembly File?

petr_cizekTGR8C
Participant Participant
1,949 Views
6 Replies
Message 1 of 7

How to get via API all File Properties and their Values for all Files from the selected Assembly File?

petr_cizekTGR8C
Participant
Participant

Hi, we are building an extension to Vault Professional 2024 Client to allow the user to transfer data from Vault to ERP system via the REST API. Currently the C# code is written to work with Vault Files and their Properties, we could possibly change the approach to work with Vault Items if recommended.

 

Our target would be to get via Vault API all File Properties and their Values for all Files from the selected Assembly File and later to work with them locally (verification, Assembly creation, Child-part creation, …) in order to minimize the number of requests to the Vault server via the API.

 

Our today solution works when selected single Part. We are using the PropertyManager.GetPropertyValue to get each File Property Value. When we use the same function on the Assembly which has the same part as the child-part, we could not receive the Category Name, Status , ...

0 Likes
1,950 Views
6 Replies
Replies (6)
Message 2 of 7

Nick_Hall
Collaborator
Collaborator

Hi Petr

 

You can use PropertyService.GetPropertiesByEntityIds to return all the properties for all of the files (or items)

 

PropInst[] fileProperties = propSvc.GetPropertiesByEntityIds("FILE", new long[] { file1.Id, file2.Id, ... fileN.Id});

 

Hope that helps

 

Nick

0 Likes
Message 3 of 7

petr_cizekTGR8C
Participant
Participant

Hi Nick, thanks for your reply. Could you please advice as well the best way to get the list of all child-files from the "assembly" file? I found this: GetItemFileAssociationsByItemIds but is not this function only for the Items? Because we work with Files in IExplorer... Thanks Petr

0 Likes
Message 4 of 7

Markus.Koechl
Autodesk
Autodesk

There are two options to get related files: retrieve all IDs using GetFileAssociationLitesByIds or retrieve all file objects of these using GetFileAssociationsByIds. Sample code is available here: iLogic-Vault/iLogic-Vault-QuickstartLibrary/iLogic-Vault QuickstartLibrary.cs at 2023.3 · koechlm/iL....



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 7

Nick_Hall
Collaborator
Collaborator

Thanks @Markus.Koechl for saving me the job of replying

 

Nick

0 Likes
Message 6 of 7

petr_cizekTGR8C
Participant
Participant

Hi @Nick_Hall & @Markus.Koechl, thanks for your feedback. As we go further, we face another issue...

Issue: Different Properties received for single selected file versus same file as component in Assembly

 

When we select single File (240189.ipt) in Vault, we get correct File properties:

 

Vault:

petr_cizekTGR8C_0-1698411571378.png

 

Code to get Properties if selected PART:

petr_cizekTGR8C_1-1698411571393.png

 

PropInfoArray:

petr_cizekTGR8C_2-1698411571404.png

In this case, the Part Number (PropDefId = 26) is 240189 which is OK.

 

If I select Assembly, which has this File 240189 as a component, we get wrong data…:

Vault selection:

petr_cizekTGR8C_3-1698411571415.png

Code to get the ChildFiles for the Assembly:

petr_cizekTGR8C_4-1698411571432.png

Received bom object:

petr_cizekTGR8C_5-1698411571436.png

bom CompArray:

petr_cizekTGR8C_6-1698411571447.png

BOM InstArray:

petr_cizekTGR8C_7-1698411571453.png

The code to check the Assembly is calling the same function isValidProperties… but the received data for the Child Part are different:

PropInfoArray:

petr_cizekTGR8C_8-1698411571464.png

It is mainly the Part Number and Category Name we have trouble with… but probably not limited to these.

 

It seems we are receiving different BOM InstanceId or XRefId (1880778 versus 1850257), but how to get the same Instance from the Assembly file…?

 

Are you able to help? Thanks

0 Likes
Message 7 of 7

Nick_Hall
Collaborator
Collaborator

Hi Petr

 

Without having access to your Vault I can't be 100% certain about this, but I think that your assembly is referencing an older version of 240189.ipt

 

There are loads of ways this could happen, so it's quite plausible/likely

 

If you want to get the latest version, you can use GetLatestFilesByMasterIds or GetLatestFilesByIds

 

If I've understood correctly, you want to pass an array of CompArray.XRefId to GetLatestFilesByIds, which will give you the latest version of all the BOM Components

 

It will get a bit messy handling the referenced and latest components, but you should be able to work it out

 

But it's worth looking into why this is happening, which you can do by cross-checking the version numbers in Vault, and working back from there. It may be that you need to make changes to your workflows and/or lifecycles to ensure the data in Vault & the data in your ERP system match

 

Hope that helps

 

Nick

 

 

0 Likes