Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations Ron247 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in journal that identify assembly components that are "familly members components&quo

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi

Please can anyone help in nxopen vb functions that can scan an assembly and list all components
that are "familly members components"

Thanks in advanced
 
Replies continue below

Recommended for you

1. Family members can be visually identified in the Assembly Navigator by displaying the column called "Info"
2. In a journal, use the old user function "UF_PART_is_family_instance"
3. As for scanning the assembly, there are a lot of code examples in the Siemens GTAC library
 
Hi daluigi

I'l try the "UF_PART_is_family_instance"

Thank you
 
Hi daluigi

maybe you can help in this

the "UF_PART_is_family_instance" function works good in NATIVE mode
but I need it in NXMANAGER mode but in this mode I get an error at this line

ufs.Part.IsFamilyInstance(myPart.Tag, is_family_instance)

the error is System.NullReferenceException: Object reference not set to an instance of an object

Thanks in advanced

heer the code that works good in Native mode

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Assemblies

Module list_all_family_members_components

Dim s As Session = Session.GetSession
Dim ufs As UFSession = UFSession.GetUFSession
Dim workPart As Part = s.Parts.Work
Dim dispPart As Part = s.Parts.Work
Dim lw As ListingWindow = s.ListingWindow

Sub Main()

Dim root As Component = dispPart.ComponentAssembly.RootComponent
Dim refComps As Component() = root.GetChildren()
Dim is_family_instance As Boolean
Dim cnt As Integer = 1
Dim len As Integer
Dim fmComponents(-1) As Component
lw.Open()

len = -1
For Each thisComp As Component In refComps

Dim myPart As Part = thisComp.Prototype.OwningPart
ufs.Part.IsFamilyInstance(myPart.Tag, is_family_instance)
If is_family_instance = TRUE Then

len = len + 1
ReDim Preserve fmComponents(len)
fmComponents(len) = thisComp

End If

Next

cnt = 1
For Each thisComp As Component In fmComponents

Dim selectedComps(0) As Assemblies.Component
lw.WriteLine(cnt.ToString & " " & thisComp.DisplayName & " ====>>> Is a family Member ")
cnt = cnt + 1

Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module
 
I am not familiar with "thisComp.Prototype.OwningPart". I tried replacing myPart.Tag with dispPart.tag and it ran. You will need another way of defining how you get the tag from your components. I would probably open each component in the assembly and use workPart.tag. There should be a better way of doing this, but can't think of it off the top of my head.
 
aluminum2 said:
I am not familiar with "thisComp.Prototype.OwningPart".

The syntax above will get a reference to the part file of the given component. It only works if the part file is open in session or if it can be found with the current load options.

Check to see if "myPart" is a valid reference before calling any of its properties or methods.

Code:
If IsNothing(myPart) Then
    'part is not loaded, attempt to load it
    'or skip processing this part
End If

Fully loading the assembly or changing your TC load options may help.

www.nxjournaling.com
 
Hi

I'm very Thanks for the repllies

For thisComp.Prototype.OwningPart See NX journaling link
on the line ==>> Dim thePart As Part = theComponent.Prototype.OwningPart
and I see it also in some GTAC code examples

It only works if the part file is open in session but this journal is run ok in native mode
without opening any component part

Is NXMANAGER running mode is different from NATIVE running mode
Why NXMANAGER throw System.NullReferenceException and NATIVE not

I'm very thanks for any help to come
 
Hi cowski

Thank you for the response

When I am at work I'll check it

But what are the settings in load options that will allow the journal to work


I am grateful for any help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor