UF_OBJ_cycle_objs_in_part( this_part, type, &feature ) not able to get Group Tag

I wanted to ungroup all the groups and delete only the feature groups. Not able to get group tag
UF_OBJ_cycle_objs_in_part( this_part, type, &feature ); when type= UF_group_type

Gettting null feature
wanted to use UF_GROUP_ungroup_all routine
Please let me know

Thanks

I'm a bit unclear on whether you want to work with feature groups, regular groups, or maybe both. It seems that you want to find the feature groups, remove the members, and delete the group container. The code below will do that; if I have misinterpreted your question, please let me know.



Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.Features

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Const undoMarkName As String = "Delete Feature Groups"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim myFeatureGroups As New List(Of FeatureGroup)

'collect all the feature groups in the work part
For Each theFeature As Feature In workPart.Features
If TypeOf (theFeature) Is FeatureGroup Then
myFeatureGroups.Add(theFeature)
End If
Next

'remove features from the feature groups
For Each tempGroup As FeatureGroup In myFeatureGroups
tempGroup.RemoveAllMembers()
Try
'update the part navigator display
theSession.UpdateManager.LogForUpdate(tempGroup)
theSession.UpdateManager.DoUpdate(markId1)
Catch ex As NXException

End Try

Next

'delete the feature group containers
theSession.UpdateManager.ClearErrorList()

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Delete")

Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(myFeatureGroups.ToArray)

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId2)

lw.Close()

End Sub

End Module

How can I remove/delete group in Component Groups in Part? I can remove all components but not group itself.

Thank you in advance,
Alen