Is there any way to have a custom property in a part that references the mass properties of whatever assembly it is used in?

I have a quantity of a part that depends on the mass properties of whatever assembly it is used in. Any ideas on a macro that could do this?

SolidworksApi macros