Ansys自定义工具中的Ironpython脚本



我是Python的初学者,我正在使用Ansys自定义工具(ACT(添加我自己的扩展。有没有一种直接的方法可以在变形后用每个节点的坐标填充文件?希望在3行或3列中:x,y,z到目前为止,我只找到了GetNodeValue对象,但它只给了我位移,我需要整个模型的变形坐标。我的第一个想法是将位移添加到初始坐标中,但我没能做到

非常感谢您的帮助

Lara

APDL代码段

在树的解决方案部分添加APDL代码段:

/prep7
UPGEOM,1,1,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

如果你想留在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],result_unit,"m","Length")
deformationNode1[2] = units.ConvertUnit(deformationNode1[2],result_unit,"m","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,"m","Length")   
node1CoorY = units.ConvertUnit(node1.Y,mesh_unit,"m","Length")   
node1CoorZ = units.ConvertUnit(node1.Z,mesh_unit,"m","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

最新更新