Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: nmunro

Thanks for the assistance. The Evaluator function allows reading of the face areas without having to type it in like my first attempt was!

 

I've copied the code if anyone wants to look at it. It uses the area to determine and assign a mass based on the surface area density that you assign through an input box.

 

Sub SurfaceMeasurement()

'Check all referenced docs
Dim oDoc As Inventor.Document
Dim oSurfaceBodies As WorkSurface
Dim oSurfaceBody As SurfaceBody
Dim oFace As Face
Dim density As Double
Dim mass As Double
Dim allArea As Double

mass = 0
allArea = 0
tcount = 0
Set oDoc = ThisApplication.ActiveDocument
oDoc.SelectSet.Clear

'set surface bodies visibility
For Each oSurfaceBodies In oDoc.ComponentDefinition.WorkSurfaces
For Each oSurfaceBody In oSurfaceBodies.SurfaceBodies

For Each oFace In oSurfaceBody.Faces

allArea = allArea + oFace.Evaluator.area * 100

Next

Next
Next

density = InputBox("Please enter the mass per m^2: ", "Density", 2.477)
mass = allArea * density * 0.000001
MsgBox "The mass is " & CStr(mass) & " kg."

oDoc.ComponentDefinition.MassProperties.mass = mass


End Sub