I have edited a python script based on an answer on another question but it still does not seem to run. I have a force load which causes a displacement. I want that after a certain amount of displacement, the force becomes zero. This is the code that I have so far based on this previous problem How to run a python script after every time step of a dynamic load in Ansys WB (transient analysis. I appreciate any advice and help:
model=ExtAPI.DataModel.Project.Model
firstAnalysis = model.Analyses[0]
solution = firstAnalysis.Solution
force_246=ExtAPI.DataModel.GetObjectById(246)
for loadstep in loadsteps:
currentAnalysis = firstAnalysis.Duplicate()
# Get the results from the last load step
deformations = [item for item in solution.Children if item.GetType() == Ansys.ACT.Automation.Mechanical.Results.DeformationResults.DeformationResult]
deformation1 = deformations.GetObjectById(53)
for i in dis:
if deformation1 >= 0.058:
force_246.YComponent.Output.SetDiscreteValue(2.2, Quantity(0, "N"))
solution = currentAnalysis.Solution
solution.Solve(True)