Rotation Matrix between CSYS objects
Rotation Matrix between CSYS objects
(OP)
I would like to be able to identify a 4x4 matrix for rotation/tranlation of a CSYS object to another CSYS object. Is this possible with any NX features? Will I need to do some NXOpen coding for this?





RE: Rotation Matrix between CSYS objects
If you have a different end goal in mind, we'll need more info...
www.nxjournaling.com
RE: Rotation Matrix between CSYS objects
RE: Rotation Matrix between CSYS objects
RE: Rotation Matrix between CSYS objects
www.nxjournaling.com
RE: Rotation Matrix between CSYS objects
CODE
'run this journal on the supplied "transform_matrix.prt" (NX 8) 'running it on other parts will result in an error, the journal looks for specific objects in the file Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession() Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim myStartObject As CoordinateSystem For Each tempCsys As CoordinateSystem In workPart.CoordinateSystems If tempCsys.Name = "CSYS_START" Then myStartObject = tempCsys End If Next Dim startPoint As Point3d = myStartObject.Origin Dim startOrientation As NXMatrix = myStartObject.Orientation lw.WriteLine("start point") lw.WriteLine(startPoint.ToString) lw.WriteLine("starting orientation") lw.WriteLine(startOrientation.Element.Xx & ", " & startOrientation.Element.Xy & ", " & startOrientation.Element.Xz) lw.WriteLine(startOrientation.Element.Yx & ", " & startOrientation.Element.Yy & ", " & startOrientation.Element.Yz) lw.WriteLine(startOrientation.Element.Zx & ", " & startOrientation.Element.Zy & ", " & startOrientation.Element.Zz) lw.WriteLine("") Dim myEndObject As CoordinateSystem For Each tempCsys As CoordinateSystem In workPart.CoordinateSystems If tempCsys.Name = "CSYS_END" Then myEndObject = tempCsys End If Next Dim endPoint As Point3d = myEndObject.Origin Dim endOrientation As NXMatrix = myEndObject.Orientation lw.WriteLine("end point") lw.WriteLine(endPoint.ToString) lw.WriteLine("ending orientation") lw.WriteLine(endOrientation.Element.Xx & ", " & endOrientation.Element.Xy & ", " & endOrientation.Element.Xz) lw.WriteLine(endOrientation.Element.Yx & ", " & endOrientation.Element.Yy & ", " & endOrientation.Element.Yz) lw.WriteLine(endOrientation.Element.Zx & ", " & endOrientation.Element.Zy & ", " & endOrientation.Element.Zz) lw.WriteLine("") Dim fromOrigin() As Double = {startPoint.X, startPoint.Y, startPoint.Z} Dim fromXAxis() As Double = {startOrientation.Element.Xx, startOrientation.Element.Xy, startOrientation.Element.Xz} Dim fromYAxis() As Double = {startOrientation.Element.Yx, startOrientation.Element.Yy, startOrientation.Element.Yz} Dim toOrigin() As Double = {endPoint.X, endPoint.Y, endPoint.Z} Dim toXAxis() As Double = {endOrientation.Element.Xx, endOrientation.Element.Xy, endOrientation.Element.Xz} Dim toYAxis() As Double = {endOrientation.Element.Yx, endOrientation.Element.Yy, endOrientation.Element.Yz} Dim mtx4Transform(15) As Double theUfSession.Mtx4.CsysToCsys(fromOrigin, fromXAxis, fromYAxis, toOrigin, toXAxis, toYAxis, mtx4Transform) lw.WriteLine("transform matrix") lw.WriteLine(mtx4Transform(0) & ", " & mtx4Transform(1) & ", " & mtx4Transform(2) & ", " & mtx4Transform(3)) lw.WriteLine(mtx4Transform(4) & ", " & mtx4Transform(5) & ", " & mtx4Transform(6) & ", " & mtx4Transform(7)) lw.WriteLine(mtx4Transform(8) & ", " & mtx4Transform(9) & ", " & mtx4Transform(10) & ", " & mtx4Transform(11)) lw.WriteLine(mtx4Transform(12) & ", " & mtx4Transform(13) & ", " & mtx4Transform(14) & ", " & mtx4Transform(15)) End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination '----Other unload options------- 'Unloads the image immediately after execution within NX 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 'Unloads the image explicitly, via an unload dialog 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly '------------------------------- End Function End Modulewww.nxjournaling.com