Setting "Move Component" dialog window options with NX Open

Hello,
I want to set "Move Component" dialog window options by journal.
"Move Selected Components Only" box has to be always unticked and the collision action has to be set to "Highlight collision".
The journal can be triggered by some other action.
I tried to record a journal but these options seem to be not settable with NX Open.
Is there any way to do this?
I currently use NX 8.5 but I have also tried it in NX 11 and apparently not much changed in handling these options.
I will appreciate all the help you can give.

These options are controlled by "dialog memory". If you set the options that you want, move a component, and press "Ok"; the options will be saved and will be set the next time you open the dialog.

I don't know of any NXOpen API commands that will set these options for you, but the dialog memory file is essentially a plain text XML file. If you figure out the syntax required for your desired options, you can edit any user's file to add the options as the "default" value. I'm currently using Windows 7, the dialog memory file can be found at {user}\AppData\Local\Siemens\NX{version}\DialogMemory.dlx.

Hi
I would like to rotate a cylinder on its own axis.
I have recorded a journal and tried editing them.
Say i have an Cylinder
1.I Select the part to be rotated
2.I Select a face-for assigning an Axis (Direction)i.e along its axis
3.Set an Angle for rotation .As its a recored journal i did for 45 degrees(Let us not worry for that now).

Still doesn't work .Please suggest.

Here is my code
' NX 8.0.0.25
' Journal created by Dinesh on Sat Apr 01 18:16:08 2017 India Standard Time
'
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim mySelectedObject As NXObject
Dim part1 As NXOpen.Assemblies.Component = Nothing
If SelectComponent(part1) = Selection.Response.Cancel Then
Exit Sub
End If
Dim face1 as face
If SelectAnObject("Hey, select something", _
mySelectedObject) = Selection.Response.Cancel Then
Exit Sub
End If

Dim body1 as body
If SelectAObject("Hey, select something", _
mySelectedObject) = Selection.Response.Cancel Then
Exit Sub
End If

Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim componentPositioner1 As Positioning.ComponentPositioner
componentPositioner1 = workPart.ComponentAssembly.Positioner

componentPositioner1.ClearNetwork()

Dim arrangement1 As Assemblies.Arrangement = CType(workPart.ComponentAssembly.Arrangements.FindObject("Arrangement 1"), Assemblies.Arrangement)

componentPositioner1.PrimaryArrangement = arrangement1

componentPositioner1.BeginMoveComponent()

Dim network1 As Positioning.Network
network1 = componentPositioner1.EstablishNetwork()

Dim componentNetwork1 As Positioning.ComponentNetwork = CType(network1, Positioning.ComponentNetwork)

componentNetwork1.MoveObjectsState = True

Dim nullAssemblies_Component As Assemblies.Component = Nothing

componentNetwork1.DisplayComponent = nullAssemblies_Component

componentNetwork1.NetworkArrangementsMode = Positioning.ComponentNetwork.ArrangementsMode.Existing

componentNetwork1.RemoveAllConstraints()

Dim movableObjects1(0) As NXObject
Dim component1 As Assemblies.Component = CType(workPart.ComponentAssembly.RootComponent.FindObject("COMPONENT 1 1"), Assemblies.Component)

movableObjects1(0) = component1
componentNetwork1.SetMovingGroup(movableObjects1)

componentNetwork1.Solve()

theSession.SetUndoMarkName(markId1, "Move Component Dialog")

componentNetwork1.MoveObjectsState = True

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Move Component Update")

' ----------------------------------------------
' Dialog Begin Move Component
' ----------------------------------------------
componentNetwork1.Solve()

componentPositioner1.ClearNetwork()

Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.AddToDeleteList(componentNetwork1)

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId2)

Dim network2 As Positioning.Network
network2 = componentPositioner1.EstablishNetwork()

Dim componentNetwork2 As Positioning.ComponentNetwork = CType(network2, Positioning.ComponentNetwork)

componentNetwork2.MoveObjectsState = True

componentNetwork2.DisplayComponent = nullAssemblies_Component

componentNetwork2.NetworkArrangementsMode = Positioning.ComponentNetwork.ArrangementsMode.Existing

componentNetwork2.RemoveAllConstraints()

Dim movableObjects2(0) As NXObject
movableObjects2(0) = component1
componentNetwork2.SetMovingGroup(movableObjects2)

componentNetwork2.Solve()

Dim scaleAboutPoint1 As Point3d = New Point3d(31.7272274231921, 4.56350531429475, 0.0)
Dim viewCenter1 As Point3d = New Point3d(-31.727227423192, -4.56350531429475, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(0.8, scaleAboutPoint1, viewCenter1)

Dim scaleAboutPoint2 As Point3d = New Point3d(39.65903427899, 5.70438164286843, 0.0)
Dim viewCenter2 As Point3d = New Point3d(-39.65903427899, -5.70438164286842, 0.0)
workPart.ModelingViews.WorkView.ZoomAboutPoint(0.8, scaleAboutPoint2, viewCenter2)

Dim scalar1 As Scalar
scalar1 = workPart.Scalars.CreateScalar(0.500561055056223, Scalar.DimensionalityType.None, SmartObject.UpdateOption.AfterModeling)

Dim scalar2 As Scalar
scalar2 = workPart.Scalars.CreateScalar(0.666645738204682, Scalar.DimensionalityType.None, SmartObject.UpdateOption.AfterModeling)

Dim point1 As Point
point1 = workPart.Points.CreatePoint(face1, scalar1, scalar2, SmartObject.UpdateOption.AfterModeling)

Dim direction1 As Direction
direction1 = workPart.Directions.CreateDirection(face1, Sense.Forward, SmartObject.UpdateOption.AfterModeling)

Dim face2 As Face = CType(component1.FindObject("PARTIAL_PROTO#.Bodies|Body8|HANDLE R-2766"), Face)

Dim nXObject1 As NXObject
Dim xform1 As Xform
xform1 = workPart.Xforms.CreateExtractXform(face2, SmartObject.UpdateOption.AfterModeling, False, nXObject1)

Dim direction2 As Direction
direction2 = workPart.Directions.CreateDirection(direction1, xform1, SmartObject.UpdateOption.AfterModeling)

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Angle")

Dim loaded1 As Boolean
loaded1 = componentNetwork2.IsReferencedGeometryLoaded()

componentNetwork2.BeginDrag()

Dim translation1 As Vector3d = New Vector3d(0.0, 0.0, 0.0)
Dim rotation1 As Matrix3x3
rotation1.Xx = 0.985401278333885
rotation1.Xy = -0.0637396572399425
rotation1.Xz = -0.157865692133787
rotation1.Yx = -0.0637396572399425
rotation1.Yy = 0.721705502852663
rotation1.Yz = -0.689259329459616
rotation1.Zx = 0.157865692133787
rotation1.Zy = 0.689259329459616
rotation1.Zz = 0.707106781186548
componentNetwork2.DragByTransform(translation1, rotation1)

componentNetwork2.EndDrag()

componentNetwork2.ResetDisplay()

componentNetwork2.ApplyToModel()

componentNetwork2.Solve()

componentPositioner1.ClearNetwork()

Dim nErrs3 As Integer
nErrs3 = theSession.UpdateManager.AddToDeleteList(componentNetwork2)

Dim nErrs4 As Integer
nErrs4 = theSession.UpdateManager.DoUpdate(markId2)

Dim network3 As Positioning.Network
network3 = componentPositioner1.EstablishNetwork()

Dim componentNetwork3 As Positioning.ComponentNetwork = CType(network3, Positioning.ComponentNetwork)

componentNetwork3.MoveObjectsState = True

componentNetwork3.DisplayComponent = nullAssemblies_Component

componentNetwork3.NetworkArrangementsMode = Positioning.ComponentNetwork.ArrangementsMode.Existing

componentNetwork3.RemoveAllConstraints()

Dim movableObjects3(0) As NXObject
movableObjects3(0) = component1
componentNetwork3.SetMovingGroup(movableObjects3)

componentNetwork3.Solve()

Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Move Component")

componentNetwork3.Solve()

componentPositioner1.ClearNetwork()

Dim nErrs5 As Integer
nErrs5 = theSession.UpdateManager.AddToDeleteList(componentNetwork3)

Dim nErrs6 As Integer
nErrs6 = theSession.UpdateManager.DoUpdate(markId2)

componentPositioner1.DeleteNonPersistentConstraints()

Dim nErrs7 As Integer
nErrs7 = theSession.UpdateManager.DoUpdate(markId2)

theSession.DeleteUndoMark(markId4, Nothing)

theSession.SetUndoMarkName(markId1, "Move Component")

componentPositioner1.EndMoveComponent()

Dim nullAssemblies_Arrangement As Assemblies.Arrangement = Nothing

componentPositioner1.PrimaryArrangement = nullAssemblies_Arrangement

theSession.DeleteUndoMark(markId2, Nothing)

theSession.DeleteUndoMark(markId3, Nothing)

End Sub

Function SelectComponent(ByRef selObj As TaggedObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim message As String = "Select component to reset position"
Dim title As String = "Select a Component"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_component_type
.Subtype = UFConstants.UF_all_subtype
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(message, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Function SelectAnObject(prompt As String, _
ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.Faces, _
Selection.SelectionType.Edges}

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)

If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Function SelectAObject(prompt As String, _
ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Faces, _
Selection.SelectionType.Edges, _
Selection.SelectionType.Features}

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj, cursor)

If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function
End Module

I've not yet had time to work through your code; are you having trouble with the code to perform the rotation or are you having trouble finding the axis of rotation?

Hi
I am finding trouble in rotating a part say a cylinder along its centre axis.
Below is the code i got from GTAC for rotating a part along its own axis.
But still it doesn't rotate my part(ie cylinder placed anywhere in the space)
about its centre axis.

I had even aligned my part's WCS along its centre axis.

Please suggest .Could you please help me in modifying the below code as the above one is bit complicated as it was recorded and then modified.Please clarify

Option Strict Off

Imports System
Imports System.Math

Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module rotateSelectedComponentAboutItsOwnXAxis

Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()

Sub Main()

Dim comp As Assemblies.Component = Nothing
Dim ac As Assemblies.ComponentAssembly = _
theSession.Parts.Work.ComponentAssembly()

Do
comp = SelectAComponent("Rotate 90 degrees about X")
If comp IsNot Nothing Then
theSession.SetUndoMark(Session.MarkVisibility.Visible, _
"Rotate Component")

Dim origin As Point3d
Dim orientation As Matrix3x3
comp.GetPosition(origin, orientation)

Dim Xaxis As Vector3d = New Vector3d(orientation.Xx, _
orientation.Xy, orientation.Xz)
displayConehead(origin, Xaxis)

Dim comp_mx As Double() = _
convertMatrix3x3ToDoubleArray(orientation)
ufs.Mtx3.OrthoNormalize(comp_mx)
Dim matrix_id As NXOpen.Tag

ufs.Csys.CreateMatrix(comp_mx, matrix_id)
Dim comp_origin As Double() = _
convertPoint3dToDoubleArray(origin)
Dim csys_id(0) As NXOpen.Tag

ufs.Csys.CreateTempCsys(comp_origin, matrix_id, csys_id(0))
Dim comp_xaxis As Double() = convertVector3dToDoubleArray(Xaxis)

Dim rot_mx(11) As Double
Dim resp As Integer

ufs.Trns.CreateRotationMatrix(comp_origin, comp_xaxis, 90, _
rot_mx, resp)

ufs.Trns.TransformObjects(rot_mx, csys_id, 1, 1, 0, 2, _
Nothing, Nothing, resp)
ufs.Csys.AskCsysInfo(csys_id(0), matrix_id, comp_origin)
Dim comp_orientation(8) As Double

ufs.Csys.AskMatrixValues(matrix_id, comp_orientation)

ufs.Assem.RepositionInstance( _
ufs.Assem.AskInstOfPartOcc(comp.Tag), _
comp_origin, comp_orientation)
End If
Loop While comp IsNot Nothing

End Sub

Function SelectAComponent(ByVal prompt As String) As Assemblies.Component

Dim ui As UI = GetUI()
Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_component_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim obj As NXObject = Nothing
Dim cursor As Point3d = Nothing

ui.SelectionManager.SelectObject(prompt, "Select a component", _
Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, obj, cursor)

Return obj

End Function

Sub displayConehead(ByVal origin As Point3d, ByVal direction As Vector3d)

Dim loc() As Double = {origin.X, origin.Y, origin.Z}
Dim dir() As Double = {direction.X, direction.Y, direction.Z}

ufs.Disp.Conehead(UFConstants.UF_DISP_ALL_ACTIVE_VIEWS, loc, dir, 0)

End Sub

Function convertPoint3dToDoubleArray(ByVal pt As Point3d) As Double()
Dim da As Double() = {pt.X, pt.Y, pt.Z}
Return da
End Function

Function convertVector3dToDoubleArray(ByVal pt As Vector3d) As Double()
Dim da As Double() = {pt.X, pt.Y, pt.Z}
Return da
End Function

Function convertMatrix3x3ToDoubleArray(ByVal mat As Matrix3x3) As Double()

Dim mtx() As Double = {mat.Xx, mat.Xy, mat.Xz, mat.Yx, mat.Yy, _
mat.Yz, mat.Zx, mat.Zy, mat.Zz}

Return mtx

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module

"Below is the code i got from GTAC for rotating a part along its own axis.
But still it doesn't rotate my part(ie cylinder placed anywhere in the space)
about its centre axis.

I had even aligned my part's WCS along its centre axis."

The code works by rotating the component about the component part's absolute X axis, moving your WCS won't change the rotation axis. Note that if your component has associative constraints applied to it, it may not be free to rotate.

If you want to modify this code to your purposes, you will need to supply your desired "origin" and "axis" values to the .CreateRotationMatrix method.

Hi
Can you give me an example of such or if you have one earlier please share the same.I have tried enough for getting one.I still ended up with no use.
Can you please give me one say my cylinder origin is at (0,0,0)
and its axis is in between all three major axis.

There is code in the link below that allows a user to choose a vector (see the SpecifyVector function). If you want the user to interactively choose a vector, this code can be used almost "as-is". If you want the journal to automatically find the vector, you will need to formulate a strategy to find the desired axis.

http://nxjournaling.com/comment/1797#comment-1797

Hi
Thanks for the feedback.

I guess i need the below code alone for selecting the face and creating the vector.

Function SpecifyVector(ByVal prompt As String) As Vector3d

Dim theUISession As UI = UI.GetUI()

Dim direction(2) As Double
Dim origin(2) As Double
Dim response As Integer

theUISession.LockAccess()
theUfSession.Ui.SpecifyVector(prompt, UFConstants.UF_UI_INFERRED, UFConstants.UF_UI_DISP_TEMP_VECTOR, direction, origin, response)
theUISession.UnlockAccess()

If response <> UFConstants.UF_UI_OK Then
Return Nothing
End If

Dim outputDir As Vector3d
outputDir.X = direction(0)
outputDir.Y = direction(1)
outputDir.Z = direction(2)

Return outputDir

End Function

Function PlanarFaceNormal(ByVal planarFace As Face) As Vector3d

'get normal direction of given face
Dim param() As Double = {0, 0}
Dim pt(2) As Double
Dim u1(2) As Double
Dim v1(2) As Double
Dim u2(2) As Double
Dim v2(2) As Double
Dim unitNormal(2) As Double
Dim radii(1) As Double
theUfSession.Modl.AskFaceProps(planarFace.Tag, param, pt, u1, v1, u2, v2, unitNormal, radii)

Dim faceNormal As New Vector3d(unitNormal(0), unitNormal(1), unitNormal(2))
Return faceNormal

End Function

Function PlanarFaceMidPoint(ByVal planarFace As Face) As Point3d

Dim uvMinMax(3) As Double
theUfSession.Modl.AskFaceUvMinmax(planarFace.Tag, uvMinMax)

Dim ptMin(2) As Double
Dim ptMax(2) As Double

'get mid point of given face
Dim param() As Double = {(uvMinMax(0) + uvMinMax(1)) / 2, (uvMinMax(2) + uvMinMax(3)) / 2}
Dim pt(2) As Double
Dim u1(2) As Double
Dim v1(2) As Double
Dim u2(2) As Double
Dim v2(2) As Double
Dim unitNormal(2) As Double
Dim radii(1) As Double
theUfSession.Modl.AskFaceProps(planarFace.Tag, param, pt, u1, v1, u2, v2, unitNormal, radii)

Dim midPt As New Point3d(pt(0), pt(1), pt(2))
Return midPt

End Function

Once the vector direction is assigned using above code , i have to loop this with my earlier code as its direction rather than assigning it the global axis.

I hope in right and coming back to your earlier post will running this remove all my associative constraints.If yes are there ways of solving it.

Please suggest.

"I hope in right and coming back to your earlier post will running this remove all my associative constraints.If yes are there ways of solving it."

None of the code listed in this thread will remove assembly constraints. The code to move the component will only work if the component has a "degree of freedom" to rotate about the desired axis.

If you want/need to remove the constraints from a component; the component object has the .GetConstraints method that will give you all the constraints directly connected to the component. You can then delete the constraints that you no longer want.

Thanks

I am still struggling in linking the selected vector using the function with

' This is the math to set up to rotate 90 degrees about the absolute Y axis:
Dim absY() As Double = {0, 1, 0}
Dim mtx(8) As Double
theUFSession.Mtx3.RotateAboutAxis(absY, (PI / 4), mtx)
Dim rotate_90 As Matrix3x3 = convertToMatrix3x3(mtx)
Dim translate_0 As Vector3d = New Vector3d(0.0, 0.0, 0.0)

'Show the user the vector the rotation will be around
Dim abs_origin As Point3d = New Point3d(0, 0, 0)
Dim abs_y As Vector3d = New Vector3d(0, 1, 0)
displayLabeledConehead(abs_origin, abs_y, "+Y")

Do
comp = SelectAComponent("Rotate 90 degrees about +Y")

If comp IsNot Nothing Then
mark1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Rotate Component")

Dim movableObjects() As NXObject = {comp}
componentNetwork1.SetMovingGroup(movableObjects)
componentNetwork1.DragByTransform(translate_0, rotate_90)
componentNetwork1.Solve()

End If
Loop While comp IsNot Nothing

The complete code

Option Strict Off
Imports System
Imports System.Math

Imports NXOpen
Imports NXOpen.UF

Module NXJournal

Dim theSession As Session = Session.GetSession()
Dim theUFSession As UFSession = UFSession.GetUFSession()

Sub Echo(ByVal output As String)
theSession.ListingWindow.Open()
theSession.ListingWindow.WriteLine(output)
theSession.LogFile.WriteLine(output)
End Sub

Sub Main()

Dim comp As Assemblies.Component = Nothing
Dim componentPositioner1 As Positioning.ComponentPositioner = theSession.Parts.Work.ComponentAssembly.Positioner

Dim network1 As Positioning.Network
network1 = componentPositioner1.EstablishNetwork()

Dim componentNetwork1 As Positioning.ComponentNetwork = CType(network1, Positioning.ComponentNetwork)
Dim mark1 As Session.UndoMarkId = Nothing

' This is the math to set up to rotate 90 degrees about the absolute Y axis:
Dim absY() As Double = {0, 1, 0}
Dim mtx(8) As Double
theUFSession.Mtx3.RotateAboutAxis(absY, (PI / 4), mtx)
Dim rotate_90 As Matrix3x3 = convertToMatrix3x3(mtx)
Dim translate_0 As Vector3d = New Vector3d(0.0, 0.0, 0.0)

'Show the user the vector the rotation will be around
Dim abs_origin As Point3d = New Point3d(0, 0, 0)
Dim abs_y As Vector3d = New Vector3d(0, 1, 0)
displayLabeledConehead(abs_origin, abs_y, "+Y")

Do
comp = SelectAComponent("Rotate 90 degrees about +Y")

If comp IsNot Nothing Then
mark1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Rotate Component")

Dim movableObjects() As NXObject = {comp}
componentNetwork1.SetMovingGroup(movableObjects)
componentNetwork1.DragByTransform(translate_0, rotate_90)
componentNetwork1.Solve()

End If
Loop While comp IsNot Nothing

theSession.UpdateManager.AddToDeleteList(componentNetwork1)
theSession.UpdateManager.DoUpdate(mark1)

End Sub

Sub displayLabeledConehead(ByVal origin As Point3d, ByVal direction As Vector3d, ByVal label As String)

Dim loc() As Double = {origin.X, origin.Y, origin.Z}
Dim dir() As Double = {direction.X, direction.Y, direction.Z}

theUFSession.Disp.LabeledConehead(UFConstants.UF_DISP_ALL_ACTIVE_VIEWS, loc, dir, 0, label)

End Sub

Function convertToMatrix3x3(ByVal mtx As Double()) As Matrix3x3

Dim mx As Matrix3x3
With mx
.Xx = mtx(0)
.Xy = mtx(1)
.Xz = mtx(2)
.Yx = mtx(3)
.Yy = mtx(4)
.Yz = mtx(5)
.Zx = mtx(6)
.Zy = mtx(7)
.Zz = mtx(8)
End With

Return mx

End Function

Function convertMatrix3ToMatrix3x3(ByVal mtx As VectorArithmetic.Matrix3) As Matrix3x3

Dim mx As Matrix3x3
With mx
.Xx = mtx.m(0)
.Xy = mtx.m(1)
.Xz = mtx.m(2)
.Yx = mtx.m(3)
.Yy = mtx.m(4)
.Yz = mtx.m(5)
.Zx = mtx.m(6)
.Zy = mtx.m(7)
.Zz = mtx.m(8)
End With

Return mx

End Function

Function SelectAComponent(ByVal prompt As String) As Assemblies.Component

Dim mask(0) As Selection.MaskTriple
With mask(0)
.Type = UFConstants.UF_component_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim obj As NXObject = Nothing
Dim cursor As Point3d = Nothing

UI.GetUI.SelectionManager.SelectObject(prompt, "Select a component", _
Selection.SelectionScope.WorkPart, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, mask, obj, cursor)

Return obj

End Function

Function SpecifyVector(ByVal prompt As String) As Vector3d

Dim theUISession As UI = UI.GetUI()

Dim direction(2) As Double
Dim origin(2) As Double
Dim response As Integer

theUISession.LockAccess()
theUfSession.Ui.SpecifyVector(prompt, UFConstants.UF_UI_INFERRED, UFConstants.UF_UI_DISP_TEMP_VECTOR, direction, origin, response)
theUISession.UnlockAccess()

If response <> UFConstants.UF_UI_OK Then
Return Nothing
End If

Dim outputDir As Vector3d
outputDir.X = direction(0)
outputDir.Y = direction(1)
outputDir.Z = direction(2)

Return outputDir

End Function
Function PlanarFaceNormal(ByVal planarFace As Face) As Vector3d

'get normal direction of given face
Dim param() As Double = {0, 0}
Dim pt(2) As Double
Dim u1(2) As Double
Dim v1(2) As Double
Dim u2(2) As Double
Dim v2(2) As Double
Dim unitNormal(2) As Double
Dim radii(1) As Double
theUfSession.Modl.AskFaceProps(planarFace.Tag, param, pt, u1, v1, u2, v2, unitNormal, radii)

Dim faceNormal As New Vector3d(unitNormal(0), unitNormal(1), unitNormal(2))
Return faceNormal

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module

In the code that you just posted, it appears that you want to rotate the component about the assembly file's absolute +Y axis. Is this the case? What exactly are you trying to accomplish?

In the code that you just posted, it appears that you want to rotate the component about the assembly file's absolute +Y axis. Is this the case? What exactly are you trying to accomplish?

I am trying to rotate the component about the selected vector .I had used the same code from GTAC thats the reason you find it as about Y axis.

My case is simple rotate the component ( a solid cylinder in an assembly)
about the selected vector.