Is a Component a Part-Family-Member or not...

Hello everybody,

currently I'm working on an automated parts list. So far the Journal cycles through the assembly and collects all parts. In the following the Journal gets the needed information from each part and writes it into a .csv-file.
In a additional column I want to write the information if the part is a regular part or a part-family-member.
As a result I'm searching after a command or technique to find out if a component is a family-member or not.

Can someone help me with this problem?

Thanks in advance
Lorenz

Below is some code I have on hand that reports whether the work part is a family template, an instance, or a normal part. The functions take a part as a parameter; if you have a reference to a component, you could pass in the component prototype's .OwningPart to see whether the component part is part of a family or not.

Option Strict Off
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display

Sub Main()

If IsNothing(theSession.Parts.Display) Then
MessageBox.Show("Active Part Required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End If

Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

'Dim famInstSaveDir As String
'theUfSession.Part.AskFamInstSaveDir(famInstSaveDir)
'lw.WriteLine("family instance save directory [session/customer default part file directory]: " & famInstSaveDir)

Dim numMembers As Integer = 0

If IsPartFamilyTemplate(workPart) Then
lw.WriteLine("the work part is a part family template")
lw.WriteLine("family save directory: " & PartFamilySaveDir(workPart))

ElseIf IsPartFamilyInstance(workPart) Then
lw.WriteLine("the work part is a family member")
Dim parent As String = PartFamilyTemplateFilename(workPart)
lw.WriteLine(" this instance belongs to: " & parent)

lw.WriteLine("")

End If

End Sub

Function IsPartFamilyTemplate(ByVal thePart As Part) As Boolean

Dim isFamilyTemplate As Boolean = False
theUfSession.Part.IsFamilyTemplate(thePart.Tag, isFamilyTemplate)
Return isFamilyTemplate

End Function

Function IsPartFamilyInstance(ByVal thePart As Part) As Boolean

Dim isFamilyInstance As Boolean = False
theUfSession.Part.IsFamilyInstance(thePart.Tag, isFamilyInstance)
Return isFamilyInstance

End Function

Function PartFamilyTemplateFilename(ByVal thePart As Part) As String

Dim familyTemplate As String = ""
theUfSession.Part.AskTemplateFilename(thePart.Tag, familyTemplate)
Return familyTemplate

End Function

Function PartFamilySaveDir(ByVal templatePart As Part) As String

'ref: nx_api3895

Dim family_count As Integer
Dim families() As Tag = Nothing
theUfSession.Part.AskFamilies(templatePart.Tag, family_count, families)

Dim familyDir As String = ""
theUfSession.Part.AskFamilySaveDir(families(0), familyDir)

Return familyDir

End Function

End Module