Is there a simple way of finding if a part in the session is a child/component of another part?
Currently I'm having to get all components of each part in the session and then lookup if the part of interest is in the my list of known components which seems a little long winded.
There should be Information => Assemblies => Where used, which you could try to record a journal of.
Production: NX10.0.3, VERICUT 8.0, FBM, MRL 3.1.4 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 10.1
Development: VB.NET, Tcl/Tk Testing: NX11.0 EAP, NX12.0 EAP
How to Get the Most from Your Signature in the Community
Are you concerned with just the parts in the session, or anywhere?
TC or Native?
If anywhere/native, you could use the ugpc.exe on all files & parse the output
If anywhere/TC, where used can show things (may assume PSE is correct for all parts)
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled
Thanks for your suggestion. I've given that a go but it's not supported (at least in NX8.5 that I'm running)
I was thinking along the lines of getting the occurance of the part or casting the part to a component to allow me to then get the parent.
I'm only interested in the parts in the session.
At the moment this is what I'm doing:
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Assemblies Imports System.Collections.Generic Module Module1 Dim comp_list As New List(Of String) Dim parts_list As New List(Of String) ' Explicit Activation ' This entry point is used to activate the application explicitly Sub Main() Dim theSession As Session = Session.GetSession() Dim ufs As ufsession = ufsession.getufsession() Dim theUI As UI = UI.GetUI() Dim lw As ListingWindow = theSession.ListingWindow lw.Open() For Each my_part As Part In theSession.Parts parts_list.Add(my_part.FullPath) Dim ca As ComponentAssembly = my_part.ComponentAssembly Try Walk(ca.RootComponent, 0) Catch ex As Exception End Try Next For Each my_part As String In parts_list If comp_list.Contains(my_part) Then Else lw.WriteLine(my_part) End If Next End Sub Sub Walk(ByVal c As Component, ByVal level As Integer) Dim children As Component() = c.GetChildren() Dim child As Component Dim prototype As Part For Each child In children Dim child_part As Part If TypeOf child.Prototype Is Part Then child_part = CType(child.Prototype, Part) comp_list.Add(child_part.Leaf) End If Walk(child, level + 1) Next End Sub End Module
This shows the parts that are top level assys, which is ultimately what I'm trying to achieve.
Have you tried using this:
It sounds like it could be just what you need.
Note that there are VB/C#/Java wrappers for it.
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX220.127.116.11 MP11 64bit Testing: NX18.104.22.168