Page 1 of 1

Several stages outputs using python

Posted: Mon May 31, 2021 1:40 pm
by mmc
Hi!
I am trying to obtain the displacement of a node from a pushover analysis. However, I want to obtain the displacements for the two stages I have in the model: the gravitational and the horizontal. I have only been able to plot for the displacements for just one stage, either the gravitational or the horizontal. Is it possible to obtain them for both stages?
Regards

Code: Select all

# create evaluation options
# here we want to extract data for all steps of the last stage
all_stages = db.getStageIDs() # get all model stages
last_stage = all_stages[1] # get the last stage (pushover)
all_steps = db.getStepIDs(last_stage) # get all steps of the last stage
all_times = db.getStepTimes(last_stage) # get all step times of the last stage
# initialize the evaluation options with the last stage
opt = MpcOdbVirtualResultEvaluationOptions()
opt.stage = last_stage

Re: Several stages outputs using python

Posted: Mon May 31, 2021 2:04 pm
by STKO Team
Of course you can,
Just create the evaluation options at the beginning, and perform a loop though all the stages:

Code: Select all

# create evaluation options
opt = MpcOdbVirtualResultEvaluationOptions()
# here we want to extract data for all steps of the current stage
all_stages = db.getStageIDs() # get all model stages
# if you want to extract results from all stages, just do a loop
for stage_id in all_stages:
	# set the current stage into the evaluation options
	opt.stage = stage_id
	all_steps = db.getStepIDs(stage_id) # get all steps of the current stage
	all_times = db.getStepTimes(stage_id) # get all step times of the current stage
	# go on with your processing here...

Re: Several stages outputs using python

Posted: Tue Jun 01, 2021 7:03 am
by mmc
Hi.
I am not sure to understand that... I have added your code but an error appears... Should I also change the loop that it is below what I have written?

Re: Several stages outputs using python

Posted: Tue Jun 01, 2021 10:35 am
by STKO Team
Here is the working file:
Rec_nodal disp mastnod.zip
(1.38 KiB) Downloaded 185 times
The main error was that you should have put your old script where I wrote: "# go on with your processing here...".
That is, you need 2 nested loops, the outer loop for the stages, and the inner loop for the steps of the current stage.

In the webinar example, I did only 1 loop (the inner one) because I was considering only the last stage.
Let me know if you need further explanations.