How to change and set up multiple steps via scripting

Erik Kostson
Erik Kostson Member, Employee Posts: 196
50 Answers 100 Comments Photogenic 5 Likes
✭✭✭✭
edited August 27 in Structures

We want to change the number of steps and change the step controls (say number of steps, end time, etc.) for each step, using scripting.

Best Answer

  • Erik Kostson
    Erik Kostson Member, Employee Posts: 196
    50 Answers 100 Comments Photogenic 5 Likes
    ✭✭✭✭
    edited August 27 Answer ✓

    Below is a code that does that:

    numsteps=10
    model=ExtAPI.DataModel.Project.Model
    analysis=model.Analyses[0]
    solution=analysis.Solution
    analysisset=analysis.AnalysisSettings
    
    
    
    i=0
    times=range(1,2*numsteps,2)
    step_index_list = range(1,numsteps+1,1)
    analysisset.StepEndTime=(Quantity(times[len(times)-1], "sec"))
    analysisset.NumberOfSteps=numsteps
    
    with Transaction():
        for step_index in step_index_list:
            analysisset.CurrentStepNumber=step_index
            analysisset.SetAutomaticTimeStepping(step_index, AutomaticTimeStepping.Off)
            analysisset.SetDefineBy(step_index, TimeStepDefineByType.Substeps)
            analysisset.SetNumberOfSubSteps(step_index, 2)
            analysisset.StepEndTime=(Quantity(times[i], "sec"))
            i=i+1
    
This discussion has been closed.