Custom weight and CoG report in shipbuilding

Hello,

I need to measure the weight and center of gravity of each section along my ship. I need to export this information to a spreadsheet.
There is the Weight and Center of Gravity feature in the basic design module, which exports the weight and CoG of a certain section in a spreadsheet. But how can I modify this feature so that my spreadsheet will show the weight and CoG of all of my sections along the ship? The cells of a row would contain the following:
Section 1 Weight(t) Xcg(m) Ycg(m) Zcg(m), and so on with Section 2 in the second row, Section 3 in the third row...

The journaling doesn't help me a lot, because I'm very new to this, and when I record the steps of this feature, it doesn't record creating the excel. (When I use this feature without recording, then it shows the excel with the information at the end, but when I use the feature while recording, it doesn't even show the excel at the end.) All it records is this:

Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: Application->Ship Structure->Basic Design
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Enter Ship Structure Basic Design")

theSession.ApplicationSwitchImmediate("UG_APP_SHIP_BASICDESIGN")

displayPart.Features.ShipCollection.RegisterCallbackFunctionsForMirrorCopy()

displayPart.Features.ShipCollection.SetSteelFeatureApproach(NXOpen.Features.ShipCollection.SteelFeatureApproach.SketchSharing)

theSession.CleanUpFacetedFacesAndEdges()

' ----------------------------------------------
' Menu: Tools->Ship Design->Weight and Center of Gravity...
' ----------------------------------------------
Dim markId2 As NXOpen.Session.UndoMarkId = Nothing
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim weightAndCGBuilder1 As NXOpen.Features.ShipDesign.WeightAndCGBuilder = Nothing
weightAndCGBuilder1 = workPart.Features.ShipCollection.CreateWeightAndCgBuilder()

theSession.SetUndoMarkName(markId2, "Weight and Center of Gravity Dialog")

Dim component1 As NXOpen.Assemblies.Component = CType(displayPart.ComponentAssembly.RootComponent.FindObject("COMPONENT 000876/A 1"), NXOpen.Assemblies.Component)

Dim body1 As NXOpen.Body = CType(component1.FindObject("PROTO#.Bodies|ShipSection(70:2A)"), NXOpen.Body)

weightAndCGBuilder1.VolumeBody.Value = body1

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Weight and Center of Gravity")

Dim nXObject1 As NXOpen.NXObject = Nothing
nXObject1 = weightAndCGBuilder1.Commit()

theSession.DeleteUndoMark(markId3, Nothing)

theSession.SetUndoMarkName(markId2, "Weight and Center of Gravity")

weightAndCGBuilder1.Destroy()

Dim markId4 As NXOpen.Session.UndoMarkId = Nothing
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim weightAndCGBuilder2 As NXOpen.Features.ShipDesign.WeightAndCGBuilder = Nothing
weightAndCGBuilder2 = workPart.Features.ShipCollection.CreateWeightAndCgBuilder()

theSession.SetUndoMarkName(markId4, "Weight and Center of Gravity Dialog")

' ----------------------------------------------
' Dialog Begin Weight and Center of Gravity
' ----------------------------------------------
weightAndCGBuilder2.Destroy()

theSession.UndoToMark(markId4, Nothing)

theSession.DeleteUndoMark(markId4, Nothing)

theSession.CleanUpFacetedFacesAndEdges()

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

When I play it back, nothing happens.

Do you have a good idea how it could be done? Thanks if you can help me.

I

Unfortunately, I don't have any knowledge of (or access to) the ship building functions in NX. If no one here has any ideas, I suggest posting on the Siemens community forum, someone there may have experience with automating the ship building functions.

https://community.sw.siemens.com/s/topic/0TO4O000000MiiWWAS/nx-customiza...

OK, I'll do that, thanks!

Hi Ildi,
I have some experience with the Ship Building functions. Writing to Excel is not very complicated but I think it can not be done with a journal. I expect you need to be able to create a dll file.
I have been working on a custom export script to excel, there are some complexities (depending on the NX version) when dealing with attributes that are on a face.

You can read from and write to an Excel file even if you do not have an NX author license; the process is a bit more difficult, but possible.

http://nxjournaling.com/comment/623#comment-623
http://nxjournaling.com/comment/4964#comment-4964

I found the above by doing a quick search on this site, those were a couple of the first hits. I'm sure that searching eng-tips and the Siemens forum would also turn up some examples.

Also, Yamada wrote a guide to communicating with Excel. His guide assumes that you have an NX author license, but much of what he wrote applies even if you do not.
https://community.sw.siemens.com/s/question/0D54O000061xKz0SAE/communica...

Thank you for this info, this could be especially useful when bound to a journal file.