问题描述
我是 Python 初学者,正在使用 Ansys 自定义工具 (ACT) 添加我自己的扩展。 有没有一种直接的方法可以在变形后用每个节点的坐标填充文件? 希望在 3 行或列中: x , y , z 到目前为止,我只找到了 GetNodeValue 对象,但它只给了我位移,我需要整个模型的变形坐标。 我的第一个想法是将位移添加到初始坐标,但我没能做到。
非常感谢您的帮助
拉拉
解决方法
APDL 片段
在树的解决方案部分添加一个APDL Snippet:
/prep7
UPGEOM,1,file,rst ! adds the displacements to the nodal coordinates.
cdwrite,geom,nodesAndelements,geom ! Writes node and element data to nodesAndelement.geom
我不确定您是否可以使用 cdwrite 的输出格式,但这是我能想到的最快的解决方案。 如果你想自动化,你必须通过
插入命令片段solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solution
fullPath = "path//to//snippet"
snippet = solution.AddCommandSnippet()
snippet.ImportTextFile(fullPath)
行动
如果你想留在 ACT,可以这样做:
global nodeResults
import units
analysis = ExtAPI.DataModel.Project.Model.Analyses[0]
mesh = analysis.MeshData
# Get nodes
allNodes = mesh.Nodes
# get the result data
reader = analysis.GetResultsData()
# get the deformation result
myDeformation = reader.GetResult("U")
nodeResultsTemp = []
result_unit = myDeformation.GetComponentInfo("X").Unit
for node in allNodes:
# get node deformation and convert values in meter
deformationNode1 = myDeformation.GetNodeValues(node.Id)
deformationNode1[0] = units.ConvertUnit(deformationNode1[0],result_unit,"m","Length")
deformationNode1[1] = units.ConvertUnit(deformationNode1[1],"Length")
deformationNode1[2] = units.ConvertUnit(deformationNode1[2],"Length")
# add node coordinates (in meter) to the displacement
mesh_unit = mesh.Unit
node1 = mesh.NodeById(node.Id)
node1CoorX = units.ConvertUnit(node1.X,mesh_unit,"Length")
node1CoorY = units.ConvertUnit(node1.Y,"Length")
node1CoorZ = units.ConvertUnit(node1.Z,"Length")
deformationNode1[0] = deformationNode1[0]+node1CoorX
deformationNode1[1] = deformationNode1[1]+node1CoorY
deformationNode1[2] = deformationNode1[2]+node1CoorZ
nodeResultsTemp.append([node1.X,node1.Y,node1.Z,deformationNode1[0],deformationNode1[1],deformationNode1[2]])
nodeResults = nodeResultsTemp