tcl2py

opstool.pre.tcl2py(input_file, output_file, prefix='ops', encoding='utf-8', keep_comments=False)[source]

Convert OpenSees Tcl code to OpenSeesPy Python format.

Note

  • 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.

  • If an encoding error is reported, please use software such as vscode to re-save the file encoding as UTF-8 in advance.

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.