Ansys Learning Forum Forums Discuss Simulation General Mechanical Automated Import of Load history data uisng scripts (Python or Mapdl) Reply To: Automated Import of Load history data uisng scripts (Python or Mapdl)

user deleted
Ansys Employee

For anyone looking through this thread in the future

This is the code adapted to componentwise force import (in this case Y direction)

import csv
filePath = 'filepath\\force.csv'
timesteps = [] #Create empty list to store timestep values
loads = [] #Create empty list to store load values
with open(filePath, 'r') as csvFile:
    csvRead = csv.reader(csvFile, delimiter=',')
    next(csvRead) #Skip first line (assumed headers)
    
    for row in csvRead:
        timesteps.append(row[0]) #Populate list with first column's values
        loads.append(row[1]) #Populate list with second column's values
 
#Configure lists
timeUnit = '[sec]' #Timestep unit
loadUnit = '[N]' #Load unit
timesteps = [str(time) + timeUnit for time in timesteps] #Convert values to strings and append unit
loads = [str(load) + loadUnit for load in loads] #Convert values to strings and append unit
#Create load
analysis_104 = DataModel.GetObjectById(207)
force_207 = DataModel.GetObjectById(207)
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = [23]
force_207.Location = selection
force_207.DefineBy = LoadDefineBy.ComponentY
force_207.YComponent.Inputs[0].DiscreteValues = [Quantity(time) for time in timesteps]
force_207.YComponent.Output.DiscreteValues = [Quantity(load) for load in loads]
Â