Mechanical API for "Table" Objects

Mike.Thompson
Mike.Thompson Member, Employee Posts: 327
25 Answers First Anniversary 100 Comments 25 Likes
✭✭✭✭
edited April 11 in Structures

Hello,
Here is an example of a simple API for creating a "Table" object in Mechanical. These are available as of 24.1 release:

TableGroup = Model.AddTableGroup()

Tables = list(TableGroup.Children)
for T in Tables:
try:
ExtAPI.DataModel.Remove(T)
except Exception as e:
pass

Table = TableGroup.AddTable()
TimeEnum = MechanicalEnums.Table.VariableType.Time
TimeClassification = MechanicalEnums.Table.VariableClassification.Independent
PressureEnum=MechanicalEnums.Table.VariableType.Pressure
PressureClassification = MechanicalEnums.Table.VariableClassification.Real

Table.CreateAndAddColumn(TimeEnum, TimeClassification, None, None, 'Time')
Table.CreateAndAddColumn(PressureEnum, PressureClassification, None, None, 'Pressure')
Table.Name = "New Table"
Table.SendToSolver = True
Table.APDLName = "MyTable"

NumRows = Table.RowCount
with Transaction(True):
for i in range(3):
Table.TryInsertRow(NumRows+i,[i+1,i+1])

Tagged: