Vault: Display Mass – Client or Web

A client recently asked me if I could help them with a request from an end user. They wanted to see the mass of their part and assembly files in Vault. A secondary requirement was to see this same information in the Vault web client.

I figured a simple iLogic rule would suffice. However, a word of warning when using Vault and iLogic. Always make sure that your code does not try to write properties or update the model after it has been saved or checked in, more on this later (see Event Triggers).

Part One – a bit of iLogic to get the mass:

The code is really simple, it writes the mass of the component to an iProperty called “Subject”. I chose “Subject” for 3 reasons, firstly it is not often used, secondly it is already mapped to Vault, and thirdly, it is easily viewable in the web client.

Create an external iLogic rule called “Mass” (or something similar). Here is the iLogic code that we need:

'This iLogic code by @ClintBrown3D, originally posted at https://clintbrown.co.uk/vault-display-mass---client-or-web
iLogicVb.UpdateWhenDone = True
oMassCalc = Round(iProperties.Mass,2) ' This sets the accuracy 2 = 0.12  -  3 = 0.123
iProperties.Value("Summary", "Subject") = "Last Calculated Mass " & oMassCalc & " Kg - This number could be out of date"

Test the code on a part or assembly file, the “Mass” should show in the iProperties of the file (listed under “Subject”), as shown below:

Note that I have a little disclaimer in the comment we are writing back to the file. This method should be 100% accurate, but without testing it extensively, this is the safest way to proceed. You can edit this to match your requirements.

Part Two – Event Triggers:

In Inventor we are going to set up some Event Triggers.

The Event Triggers must be set up identically for both Parts and Assemblies. In both cases we assign our external rule “Mass” to run “Before Save”.

Two things to consider here;

Firstly we are using an “External Rule” because we could be affecting thousands of files, and if we needed to tweak the rule, this could become quite difficult with an internal rule.With one external rule to manage this task is very simple.

Secondly, we are running our Event Triggers “Before Save”, this is effectively asking Inventor to write the iProperty “Mass” to the iProperty “Subject” before we save the file, i.e. when the user hits save, first update the component Mass, write out our properties and then save the file. This ensures that all edits are complete before the file is checked in, preventing the dirtying of files.

Part Three – Vault

The good news here, is that because we have chosen a standard property, there is no mapping to do, we can just check that the work we did above works as expected.

To test this, simply save, then check the a part or assembly file into Vault. The “Subject” field should look similar to the image below.

Part Four – Web Client Setup

Log into your Web client as an Administrator. Click your “Project Explorer”, then on the settings icon shown below.

Add “Subject” to the “Selected Properties” list.

The “Subject” field will now be visible, the image below shows results of a search.

If you then choose a file (preferably one that already has a populated “Subject” value). There are 2 settings that can be changed to show the “Subject” property (shown below). As before, add “Subject” to both of these listings.

The “Mass” (or “Subject”) of the component will now be visible here too.

In summary, a small iLogic utility and a couple of tweaks to the web client seem to work quite well. But I have not done exhaustive tests to ensure this.

Notes:

This version of the code was briefly tested in Inventor 2021.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!