如何使用 Python 脚本在 ANSYS 中插入表格数据?

问题描述

我试图在 Ansys 中插入一个用于位移的表格数据,如下所示:

SlMn = ExtAPI.SelectionManager

SlMn.ClearSelection()

Sel = SlMn.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)

disp=DataModel.AnalysisList[0].Adddisplacement()

Sel.Ids=[25] # ID 25 is an edge

disp.Location=Sel

disp.XComponent.Output.DeFinitionType=VariableDeFinitionType.discrete

disp.YComponent.Output.DeFinitionType=VariableDeFinitionType.discrete

disp.ZComponent.Output.DeFinitionType=VariableDeFinitionType.discrete

disp.YComponent.Inputs=[Quantity('0 [sec]'),Quantity('0.1[sec]'),Quantity('0.2 [sec]'),Quantity('1[sec]')]

我收到此错误

无法分配给只读属性“字段”类型的输入

我使用了 ANSYS ACT 开发人员指南中为力规定的相同语法。如果我可以在表格中手动输入值,表格数据如何成为只读?

我的代码有问题吗?另外,我尝试了树子项方法disp=Model.Analyses[0].Children[5])。这给出了同样的错误

解决方法

我刚刚找到了一种使用 Python 在 ANSYS 中输入表格数据的方法。 例如,如果我想添加一个表格位移,我可以这样做:

SlMn = ExtAPI.SelectionManager
SlMn.ClearSelection()
Sel = SlMn.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
# Displacement
disp=DataModel.AnalysisList[0].AddDisplacement()
Sel.Ids=[25] # an edge where I want to scope
disp.Location=Sel
disp.XComponent.Output.DefinitionType=VariableDefinitionType.Discrete
disp.YComponent.Output.DefinitionType=VariableDefinitionType.Discrete
disp.ZComponent.Output.DefinitionType=VariableDefinitionType.Discrete
disp.DefineBy=LoadDefineBy.Components
disp.YComponent.Inputs[0].DiscreteValues=[Quantity('0 [sec]'),Quantity('0.1[sec]'),Quantity('0.2 [sec]'),Quantity('1[sec]')]
disp.YComponent.Output.DiscreteValues=[Quantity('0 [m]'),Quantity('-0.000001[m]'),Quantity('-0.00002 [m]'),Quantity('-0.1[m]')]