ironpythonansys

How do I insert a tabular data in ANSYS using a Python script?


I was trying to insert a tabular data for displacement in Ansys as follows:

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]')]

I am getting this error:

can't assign to read-only property Inputs of type 'Field'

I was using the same syntax prescribed for forces in the ANSYS ACT developer guide. How can a tabular data be read-only if I can manually input values in the table?

Is there anything wrong with my code? Also, I have tried the tree children method (disp=Model.Analyses[0].Children[5]). This gives the same error.


Solution

  • I just found a way to enter tabular data in ANSYS using Python. For example, If I want to add a tabular displacement, I can do it as follows:

    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]')]