- Index
- » Programming
- » Modelica Language
- » How to get variables with complex...
Page Start Prev 1 Next End
How to get variables with complex names from result file
How to get variables with complex names from result file
Apr-01-14 11:07:49
Hello! I'm using following python script to get variables from *.mat result file:
Code:
import OMPython as omp
result_dict = {}
# read all names of variables from "res_filename"
res = omp.execute('readSimulationResultVars("'+res_filename+'")')
# create list of variables' names
temp_vars_list = omp.get(res, 'SET1.Values')[0].split(',')
# delete first and last " symbols
vars_list = [variable[1:-1] for variable in temp_vars_list]
for key in vars_list:
values_list = omp.execute('readSimulationResult("'+res_filename+'", '+key+')')
# delete last value ([:-1]), because it is the same as penultimate
result_dict[key] = omp.get(values_list, 'SET2.Set1')[:-1]
omp.execute('closeSimulationResultFile()')
This code worked well for dcmotor model, but with linear_actuator model it fails to retrieve values for such variables that have brackets, i.e. "(" or ")", in their names.
For example:
variable der(der(mass1.flange_b.s)) or
variable der(der(idealgearr2t1.flangeT.s))
Is it possible to get values of variables with such names?
I tried these:
Code:
readSimulationResult("results.mat", 'der(der(idealgearr2t1.flangeT.s))')
readSimulationResult("results.mat", "der(der(idealgearr2t1.flangeT.s))")
readSimulationResult("results.mat", {der(der(idealgearr2t1.flangeT.s))})
Nothing worked.
Edited by: Zeolite - Apr-01-14 11:08:58
Page Start Prev 1 Next End
- Index
- » Programming
- » Modelica Language
- » How to get variables with complex...
There are 0 guests and 0 other users also viewing this topic