Get Sheetbody name of a Trimsheet Feature

Hi NxJournaling,

I need to rename sheetbody of a trimsheet feature. I can rename trimsheet feature but not able to get sheetbody name (using feature.getbodies).

Here is the code i am trying.

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

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

Dim objects1(0) As NXOpen.NXObject
Dim theUI As UI = UI.GetUI()

objects1(0) = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.Features.TrimSheet)

Dim featureGeneralPropertiesBuilder1 As NXOpen.FeatureGeneralPropertiesBuilder = Nothing
featureGeneralPropertiesBuilder1 = workPart.PropertiesManager.CreateFeatureGeneralPropertiesBuilder(objects1)

featureGeneralPropertiesBuilder1.FeatureName = "Feature_p1"

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

featureGeneralPropertiesBuilder1.Destroy()

dim Sheetbodies() as NxOpen.Body = Nothing
Sheetbodies = objects1.GetBodies

'Sheetbodies = objects1.GetBodies getting error here (unable to convert trimsheet
to NxOpen Body.

'Please help me to solve this.

End Sub
End Module

Thanks & Regards,
GopinadhGvs.

Try the following code. It assumes the trimsheet feature is pre-selected before the journal is run. It should find the sheet body and name it "TEST".

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim objects1 As Features.TrimSheet

objects1 = CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.Features.TrimSheet)

Dim Sheetbodies() As NXOpen.Body = Nothing
Sheetbodies = objects1.GetBodies

'lw.WriteLine("number of bodies found: " & Sheetbodies.Length.ToString)

Sheetbodies(0).SetName("test")

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

It's Working.

Thanks NX Journaling.

GopinadhGvs