Get next vertex ID and spherical coordinates.

Hello,

I have two questions.

I have several python codes that add several pieces to my model separately. Their usual format is something along the lines of: read in geometry information, convert points to vertices, create curve through vertices, create surface from curve. My problem is that the starting vertex for curve creation changes depending on how many vertices are already in the model.

My question is: is there a way to query cubit from python and return the ID of the next vertex which will be created? If so, is there a similar way to get next curve ID (or surface, or volume)?

Another question is: are there plans to support a spherical coordinate system in Trelis? Or is there already support for this that I have missed?

Thanks very much

Michael Afanasiev
ETH Zürich

Michael,

You can use the following to get the number of entities:

cubit.get_node_count()
cubit.get_edge_count()
cubit.get_tri_count()
cubit.get_quad_count()
cubit.get_tet_count()
cubit.get_hex_count()
cubit.get_pyramid_count()
cubit.get_volume_count()
cubit.get_surface_count()
cubit.get_curve_count()
cubit.get_vertex_count()

Typically, if you are creating geometry in a bottom-up manner, and as long as you don’t have any holes in your id space, this would work.

But if you have holes in your id space, you could use Trelis’ aprepro functionality.

Id(“type”) Returns the ID of the entity most recently created with the specified type. Acceptable types include: “body”, “volume”, “surface”, “curve”, “vertex”, “group”, “node”, “edge”, “quad”, “face”, “tri”, “hex”, “tet”, or “pyramid”.

You can combine this with python:

v1 = cubit.create_vertex(0,0,0)
v2 = cubit.create_vertex(1,0,0)
c1 = cubit.create_curve(v1,v2)
cubit.cmd(’${last_curve_id=Id(“curve”)}’)
my_last_curve_id = cubit.get_aprepro_value_as_string(“last_curve_id”)
print my_last_curve_id

As for supporting spherical coordinate systems in Trelis, there are no plans for that currently.

Perfect, thanks! Yes the issue was that I had holes in my ID space from previous entity deletions.