NX Journal アセンブリの子部品の位置表示

Share on:

NXジャーナルで子部品の位置を表示するプログラムを作成しました。

VBコード

 1Imports System
 2Imports NXOpen
 3
 4Module NXJournal
 5    Sub Main (ByVal args() As String) 
 6        Dim theSession As Session = Session.GetSession()
 7        Dim workPart As Part = theSession.Parts.Work
 8
 9        Dim children() As Assemblies.Component
10        Dim constraints() As Positioning.ComponentConstraint
11        Dim i As Long, j As Long
12
13        Dim lw As ListingWindow = theSession.ListingWindow
14        lw.Open
15
16        children = workPart.ComponentAssembly.RootComponent.GetChildren()
17
18        For i = 0 to ubound(children)
19            lw.WriteLine(children(i).GetStringAttribute("DB_PART_NO"))
20
21            Dim child_pt As Point3d
22            Dim child_mt As Matrix3x3
23
24            children(i).GetPosition(child_pt, child_mt)
25
26            lw.WriteLine("pt X, Y, Z  :")
27            lw.WriteLine(child_pt.X & ", " & child_pt.Y & ", " & child_pt.Z)
28
29            lw.WriteLine("mt :")
30            lw.WriteLine(child_mt.Xx & child_mt.Xy & child_mt.Xz)
31            lw.WriteLine(child_mt.Yx & child_mt.Yy & child_mt.Yz)
32            lw.WriteLine(child_mt.Zx & child_mt.Zy & child_mt.Zz)
33        Next
34    End Sub
35
36End Module

関連記事