Submitted by Alexminsk on Fri, 04/11/2014 - 07:38
Forums:
hi!
How to rotate component, added to Assembly, around its axis.An example would be great!
Thank you!
NXOpen::Part *workPart(theSession->Parts()->Work());
int layer=0;
double origin[3]={0,0,0};
Point3d curs;
curs.X = 0.0; curs.Y = 0.0; curs.Z = 0.0;
Matrix3x3 oMatrix;
oMatrix.Xx=1;oMatrix.Xy=0;oMatrix.Xz=0;
oMatrix.Yx=0;oMatrix.Yy=1;oMatrix.Yz=0;
oMatrix.Zx=0;oMatrix.Zy=0;oMatrix.Zz=1;
NXOpen::PartLoadStatus *loadStatus=NULL;
NXOpen::Assemblies::ComponentAssembly * oCompon = workPart->ComponentAssembly();
NXOpen::Assemblies::Component *pNewComp = oCompon->AddComponent("Part1", "Part1", "new part", curs, oMatrix, layer, &loadStatus);
<.....>
re: rotate component
What exactly do you mean by "its axis"?
Do you need help with code to rotate a component or code to find "its axis"?
For rotating a component, you should be able to record a journal and examine the resulting code. Finding the specific axis you want to rotate about may be the harder part...
to rotate a component
It is necessary to carry out actions similar command NX: "Move-> Transform-> Motion Angle". To Rotate Component in assembly around the axis "Z" added Component.
re: rotate component
Did the journal recorder help, or are you still looking for an answer?
I'm facing the same problem;
I'm facing the same problem; in NX routing I want to rotate a part before it is added.
The journal doesn't help, as the rotation is done using transform + rotation, instead of using the provided AlongCurveAngle:
Vector3d translation2 = new Vector3d(1048.38053196637, -5522.72494620865, -2488.40981552722);
Matrix3x3 rotation1;
rotation1.Xx = 0.718616973778774;
rotation1.Xy = 0.679867185737274;
rotation1.Xz = 0.146185685874903;
rotation1.Yx = -0.409483014875944;
rotation1.Yy = 0.583602382958551;
rotation1.Yz = -0.701235993894502;
rotation1.Zx = -0.562061656337759;
rotation1.Zy = 0.444059532453454;
rotation1.Zz = 0.697780643262677;
transformPathBuilder1.DragByTransform(translation2, rotation1);
I'm Facing Similiar Problem
I am trying to rotate my component after a translation. Every time I run the journal the re set to origin before doing the next transformation. Is there a way of keeping the same position and apply the new rotation or translation from that specific position?
re: move component
What version of NX are you using?
Can you post the code that you have so far (at least the code that moves the component)?
Move Component
NX 9
Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0)
Dim orientation1 As Matrix3x3
orientation1.Xx = 1.0
orientation1.Xy = 0.0
orientation1.Xz = 0.0
orientation1.Yx = 0.0
orientation1.Yy = 1.0
orientation1.Yz = 0.0
orientation1.Zx = 0.0
orientation1.Zy = 0.0
orientation1.Zz = 1.0
Dim stateArray1(0) As Layer.StateInfo
stateArray1(0) = New Layer.StateInfo(91, Layer.State.Selectable)
workPart.Layers.ChangeStates(stateArray1, False)
Dim component1 As Assemblies.Component
component1 = workPart.ComponentAssembly.AddComponent(openFileDialog1.FileName, "SOLID", openFileDialog1.FileName, basePoint1, orientation1, -1, partLoadStatus1, True)
' ----------------------------------------------
' Declaración de Variables
' ----------------------------------------------
'|---DECLARACIÓN DE VARIABLES DE PROGRAMA---|
Dim componentPositioner1 As Positioning.ComponentPositioner
componentPositioner1 = workPart.ComponentAssembly.Positioner
componentPositioner1.ClearNetwork()
Dim network1 As Positioning.Network
network1 = componentPositioner1.EstablishNetwork()
Dim componentNetwork1 As Positioning.ComponentNetwork = CType(network1, Positioning.ComponentNetwork)
componentNetwork1.MoveObjectsState = True
'|---DECLARACIÓN DE LA PIEZA COMO COMPONENTE DE MOVIMIENTO---|
Dim movableObjects1(0) As NXObject
movableObjects1(0) = component1
componentNetwork1.SetMovingGroup(movableObjects1)
componentNetwork1.Solve()
Dim rtubo As Decimal
Dim rdado As Decimal
Dim Posx As Decimal
Dim Posy As Decimal
Dim Posz As Decimal
rtubo = 6.35 'Ingresar radio del tubo
rdado = 35.8 'Ingresar radio del dado
Posx = -144.76771206
Posy = -357.762944745
Posz = 5101.099582427
Dim translation1 As Vector3d = New Vector3d(-Posx, -Posy - rdado - rtubo, -Posz)
componentNetwork1.DragByTranslation(translation1)
After that translation it doesn't matter if its rotation or a subsequent movement it goes back to the original import position, then moves
I'm new to coding so sorry for the messy code
re: move component
I've not tested it yet, but I would suggest calling the .BeginDrag method on the component network before the .DragByTranslation method, then call the .EndDrag and .ApplyToModel methods before attempting another move.