How can I export design point data from optiSLang .omdb file as .json file by script?
Georg Kandler
Member, Employee Posts: 8
✭✭✭
Best Answer
-
You can do this by using the following script in optiSLang python (i.e. inside a python node in optiSLang, using osl_install_dir/optislang-python.cmd, or from within optiSLang postprocessing):
(tested in optiSLang 2023R1, should also work in optiSLang 2022R2)
import os import json # osl specific imports import py_os_design import py_omdb import py_os_parameter import stdcpp_python_export # omdb file you want to export from omdb_file = os.path.join('your_omdb_file.omdb') # json file the design point data should be saved to json_file = os.path.join('design_container.json') # load the data omdb = py_omdb.PyOMDB(omdb_file) params = omdb.parameter_manager designs = omdb.design_container # create a DesignExporter object design_exporter = py_os_design.DesignExporterJson() # perform the export design_exporter(designs, stdcpp_python_export.Path(json_file)) # the exported json will be without indentations # to make it more readable, reload it and save it again with # indentations with open(json_file,'r') as f: data = json.load(f) with open(json_file,'w') as f: f.write(json.dumps(data,indent=2))
6
Answers
-
Successfully used with Ansys 2023R2!
1