NextFEM Python Scripting

Empower structural analysis with Python

NextFEM APIs can be used with Python as well. This plugin helps developers in finding and testing every API instruction, directly in Designer and with immediate effect in the model.

Integrated Python scripting

Integrated Python scripting can be started by the command Tools / Python scripting. It is a web-powered Python scripting engine, able to run scripts and/or code snippets directly from within the program. Below you can see it in action after this sample script has been run.

Samples are available here.

NextFEMpy Python package

We supply the NextFEMpy Python package, which is a NextFEM REST API wrapper in pure Python, to be used with NextFEM Designer or NextFEM Server. It is a complete set of REST API call, wrapped in Python functions, distinguishing between mandatory and optional arguments.

If you’re looking for NextFEMpy source, look into /nextfempy folder. If you’re looking for sample code using nextfempy, look into /samples folder.

Installation instructions

pip install nextfempy

Upgrading instructions

pip install nextfempy --upgrade

Usage

Before using with your local installation of NextFEM Designer, start the plugin REST API Server.

from nextfempy import NextFEMrest
# connect to local copy of NextFEM Designer
nf=NextFEMapiREST.NextFEMrest()

To handle a property:

nf.autoMassInX=False
print(str(nf.autoMassInX))

To call a NextFEM API method:

nf.addOrModifyCustomData("test","Test")
print(nf.getCustomData("test"))

Python Console

The Python Console in NextFEM Designer is accessible in the Plugin tab.

This plugin works only with 64bit version of NextFEM Designer and needs Python3 64bit installed in system. Users must have Python available in the PATH environment variable.

This plugin is formed by two boards:

  1. a Linked board in which every API method affects the model and the viewport. This has Python syntax and some basic functions, but it’s not a complete Python console. In the lower textbox, start typing “” and the available commands will be suggested, as well as their arguments. Arguments between “<” and “>” are optional. API reference can be recalled by pressing Open API reference.
  2. An External board, which is a complete Python terminal. The instance of API (always called nf) is not linked to the model here. You can export the model from linked to external board by the button Export model.

The other controls in this form are associated to the ViewState and undoOps enumerator and with the resize boolean variable as explained above.