Home / Developer
Developer: scripting
Drive the FEA Tool from Python or JavaScript in the console inside the app. The functions below are read from the app's own help list, so this page always matches the version that is live.
Python
import tn
tn.new_model("AS")
tn.add_node(0, 0, 0, "A")
tn.add_node(5, 0, 0, "B")
tn.add_frame("A", "B", "310UB40.4")
tn.set_support("A", "fixed")
tn.add_nodal_load("G", "B", 0, 0, -10, 0, 0, 0)
r = await tn.run("linear")
print(r["cases"])
print(tn.results("reactions", r["cases"][0]))JavaScript
tn.new_model("AS");
tn.add_node(0, 0, 0, "A");
tn.add_node(5, 0, 0, "B");
tn.add_frame("A", "B", "310UB40.4");
tn.set_support("A", "fixed");
tn.add_nodal_load("G", "B", 0, 0, -10, 0, 0, 0);
const r = await tn.run("linear");
print(r.cases);
print(tn.results("reactions", r.cases[0]));Open the app, choose the FEA Tool, then the Script tab. Python runs in the browser (Pyodide), so no account or server is needed; the first run loads the engine once. tn.help() prints this list in the console.
Reference
tn.add_material(name, type, E, nu, rho, fy, fu, fc, alpha, standard, grade, G, nonlinear) [also add_material_from_library, define_material]tn.add_frame_section(name, shape, d, b, tf, tw, t, material) [also add_section, define_section]tn.add_rect_section(name, b, d, material)tn.add_rc_section(name, b, d, material, role, cover, bar_dia, n_bars, tie_dia, tie_spacing, top_bars, bot_bars)tn.add_box_section(name, d, b, t, material)tn.add_pipe_section(name, d, t, material)tn.add_i_section(name, d, b, tf, tw, material)tn.add_auto_select(name, sections) [also add_section_list, add_autoselect]tn.new_model(code, name) [also reset_model]
Start an empty model for a code system (AS, US, CA, EU).tn.set_title(name) [also set_name]tn.add_node(x, y, z, id) [also add_point, add_joint]
Add a node; returns its id.tn.add_frame(i, j, section, id, material, type, role, beta) [also add_member, add_beam, add_column, add_brace, add_line]
Add a frame member between two nodes or points.tn.set_support(nodes, kind) [also add_support, support, set_restraint]
Restrain nodes: fixed, pinned, roller, free or a six-letter code.tn.set_spring(nodes, k) [also add_spring]
Set joint spring stiffnesses.tn.set_release(members, start, end, both) [also set_releases, release, assign_release]tn.set_section(members, name, section) [also assign_section, set_frame_section]tn.assign_material(members, name, material) [also set_material]
Assign a material from a code library.tn.add_area_section(name, type, material, t, tb, modifiers) [also define_area_section, add_shell_section]tn.add_shell(nodes, section, mesh, id, t, material, type, modifiers) [also add_area_shell]tn.add_slab(nodes, section, mesh, id, t, material, modifiers) [also add_floor, add_deck]tn.add_plate(nodes, section, mesh, id, t, material, modifiers) [also add_plate_area]tn.add_wall(nodes, section, mesh, id, t, material, modifiers) [also add_wall_panel]tn.add_membrane(nodes, section, mesh, id, t, material, modifiers) [also add_panel]tn.add_area(nodes, t, material, type, id, section, mesh)
Add a plate or shell from node ids and a thickness.tn.mesh_area(areas, size, by_edge_points, by_frame_intersections) [also set_mesh, mesh]tn.set_modifiers(items, mods, f11, f22, f12, m11, m22, m12, v13, v23, A, As2, As3, J, I22, I33, mass, weight) [also set_area_modifiers, set_frame_modifiers, assign_modifiers]tn.add_load_case(name, type, self_weight) [also add_load_pattern, add_pattern, add_load_cases]
Create a load case with its type and self-weight factor.tn.add_nodal_load(case, node, fx, fy, fz, mx, my, mz) [also add_joint_load, add_point_load]
Apply a force and moment to a node in a case.tn.add_member_load(case, member, kind, dir, w, P, a, b, w2) [also add_beam_load, add_frame_load, add_line_load]
Apply a uniform, point or trapezoidal load on a member.tn.add_joint_pattern(name, A, B, C, D, clip, frame) [also add_pattern_field, define_joint_pattern]tn.add_area_load(case, area, q, dir, kind, face, proj, pattern, hydro, wind) [also add_surface_load, add_shell_load, add_pressure]
Apply a pressure on a plate or shell.tn.add_combo(name, factors, kind) [also add_combination, add_load_combination]
Combine load cases with factors.tn.generate_combos(code, method, replace) [also add_default_combos, default_combos, generate_combinations]tn.replicate(items, mode, dx, dy, dz, n, cx, cy, deg, axis, coord, loads, supports) [also copy, array]tn.divide_frame(member, n, at) [also divide, split_frame]tn.move(items, dx, dy, dz) [also move_nodes, translate]tn.select_by_coordinates(x, y, z, tol, kind, select) [also select_coordinates, select_range]tn.nodes() [also get_nodes, joints]
List the nodes.tn.members() [also get_members, frames]
List the members.tn.areas() [also get_areas, shells]
List the areas.tn.sections()tn.area_sections()tn.materials()tn.model()
Read the whole model as data.tn.delete(items) [also remove, delete_objects]
Delete nodes, members or areas.tn.select(items)
Set the selection.tn.selection() [also get_selection]
Read the selection.tn.refresh()
Redraw the model after script edits.tn.run(analysis, options) [also analyse, analyze]
Run an analysis type and wait for the results.await tn.run("linear") (or "p-delta", "modal", "buckling", "nonlinear", "time-history", "response-spectrum"): runs the analysis and returns { ok, cases, messages }; the view and the panels update
Run an analysis type and wait for the results.tn.results(kind, case, id) [also get_results]
Read displacements, reactions, member forces or area results.tn.reactions(case, node) [also get_reactions]tn.displacements(case, node) [also get_displacements]tn.member_forces(case, member) [also get_member_forces]tn.area_forces(case, area) [also get_area_forces]tn.design(options) [also design_members, check_design]await tn.design(): designs the members for the code (auto-select lists get the lightest passing section) and returns { ok, rows, failing, changed }, rows being { id, section, util, status }await tn.run(analysis="linear", ...) runs the analysis; await tn.design() designs the members; await tn.install("numpy")
Run an analysis type and wait for the results.anastruct.SystemElements(EA, EI): the anastruct interface (Python: from anastruct import SystemElements).
The anastruct interface for Python scripts.
Conventions
- Lengths in metres, forces in kN, stresses in MPa; the code argument of
new_modelsets the section and material libraries. - Load cases are created with
add_load_caseand referred to by name. runreturns the names of the cases it analysed;resultsreads them.