How to add a table (from file) and assign it to a pressure load?
Erik Kostson
Member, Moderator, Employee Posts: 285
✭✭✭✭
Say we have a pressure depending on x location and time in a csv file . How can we add this using scripting to a table, and then assign that table to a pressure load?
0
Comments
-
Below is one way of doing (change folder location as needed - and rest of script to adapt to needs):
model=ExtAPI.DataModel.Project.Model analysis=model.Analyses[0] # refer to analysis ns=ExtAPI.DataModel.Project.Model.NamedSelections.Children[0] tablegroup=model.AddTableGroup(True) mtable = tablegroup.AddTable() with Transaction(True): filename = r'D:\\timexpress.csv' format = MechanicalEnums.Table.ImportFormat.Delimited settings = Ansys.Mechanical.Table.ImportSettingsFactory.GetSettingsForFormat(format) settings.Delimiter = ',' settings.UseColumn(0, MechanicalEnums.Table.VariableType.Time, MechanicalEnums.Table.VariableClassification.Independent, 's', 'Time') \ .UseColumn(1, MechanicalEnums.Table.VariableType.XCoordinate, MechanicalEnums.Table.VariableClassification.Independent, 'm', 'X Coordinate') \ .UseColumn(2, MechanicalEnums.Table.VariableType.Pressure, MechanicalEnums.Table.VariableClassification.Real, 'Pa', 'Pressure') mtable.Import(filename, format, settings) mtable.Name='mytable' my_press=analysis.AddPressure() my_press.Location=ns my_press.Magnitude = "mytable"
0
This discussion has been closed.