Using Python script to overlay voronoi tessellation on mesh

I’m writing a python script to overlay a voronoi tessellation onto a mesh within cubit. It appears the function “cubit.get_block_hexes()” does not work. I do:

id = cubit.get_block_id(“volume”,2)
print id
2

elemList = cubit.get_block_hexes(id) print elemList
()

print len(elemList)
0

Any thoughts?

This method gets hexes that are assigned to a block directly. If you defined the block by volumes it will have no hexes in it. There are a couple of ways around this. You could get the volumes in the blocks and then get the hexes out of the volumes.

std::vector get_volume_hexes(int volume_id);

or you could just add the hexes into the blocks (I would probably suggest the first method)

get_block_hexes( ) will return a list of hexes stored in Block . It appears you are trying to obtain a list of hexes on Volume 2. Use this function instead:

elemList = cubit.get_volume_hexes(id)