Cancel
Showing results for 
Search instead for 
Did you mean: 

FEMAP API in Python - Topics

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

While the basics of writing the FEMAP API through Python are covered extensively in an existing post, this post will explore more targeted applications of the FEMAP API through Python, and highlight issues found with existing methods.

 

Attached as a .txt file is an example Python script created to output minimum or maximum values for selected Elemental vectors across selected Output Sets (FEMAP 11.4, Python 3.4.4). It also highlights an inconsistency in the FEMAP/Python bridge. The Set objects populated in the '.feSelectOutput()' call do not return as type 'Pyfemap.ISet' objects, but 'win32com.client.CDispatch' objects, due to the way these functions are defined.

 

Here's an example of a Set object 'vecSet' populated by a '.feSelectOutput()' call behaving differently from a more typical Set object 'eset'. Notice how the CDispatch set fails if parentheses are used for the '.Count()' method.

eset vs vecSet.png

 

This inconsistency is handled in the attached .Py script by copying/pasting the Set through the clipboard, bringing in the FEMAP Set as a Python List. 

 

Searching the Pyfemap library, it looks like the following methods also return CDispatch objects with similar inconsistency from their Pyfemap counterparts: .NextLoad() .NextLoadDef() .feFileAttachInfo() .feSelectOutputSets() .feSelectOutput() .NextBC() .NextBCDef()

1 REPLY

Replicating FEMAP GUI through Tkinter

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Here's an example of how to create a custom user dialog with Python's Tkinter package. This example replicates the .feSelectOutputSets() dialog, outputting the selection as a Python List. 

 

Tkinter dialogs handle events as they happen, which is why no reentry points are needed for flow control. This makes desiging a flexible, robust interface far easier. Additionally, the interface itself can be built and modified while it is running. A commented out portion of the code will add a button to the interface, which creates other buttons when pressed. A more practical application would be something like creating a number of fields to modify a user-selection of entities all in one window. This example is purely to demonstrate functionality.