Submitted by TuanAnh on Tue, 06/21/2016 - 23:03
Forums:
Hi all.
I have a problem, when i used "Edit Section" command, in Part Navigator have sub Group (Group "Dynamic Section"),How to get name of Group and sub Groups in Part navigator.
Please help me in this.
re: get groups
You can use the .CycleObjsInPart method to get the groups. The following code shows its use.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim tmpGrp As NXOpen.Tag = NXOpen.Tag.Null
Dim myGroup As Group
Dim numMembers As Integer
Dim memberTags() As Tag
Dim numOwningGroups As Integer
Dim owningGroups() As Tag
Do
theUfSession.Obj.CycleObjsInPart(workPart.Tag, UFConstants.UF_group_type, tmpGrp)
'skip the initial null tag
If tmpGrp = NXOpen.Tag.Null Then
Continue Do
End If
myGroup = Utilities.NXObjectManager.Get(tmpGrp)
lw.WriteLine("group name: " & myGroup.Name)
theUfSession.Group.AskGroupData(myGroup.Tag, memberTags, numMembers)
lw.WriteLine(" group contains: " & numMembers.ToString & " members")
theUfSession.Group.AskAllOwningGroups(myGroup.Tag, numOwningGroups, owningGroups)
If numOwningGroups > 0 Then
lw.WriteLine(" owned by: " & numOwningGroups.ToString & " other group(s)")
End If
lw.WriteLine("")
Loop Until tmpGrp = NXOpen.Tag.Null
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
@ NXJournaling.
@ NXJournaling.
Thanks very much. :)