如何使用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.Analysis[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]')]

最新更新