Finding centroid of element in python

Hi all

I was wondering if anyone has a method for finding the center coordingates (x,y,z) of an element

I am currently trying this python code but keep getting (0,0,0) as the answer

def write_centroid_coordinates_of_all_tets():
    x_nodes=[]
    y_nodes=[]
    z_nodes=[]
    allelements = cubit.parse_cubit_list("element", "all")
    for counter in range(0,len(allelements)):
        corrds=cubit.get_center_point("element",counter)
        print(corrds)
        x_nodes.append(corrds[0])
        y_nodes.append(corrds[1])
        z_nodes.append(corrds[2])
    return x_nodes , y_nodes , z_nodes

Hi all

I found my error

I should enter the element type not just “element”

this line
allelements = cubit.parse_cubit_list(“element”, “all”)

should say
allelements = cubit.parse_cubit_list(“tet”, “all”)
or
allelements = cubit.parse_cubit_list(“hex”, “all”)

Cheers