Get next vertex ID and spherical coordinates.

General topics about Trelis/Cubit, such as localization, GUI, etc.

Get next vertex ID and spherical coordinates.

Postby michael.afanasiev » Thu Jul 18, 2013 8:11 am

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.afanasiev
 
Posts: 6
Joined: Thu Jul 18, 2013 8:04 am

Re: Get next vertex ID and spherical coordinates.

Postby csimsoft Moderator » Mon Jul 22, 2013 3:31 pm

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.
csimsoft
csimsoft Moderator
 
Posts: 239
Joined: Tue Feb 14, 2012 5:59 pm
Location: American Fork, UT

Re: Get next vertex ID and spherical coordinates.

Postby michael.afanasiev » Thu Jul 25, 2013 2:33 am

Perfect, thanks! Yes the issue was that I had holes in my ID space from previous entity deletions.
michael.afanasiev
 
Posts: 6
Joined: Thu Jul 18, 2013 8:04 am


Return to General Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron

Search / Mark

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 58 on Mon Jun 26, 2017 4:19 pm

Users browsing this forum: No registered users and 1 guest