NX Journal Position display of child parts of assembly

2019/12/03 categories:NX Journal| tags:NX Journal|VB|

I have created a program to display the position of child parts in the NX journal.

VB Code

Imports System
Imports NXOpen

Module NXJournal
    Sub Main (ByVal args() As String) 
        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work

        Dim children() As Assemblies.Component
        Dim constraints() As Positioning.ComponentConstraint
        Dim i As Long, j As Long

        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open

        children = workPart.ComponentAssembly.RootComponent.GetChildren()

        For i = 0 to ubound(children)
            lw.WriteLine(children(i).GetStringAttribute("DB_PART_NO"))

            Dim child_pt As Point3d
            Dim child_mt As Matrix3x3

            children(i).GetPosition(child_pt, child_mt)

            lw.WriteLine("pt X, Y, Z  :")
            lw.WriteLine(child_pt.X & ", " & child_pt.Y & ", " & child_pt.Z)

            lw.WriteLine("mt :")
            lw.WriteLine(child_mt.Xx & child_mt.Xy & child_mt.Xz)
            lw.WriteLine(child_mt.Yx & child_mt.Yy & child_mt.Yz)
            lw.WriteLine(child_mt.Zx & child_mt.Zy & child_mt.Zz)
        Next
    End Sub

End Module

Share post

Related Posts

コメント