weight calculations journal

Hi,

I'm trying to write a journal for weight calculations.
In the past I was able to write some basic journals with great help from this forum. This time what I'm trying to achieve is a bit more complicated and I'm struggling to get started. Would be great if someone wants to give me some tips!

This is what I want to achieve:
I want to iterate through an assembly and, for each sheetbody get the centroid (geometric center) and the area and write them to a list.

Centroid: can be obtained using the command "mass using curves and sheets" using the thin shell option. Recording this action in a journal unfortunately gives me nothing to work with.

Area: can be optained using the face analyses command.

This info I want to use for some basic calculations:
mass (area*density_attribute*thickness_attribute) each sheetbody has its own attribute

Total COG (sum (mass*cog))/total mass

My goal is to get a results log containing:
Mass for each NX_part
Mass for the NX_ASM
COG for each NX_part
COG for the NX_ASM

First I want to get it to work fo a single part and then make it work on assembly level.

Any directions are very much appreciated!

The .AskMassProps3d is probably a good place to start. The journal below will report the surface area and COG of each sheet body in the current work part. The journal is meant to be run on a piece part, it may not work (in its current form) if run in an assembly.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module92

Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow

Sub Main()

lw = theSession.ListingWindow
lw.Open()

For Each tempBody As Body In theSession.Parts.Work.Bodies
If tempBody.IsSolidBody Then
Continue For
End If

Dim dblAcc_Value(11) As Double
Dim dblMass_Props(46) As Double
Dim dblStats(12) As Double

Dim tagList(0) As NXOpen.Tag
tagList(0) = tempBody.Tag
dblAcc_Value(0) = 0.99

ufs.Modl.AskMassProps3d(tagList, 1, 2, 1, 0.0375, 1, dblAcc_Value, dblMass_Props, dblStats)

lw.WriteLine("sheet body: " & tempBody.Tag.ToString)
lw.WriteLine("Surface Area: " & dblMass_Props(0).ToString & " in^2")
lw.WriteLine("COG: " & dblMass_Props(3).ToString & ", " & dblMass_Props(4).ToString & ", " & dblMass_Props(5).ToString)
lw.WriteLine("")

Next

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

Beware that AskMassProps3d is bizarre in that (unlike every other NXOpen function) it returns answers in WCS coordinates. This doesn't matter for mass or volume, of course, but it does matter for centroids.

Yes, it should be noted that the coordinates will be w.r.t. the WCS. I believe this is by design and not a bug or arbitrary decision by the developers. The inertia calculations depend on the chosen frame of reference; moving the WCS as desired and calling .AskMassProps3d is pretty easy. If .AskMassProps3d only gave results w.r.t. the absolute coordinate system, we'd have to call auxiliary functions or write our own code to transform the output to the desired coordinate system.

Many thanks for your help and advice!
I hope I'll get it to work :-)