NXOpen.Session.Parts.Work.ComponentAssembly.MoveComponent(component, translation, rotation)
method.
due to the fact that this method does not accept a 4x4 matrix, I have to cut it to 3x3, which causes the Z-axis to be lost.
Currently, I calculate 4x4 rotation matrix, after multiplicate vector of coordinate component and move a component by delta (current coordinates - coordinates from multiplication). But this works if point of rotation and component point is are equal.
Code:
def rotation_matrix(center: List[float], current_rotate: NXOpen.Matrix3x3, new_angleX: int, new_angleY: int):
rotation1 = NXOpen.Matrix3x3()
asin = math.sin(new_angleX)
acos = math.cos(new_angleX)
bsin = math.sin(new_angleY)
bcos = math.cos(new_angleY)
rotX = [
[1, 0, 0, 0],
[0, acos, 0 - asin, 0],
[0, asin, acos, 0],
[0, 0, 0, 1]
]
rotY = [
[bcos, 0, 0-bsin, 0],
[0, 1, 0, 0],
[bsin, 0, bcos, 0],
[0, 0, 0, 1],
]
res = matrixmult(rotX, rotY)
transf = matrixmult([center], res)[0]
rotation1.Xx = res[0][0]
rotation1.Xy = res[0][1]
rotation1.Xz = res[0][2]
rotation1.Yx = res[1][0]
rotation1.Yy = res[1][1]
rotation1.Yz = res[1][2]
rotation1.Zx = res[2][0]
rotation1.Zy = res[2][1]
rotation1.Zz = res[2][2]
return transf1, rotation1
re: rotation matrix
A 3x3 matrix can define a rotation; however, a 4x4 matrix is often used to give more flexibility:
https://en.wikipedia.org/wiki/Rotation_matrix#In_three_dimensions
The .CreateRotationMatrix method may be of use to you.
https://docs.plm.automation.siemens.com/data_services/resources/nx/1872/...
https://docs.plm.automation.siemens.com/data_services/resources/nx/1872/...
The matrix created with the method above can be used with the .TransformObjects method.