January 24, 2024 at 2:12 pm
user deleted
Ansys Employee
This is my code for the Input force
import csv
import csv
filePath = 'FilePath'
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)
force_207.Magnitude.Inputs[0].DiscreteValues = [Quantity(time) for time in timesteps]
force_207.Magnitude.Output.DiscreteValues = [Quantity(load) for load in loads]
Â