NX Journal アセンブリの子部品の位置表示
2019/12/03 categories:NX Journal| tags:NX Journal|VB|
NXジャーナルで子部品の位置を表示するプログラムを作成しました。
VBコード
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