Return to examples

A Python script for Groups Manipulation

 

 

Purpose of the script

 

The script illustrates the reading of Nastran model from BDF file, of groups from a Patran session file, and of the manipulation of these Groups with FeResPost Python extension.

 

Script

from FeResPost import *
import sys

os=sys.stdout

# Reads the Groups into a Hash :

h=Post.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")
print(h)

# Prints Groups' data :

nbrEntitiesPerLine=8
for id,grp in h.items():
    os.write("Group \"%s\":\n"%id)
    
    nbr=grp.getNbrEntitiesByType("Element")
    os.write("   Nbr Elements: %d"%nbr)
    counter=0
    for id in grp.iter_element():
        if counter%nbrEntitiesPerLine==0:
            os.write("\n      ")
        os.write("%8d"%id)
        counter+=1
    os.write("\n\n")
            
    nbr=grp.getNbrEntitiesByType("MPC")
    os.write("   Nbr MPCs: %d"%nbr)
    counter=0
    for id in grp.iter_mpc():
        if counter%nbrEntitiesPerLine==0:
            os.write("\n      ")
        os.write("%8d"%id)
        counter+=1
    os.write("\n\n")
            
    nbr=grp.getNbrEntitiesByType("Node")
    os.write("   Nbr Nodes: %d"%nbr)
    counter=0
    for id in grp.iter_node():
        if counter%nbrEntitiesPerLine==0:
            os.write("\n      ")
        os.write("%8d"%id)
        counter+=1
    os.write("\n\n")
            
    nbr=grp.getNbrEntitiesByType("CoordSys")
    os.write("   Nbr CoordSys: %d"%nbr)
    counter=0
    for id in grp.iter_coordsys():
        if counter%nbrEntitiesPerLine==0:
            os.write("\n      ")
        os.write("%8d"%id)
        counter+=1
    os.write("\n\n")

 

Explanation

 

The different steps of the Nastran FEM importation are:

 

References

 

More information on this example, and the manual explaining the functions used in this example are given in FeResPost Reference Manual.

 


 

FeResPost Home Page

 

ferespost_gg.gif