Creating new feature group

Hi,
Can any one please help me how to create a new feature group in VB?

I tried to run journal, but it doesn't support this command.

I am writing a code to create a feature group first and include all the features subsequently created inside that.

can some one please show me a sample using the following function?
CreateSetOfFeature ( _
name As String, _
features As Tag(), _
number_of_feature As Integer, _
hide_state As Integer, _
ByRef feature As Tag _
)

Thanks in advance.
Regards,
Nataraj

The code below shows how to use the .CreateSetOfFeature method. Open/create a part with several features before running the code; it will take the first few features in the part and put them into a group named "test".

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

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
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 = "NXJ feature group"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim featuresToGroup As New List(Of Tag)

For i As Integer = 0 To 4
featuresToGroup.Add(workPart.Features.ToArray(i).Tag)
Next

Dim theFeatureGroupTag As Tag
'CreateSetOfFeature(groupName, array of features to group, number of features,
' hide (embed) features [0 = show (don't embed), 1 = hide (embed)], resulting group tag)
theUfSession.Modl.CreateSetOfFeature("test", featuresToGroup.ToArray, featuresToGroup.Count, 1, theFeatureGroupTag)

Try
' TODO: Add your application code here

Catch ex As NXException
theSession.UndoToMark(markId1, undoMarkName)
MsgBox(ex.Message)

Finally

End Try

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

Other functions that will be useful when working with feature groups are:
.AskSetsOfMember
.AskAllMembersOfSet
.EditSetMembers
.EditSetHideState
.IsFeatureASetMember
.IsFeatureAHiddenSetMember
.AskSetFromName

Is it possible to create an empty feature group?
It possible with UG itself.

Dim featuresToGroup As Tag() = Nothing
Dim theFeatureGroupTag As Tag = Nothing
theUfSession.Modl.CreateSetOfFeature("test", featuresToGroup, 0, 1, theFeatureGroupTag)

Thank you NXjournaling and wizdar.... It works well.

How to create empty group and sub-groups.......

-[]-

Try the following journal (tested on NX 9).

Option Strict Off
Imports System
Imports System.Collections.Generic
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 markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "NXJ")

lw.Open()

Dim featuresToGroup As Tag() = Nothing

Dim subGroupTag1 As Tag = Nothing
theUfSession.Modl.CreateSetOfFeature("subgroup1", featuresToGroup, 0, 1, subGroupTag1)

Dim subGroupTag2 As Tag = Nothing
theUfSession.Modl.CreateSetOfFeature("subgroup2", featuresToGroup, 0, 1, subGroupTag2)

Dim featureSubGroups As New List(Of Tag)
featureSubGroups.Add(subGroupTag1)
featureSubGroups.Add(subGroupTag2)

Dim theFeatureGroupTag2 As Tag = Nothing
theUfSession.Modl.CreateSetOfFeature("featureGroup", featureSubGroups.ToArray, featureSubGroups.Count, 1, theFeatureGroupTag2)

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

CreateSetOfFeature will only create a feature group as a time stamped fature group.
Our cutomer defaults allow both.
I found this method: WorkPart.Features.ConvertToFloatingFeatureGroups()
but I do NOT want ALL feature groups to be converted.
Is there a way to convert a specific one or create one that is already floating?

Cheers
Philip
IT Solution Specialist at Siemens in Nuremberg
Mechanical Engineer from Georgia Tech

Unfortunately, I could not find a way to create a floating feature group or convert only specific groups.