FeResPost Web Site                     FeResPost Online User Manual

VII.1.1.1 Using component with python

The file “COMEX/EX01/testClaCom.py” contains the python program lines for automation of CLA calculations with python. One gives below some explanation about how the program works.

First, some python standard packages must be imported to allow the OLE automation to be used in the program. Therefore, the following statements are added at the beginning of the program:

         import sys  
         import win32con  
         from win32com.client import Dispatch, constants  
      

Then the program defines several methods that are used in the main program:

No “main” function is defined in the program. Instead, the last lines of the program file contain the instructions that perform the main analysis.

First the component must be accessed and a ClaDb object created and initialized. This is done as follows:

         frpApp = Dispatch("FeResPost_3_4_0.Application")  
         db=frpApp.newObject("ClaDb")  
         db.readNeutral("test.ndf")  
      

Note that the access to the application requires the full name of the application that includes the version identification. This means that the name will have to be changed if another version of the component is used. The initialization of the ClaDb object involves the reading of “test.ndf” neutral data file.

The output of the results is done in a disk file:

         os=file("testClaCom_py.txt","w")  
      

Note that the use of iterators with python is easy. For those who know python, to understand the following lines should not be a problem:

         for lamId in db.iter_laminateId:  
            printLamProperties(db,os,lamId)  
            for loadId in db.iter_loadId:  
               printLoadResponse(db,os,lamId,loadId,0.0,criteria)  
      

One first makes a loop on the laminates and prints their properties. Then, inside the loop on the laminates, a loop on the loads stored in the dataBase is done and the laminate load response is calculated and printed. The criteria that are calculated are: “TsaiHill”, “Ilss” and “YamadaSun”.

When the program is run, the FeResPost component application window exhibits the number of component objects referenced, and the number of references. You may stop the program at several locations to check this information. (By adding windows message boxes for example.)