Convert tcl code to OpenSeesPy commands#
- opstool.preprocessing.tcl2py(input_file, output_file, prefix='ops', encoding='utf-8', keep_comments=False)[source]#
Convert OpenSees Tcl code to OpenSeesPy format.
Tip
This function supports Tcl syntax and will flatten your Tcl code, including loops, judgments, assignments, proc, etc,.
Do not use assignment statements for OpenSees commands, such as
set ok [analyze 1]
,set lambdaN [eigen 10]
, it will trigger an error! This is because this function does not run the OpenSees command at all.It is recommended to remove analysis related tcl code and keep only commands such as model building and load definition to avoid possible exceptions. The analysis-related python code you can add manually, although this function provides the ability to convert the analysis Tcl code.
Parameters#
- input_filestr
The name of input
.tcl
file.- output_filestr
The name of output
.py
file.- prefixstr, optional
Prefix name of openseespy, by default
ops
. i.e.,import openseespy.opensees as ops
. If None or void str ‘’, the prefix is not used. i.e.,from openseespy.opensees import *
.- encoding: str, optional
file encoding format, by default “utf-8”.
- keep_comments: bool, optional
Comments are preserved, by default False. Note that this parameter will replace all opensees commands in the comment line, if any.