Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
(OP)
Hi
I have a journal that grab assembly parts by the following statement
and do somthing with the parts. but I found that the parts array
contains parts from other assembly part in the session.
and I want only parts from the assembly part that the journal itself open
and manipulate.
How I can do that.
I'm using nx 8.5
and run this journal on NX Manger platform.
Thanks in advanced.
I have a journal that grab assembly parts by the following statement
CODE -->
Dim sparts As Part() = s.Parts.ToArray()
and do somthing with the parts. but I found that the parts array
contains parts from other assembly part in the session.
and I want only parts from the assembly part that the journal itself open
and manipulate.
How I can do that.
I'm using nx 8.5
and run this journal on NX Manger platform.
Thanks in advanced.





RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
www.nxjournaling.com
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
That's a brief and good explained example.
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
why it will not work on nx manager.
When I'll be on accessible nx manager I'll try it.
Thank you.
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
www.nxjournaling.com
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
You just get the root component, and use its Descendents property. This property has internal logic that does all the recursion for you.
There are lots of examples of this sort of thing in the Assemblies chapter of the "Getting Started with SNAP" document.
RE: Journal Quastion on this statement ==> Dim sparts As Part() = s.Parts.ToArray()
BubbaK Thank you your notice. (I have not a SNAP)
I found this GTAC journal with non-recursive sub for getting all components.
and I wonder witch one is more fastest the recursive one or the non-recursive one
CODE -->
'Date: 5-JUN-2008 'Subject: Sample NX Open .NET Visual Basic program : rename components to part number 'Note: GTAC provides programming examples for illustration only, and 'assumes that you are familiar with the programming language being 'demonstrated and the tools used to create and debug procedures. GTAC 'support professionals can help explain the functionality of a particular 'procedure, but we will not modify these examples to provide added 'functionality or construct procedures to meet your specific needs. ' ' this should rename components in the current displayed part ' to the NXManager Part Number. ' ' Note that they will ONLY be renamed in the displayed part. ' ' So if part C is a component of part B and B is a component ' in part A, and A is the displayed part, component C will be ' renamed in A. If you make B the displayed part, then ' component C will not appear to be renamed in that context. ' Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.UI Imports NXOpen.Utilities Module rename_components_to_part_number Public s As Session = Session.GetSession() Public ufs As UFSession = UFSession.GetUFSession() Public lw As ListingWindow = s.ListingWindow Sub Main() Dim is_active As Boolean = False ufs.UF.IsUgmanagerActive(is_active) If is_active = False Then MsgBox("This program should be used in an NXManager environment.", _ MsgBoxStyle.Exclamation) Return End If Dim dp As Integer = 0 dp = check_for_missing_display_part() If dp = 1 Then Return End If Dim dispPart As Part = s.Parts.Display Dim thisComp As NXOpen.Tag = NXOpen.Tag.Null Do thisComp = ask_next_component(dispPart.Tag, thisComp) If thisComp <> NXOpen.Tag.Null Then Dim partName As String = "" Dim refsetName As String = "" Dim instanceName As String = "" Dim origin(2) As Double Dim csysMatrix(8) As Double Dim transform(3, 3) As Double ufs.Assem.AskComponentData(thisComp, partName, refsetName, _ instanceName, origin, csysMatrix, transform) Dim partNumber As String = "" partNumber = ask_component_part_number(partName, thisComp) Dim thisInstance As NXOpen.Tag = _ ufs.Assem.AskInstOfPartOcc(thisComp) ' this changes what shows up in Component Properties->General->Name ufs.Obj.SetName(thisComp, partNumber) ' uncomment the following line to change the instance name 'ufs.Assem.RenameInstance(thisInstance, partNumber) End If Loop Until thisComp = NXOpen.Tag.Null End Sub Public Function ask_component_part_number(ByVal partName As String, _ ByVal comp As NXOpen.Tag) As String Dim partNumber As String = "" Dim partRev As String = "" Dim partFileType As String = "" Dim partFileName As String = "" ufs.Ugmgr.DecodePartFileName(partName, partNumber, _ partRev, partFileType, partFileName) Return partNumber End Function Public Function ask_next_component(ByVal dispPartTag As NXOpen.Tag, _ ByVal comp As NXOpen.Tag) As NXOpen.Tag Dim type As Integer = 0 Dim subtype As Integer = 0 Do ufs.Obj.CycleObjsInPart(dispPartTag, _ UFConstants.UF_component_type, comp) If NXOpen.Tag.Null = comp Then Return comp End If ufs.Obj.AskTypeAndSubtype(comp, type, subtype) If subtype = UFConstants.UF_part_occurrence_subtype Then Return comp End If Loop Until comp = NXOpen.Tag.Null Return comp End Function Public Function check_for_missing_display_part() As Integer Dim dispPart As Part = Nothing Try dispPart = s.Parts.Display Catch ex As Exception lw.Open() lw.WriteLine("+++Error: " & ex.ToString()) End Try If dispPart Is Nothing Then lw.Open() lw.WriteLine("There is no current Displayed Part") ufs.UF.PrintSyslog("+++ERROR: There is no current Displayed Part", _ False) Return 1 End If Return 0 End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer Return Session.LibraryUnloadOption.Immediately End Function End Module