Export Mesh in Local Coordinate System
Hello
In mechanical scripting, is there a simple method to get mesh coordinates in a local coordinate system (cartesian).
Do I have to program the transformation myself or can I use some already programmed methods ?
I found something with 4x4 matrix, but I'm too old for that ...
Thanks
Comments
-
Oups sorry
It was quite easy to do with csys.matrix...
Just surprised there is no method to do this nativelybye
0 -
FYI you can use some DPF operators to rotate data to a given CS (matrix).
import mech_dpf
import Ans.DataProcessing as dpfdef RotationMatrixFieldFromCS(CsName):
"""""" CS = ExtAPI.DataModel.GetObjectsByName(CsName)[0] CsMatrix = list(CS.Matrix) TransformMatrix = [CsMatrix[i] for i in [0,3,6,1,4,7,2,5,8]] rot_mat_f = dpf.FieldsFactory.CreateScalarField(1) rot_mat_f.Data = TransformMatrix return rot_mat_f
def RotationOperatorFromCs(CsName, FieldsContainer):
"""
"""
rot_mat_f=RotationMatrixFieldFromCS(CsName)
RotateOp = dpf.operators.geo.rotate_fc() # operator instantiation
RotateOp.inputs.fields_container.Connect(FieldsContainer)
RotateOp.inputs.coordinate_system.Connect(rot_mat_f)
return RotateOpdef AlignFieldToCs(CsName, FieldsContainer):
"""
Take a field and align it to a local CS in Mechanical by its Name
"""
RotateOp=RotationOperatorFromCs(CsName, FieldsContainer)
RotField=RotateOp.outputs.fields_container.GetData()
return RotFielddef ObjByName(Name):
return ExtAPI.DataModel.GetObjectsByName(Name)[0]0 -
Thanks Mike for this method.
I'm not familiar with DPF, but I'll try to learn how to use it.0