Coreform Cubit 2025.1 User Documentation

Coreform Cubit Python API: Method-Based API

Common Methods

cubit.cmd(input_string)

Pass a command string into Coreform Cubit. Passing a command into Coreform Cubit using this method will result in an immediate execution of the command. The command is passed directly to Coreform Cubit without any validation or other checking.

cubit.cmd("brick x 10")
Parameters:

input_string – Pointer to a string containing a complete Coreform Cubit command

cubit.get_id_string(entity_ids)

Parse a list of integers into a Cubit style id list. Return string will not include carriage returns or line break.

cubit.cmd('sphere radius .5') cubit.cmd('volume 1 copy move x 2 repeat 3') id_list = cubit. parse_cubit_list('volume', 'all') # id_list = [1,2,3,4] # returned id_string is '1 to 4' id_string = cubit.get_id_string(id_list)
Parameters:

entity_ids – tuple of integers return A string representing the id list without line breaks

Type:

list[int]

Returns:

a Cubit stype string of ids

Return type:

str

cubit.init(argv, in_python=True)

Use cubit.init() to initialize Coreform Cubit in a stand-alone python session.

Cubit may be imported into python without starting up the GUI. The path to a licensed version of Coreform Cubit must be specifed and Cubit must be initialized prior accessing the other methods in this API.

The arguments to the init() method are the command line arguments for Coreform Cubit with the addition that the first argument is the program name “cubit”.

The following python script shows an example of initializing and using Coreform Cubit. The key parts are ensuring that the Coreform Cubit libraries are in the path, importing the Coreform Cubit libraries, and calling cubit.init().

import sys   # add Coreform Cubit libraries to your path sys.path.append('/opt/Coreform Cubit/bin')   import cubit   # start cubit - this step is key. Note that: # cubit.init does not require any arguments. # If you do want to provide arguments, you must # provide 2 or more, where the first must # be "cubit", and user args start # as the 2nd argument. # If only one argument is used, it will be ignored. cubit.init(['cubit','-nojournal'])   height = 1.2 blockHexRadius = 0.1732628   #hexagon cubit.cmd(f"create prism height {height} sides 6 radius {blockHexRadius}") #etc . . .  
Parameters:

argv – List of command line start-up directives. A blank list such as [‘’] will suffice. If command parameters are specified, the first item in the list is ignored.

Type:

list[str]

cubit.parse_cubit_list(type, entity_list_string)

Parse a Cubit style entity list into a list of integers Users are allowed to input many variations of entities and IDs for any given command. This routine parses the input and returns a regular list of valid IDs for the specified entity type. For example:

cubit.parse_cubit_list('surface', '1 to 12') cubit.parse_cubit_list('surface', 'with name "myname*"') cubit.parse_cubit_list('surface', 'in volume 5 to 23') cubit.parse_cubit_list('hex', 'in volume 1')
Parameters:
  • type – The specific entity type represented by the list of entities

  • entity_list_string – The string that contains the entity list

Type:

str

Type:

str

Returns:

A list of valid ids for the given type within the specified parameters.

Return type:

tuple[int]

Get Methods

cubit.get_arc_length(curve_id)

Get the arc length of a specified curve

Parameters:

curve_id – ID of the curve

Returns:

Arc length of the curve

Return type:

float

cubit.get_block_name(entity_id)

Get the block name for a given block id.

block_name = cubit.get_block_name(1)
Parameters:

block_id – Id of block in question

Returns:

Block name associated with this block or “” if none

Return type:

str

cubit.get_curve_center(curve_id)

Get the center point of the arc

Parameters:

curve_id – ID of the curve

Returns:

x, y, z center point of the curve

Return type:

tuple[float]

cubit.get_curve_length(curve_id)

Get the length of a specified curve

Parameters:

curve_id – ID of the curve

Returns:

Length of the curve

Return type:

float

cubit.get_curve_radius(curve_id)

Get the radius of a specified arc

Parameters:

curve_id – ID of the curve

Returns:

Radius of the curve

Return type:

float

cubit.get_distance_from_curve_start(x_coordinate, y_coordinate, z_coordinate, curve_id)

Get the distance from a point on a curve to the curve’s start point

Parameters:
  • x – value of the point to measure

  • y – value of the point to measure

  • z – value of the point to measure

  • curve_id – ID of the curve

Type:

float

Type:

float

Type:

float

Returns:

Distance from the xyz to the curve start

Return type:

float

cubit.get_center_point(entity_type, entity_id)

Get the center point of a specified entity.

center_point = cubit.get_center_point("surface", 22)
Parameters:
  • entity_type – Specifies a string representing the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

The x, y, z, coordinates of the center point

Return type:

tuple[float]

cubit.get_common_curve_id(surface_1_id, surface_2_id)

Given 2 surfaces, get the common curve id

Parameters:
  • surface_1_id – The id of one of the surfaces

  • surface_2_id – The id of the other surface

Returns:

The id of the curve common to the two surfaces

Return type:

int

cubit.get_common_vertex_id(curve_1_id, curve_2_id)

Given 2 curves, get the common vertex id

Parameters:
  • curve_1_id – The id of one of the curves

  • curve_2_id – The id of the other curves

Returns:

The id of the vertex common to the two curves, 0 if there is none

Return type:

int

cubit.get_entities(entity_type)

Get all entities of a specified type (including geometry, mesh, etc…).

entity_id_list = cubit.get_entities("volume")
Parameters:

entity_type – Specifies the type of the entity

Returns:

A tuple of ids of the specified geometry type

Return type:

tuple[int]

cubit.get_nearby_entities(entity_type)

Get the list of nearby entities of type curve, surface or volume given a list of the same entity type. For example, given one or more volumes, find all the volumes that are closer than a specified distance.

entity_id_list = cubit.get_nearby_entities("volume")
Parameters:

gtype – "curve", "surface" or "volume"

ent_ids – Find entities close to the entities in this list.

compare_ents – Entities of same type to check against. If empty, will check against all of them.

distance – Maximum distance betwen entities. Optional. Use -1 to compute default tolerance.

Returns:

A list of entities of type gtype that are nearby to ent_ids from the compare_ents list.

Return type:

tuple[int]

cubit.get_entity_color(entity_type, entity_id)

Get the color of a specified entity.

color = cubit.get_entity_color("curve", 33)
Parameters:
  • entity_type – Specifies the type of the entity

  • entity_id – Specifies the id of the entity

Returns:

The color of the entity (r, g, b, a). Note that (0,0,0,0) denotes the default color.

Return type:

tuple[float], length 4

cubit.get_entity_name(entity_type, entity_id, no_default=False)

Get the name of a specified entity Names returned are of two types: 1) user defined names which are actually stored in Coreform Cubit when the name is defined, and 2) ‘default’ names supplied by Coreform Cubit at run-time which are not stored in Cubit. The second variety of name cannot be used to query Coreform Cubit.

name = cubit.get_entity_name("vertex", 22)
Parameters:
  • entity_type – Specifies the type of the entity

  • entity_id – Specifies the id of the entity

  • no_default – True to return an empty string if no name is set

Returns:

The name of the entity

Return type:

str

cubit.get_error_count()

Get the number of errors in the current Coreform Cubit session.

Returns:

The number of errors in the Coreform Cubit session.

Return type:

int

cubit.get_merge_tolerance()

Get the current merge tolerance value

Returns:

The value of the current merge tolerance

Return type:

float

cubit.get_mesh_intervals(geometry_type, entity_id: int) int

Get the interval count for a specified entity.

intervals = cubit.get_mesh_intervals("surface", 12)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

The entity’s interval count

Return type:

int

cubit.get_mesh_scheme(geometry_type, entity_id)

Get the mesh scheme for the specified entity.

scheme = cubit.get_mesh_scheme("surface", 12)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

The entity’s meshing scheme

Return type:

str

cubit.get_mesh_size(geometry_type, entity_id)

Get the mesh size for a specified entity.

mesh_size = cubit.get_mesh_size("volume",2)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

The entity’s mesh size

Return type:

float

cubit.get_surface_area(surface_id)

Get the area of a surface

Parameters:

surface_id – ID of the surface

Returns:

Area of the surface

Return type:

float

cubit.get_surface_centroid(surface_id)

Get the surface centroid for a specified surface

Parameters:

surface_id – ID of the surface

Returns:

surface centroid

Return type:

tuple[float], length 3

cubit.get_surface_normal(surface_id)

Get the surface normal for a specified surface

Parameters:

surface_id – ID of the surface

Returns:

surface normal at the center

Return type:

tuple[float], length 3

cubit.get_surface_normal_at_coord(surface_id, arg2)

Get the surface normal for a specified surface at a location

Parameters:

surface_id – ID of the surface :param coord: array of x,y,z location on surface

Returns:

surface normal at coord

Return type:

tuple[float], length 3

cubit.get_total_volume(volume_list)

Get the total volume for a list of volume ids

Parameters:

volume_list – List of volume ids

Returns:

The total volume of all volumes indicated in the id list

Return type:

float

cubit.get_version()

Get the Coreform Cubit version.

Returns:

A string containing the current version of Coreform Cubit.

Return type:

str

cubit.get_volume_area(volume_id)

Get the area of a volume

Parameters:

volume_id – ID of the volume

Type:

int

Returns:

Area of the volume

Return type:

float

cubit.get_volume_volume(vol_id)

Get the volume of a volume

Parameters:

volume_id – ID of the volume

Type:

int

Returns:

volume

Return type:

float

Query State Methods

cubit.is_merged(geometry_type, entity_id)

Determines whether a specified entity is merged.

state = cubit.is_merged("surface",137)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Return type:

boolean

cubit.is_meshed(geometry_type, entity_id)

Determines whether a specified entity is meshed.

state = cubit.is_meshed("surface",137)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

cubit.is_periodic(geometry_type, entity_id)

Query whether a specified surface or curve is periodic.

result = cubit.is_periodic("surface",22)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

True is entity is periodic, otherwise false

Return type:

boolean

cubit.is_point_contained(geometry_type, entity_id, xyz_point)

Determine if given point is inside, outside, on or unknown the given entity. note that this is typically used for volumes or sheet bodies

Parameters:
  • geom_type – string defining geometry type (volume or body)

  • id – ID of the geometric entity

  • xyz_point – triplet defining the point x,y,z coordinates

Type:

str

Type:

int

Type:

tuple[float], length 3

Returns:

-1 failure, 0 outside, 1, inside, 2 on

Return type:

int

cubit.is_surface_meshable(surface_id)

Check if surface is meshable with current scheme.

Returns:

A boolean indicating whether surface is meshable with current scheme.

Return type:

boolean

cubit.is_surface_planar(surface_id)

Query if the given surface is planar.

Parameters:

surface_id – Specifies the id of the surface

cubit.is_volume_meshable(volume_id)

Check if volume is meshable with current scheme.

Returns:

A boolean indicating whether volume is meshable with current scheme

Return type:

boolean

cubit.is_sheet_body(volume_id)

Query whether a specified volume is a sheet body

Parameters:

volume_id – Id of the volume

Returns:

True if volume is a sheet body, otherwise false

Return type:

boolean

cubit.measure_between_entities(entity_type1, entity_id1, entity_type2, entity_id2)

Returns distance between two geometry entities and their closest points.

dist_info = cubit.measure_between_entities(“curve”, 10, “surface”, 12) dist = dist_info[0] curv_point = [dist_info[1], dist_info[2], dist_info[3]] surf_point = [dist_info[4], dist_info[5], dist_info[6]]
Parameters:
  • entity_type1 – type of first entity

  • entity_id1 – id of first entity

  • entity_type2 – type of second entity

  • entity_id2 – id of second entity

Type:

str, one of “vertex”, “curve”, “surface”, “volume”, “node”, “edge”, “tri”, “face”, “tet”, “hex”, “wedge”, “pyramid”

Returns:

The distance between two entities

Return type:

float

Get ID Methods

cubit.get_id_from_name(name)

Get id for a named entity This routine returns an integer id for the entity whose name is passed in.

entity_id = cubit.get_id_from_name("member_2")
Parameters:

name – Name of the entity to examine return Integer representing the entity

Returns:

The id associated with the given name.

Return type:

str

cubit.get_last_id(entity_type)

Get the id of the last created entity of the given type.

last_id = cubit.get_last_id(“surface”)
Parameters:

entity_type – Type of the entity being queried

Type:

str

Returns:

The id of last created entity

Return type:

int

cubit.get_next_block_id()

Get a next available block id

Returns:

Next available block id

Return type:

int

cubit.get_next_group_id()

Get the next available group id from Coreform Cubit

Returns:

next group id

Return type:

int

cubit.get_next_nodeset_id()

Get a next available nodeset id

Returns:

Next available nodeset id

Return type:

int

cubit.get_next_sideset_id()

Get a next available sideset id

Returns:

Next available sideset id

Return type:

int

Bounding Box Methods

cubit.get_bounding_box(geometry_type, entity_id)

Get the bounding box for a specified entity.

vector_list = cubit.get_bounding_box("surface", 22)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_id – Specifies the id of the entity

Returns:

A tuple of coordinates describing the entity’s bounding box. Ten (10) values will be:

  • [0] = minimum x

  • [1] = maximum x

  • [2] = box x range

  • [3] = minimum y

  • [4] = maximum y

  • [5] = box y range

  • [6] = minimum z

  • [7] = maximum z

  • [8] = box z range

  • [9] = box diagonal length

Return type:

tuple[float], length 10

cubit.get_total_bounding_box(geometry_type, entity_list)

Get the bounding box for a list of entities.

vector_list = cubit.get_total_bounding_box("surface", entity_list)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_list – List of ids associated with geom_type

Returns:

An array of coordinates for the entity’s bounding box.

  • [0] = minimum x

  • [1] = maximum x

  • [2] = box x range

  • [3] = minimum y

  • [4] = maximum y

  • [5] = box y range

  • [6] = minimum z

  • [7] = maximum z

  • [8] = box z range

  • [9] = box diagonal length

Return type:

tuple[float], length 10

cubit.get_tight_bounding_box(geometry_type, entity_list)

Get the tight bounding box for a list of entities.

vector_list = cubit.get_tight_bounding_box("surface", entity_list)
Parameters:
  • geom_type – Specifies the geometry type of the entity

  • entity_list – List of ids associated with geom_type

Returns:

A tuple of center point coordinates and axis definitions.

  • [0] = center x

  • [1] = center y

  • [2] = center z

  • [3] = normalized u component 0

  • [4] = normalized u component 1

  • [5] = normalized u component 2

  • [6] = normalized v component 0

  • [7] = normalized v component 1

  • [8] = normalized v component 2

  • [9] = normalized w component 0

  • [10] = normalized w component 1

  • [11] = normalized w component 2

  • [12] = u length

  • [13] = v length

  • [14] = z length

Return type:

tuple[float], length 15

Mesh Query Methods

cubit.get_closest_node(x_coordinate, y_coordinate, z_coordinate)

Get the node closest to the given coordinates

Parameters:
  • x – coordinate

  • y – coordinate

  • z – coordinate

Type:

float

Type:

float

Type:

float

Returns:

id of closest node, 0 if none found

Return type:

int

cubit.get_connectivity(entity_type, entity_id)

Get the list of node ids contained within a mesh entity.

node_id_list = cubit.get_connectivity("hex", 221)
Parameters:
  • entity_type – The mesh element type

  • entity_id – The mesh element id

Returns:

Tuple of node ids

Return type:

tuple[int]

cubit.get_expanded_connectivity(entity_type, entity_id)

Get the list of node ids contained within a mesh entity, including interior nodes.

node_id_list = cubit.get__expanded_connectivity("hex", 221)
Parameters:
  • entity_type – The mesh element type

  • entity_id – The mesh element id

Returns:

Tuple of all node ids associated with the element, including interior (high-order) nodes

Return type:

tuple[int]

cubit.get_element_type(element_id)

Return the type of a given element

Parameters:

element_id – The element id (i.e. the global element export id)

Returns:

The type

Return type:

str

cubit.get_geometry_owner(entity_type, entity_id)

Get the geometric owner of this mesh element.

geom_owner = cubit.get_geometry_owner("hex", 221)
Parameters:
  • entity_type – The mesh element type

  • entity_id – The mesh element id

Returns:

Name of owner

Return type:

str

cubit.get_nodal_coordinates(node_id)

Get the nodal coordinates for a given node id.

Parameters:

node_id – The node id

Returns:

A tuple containing the x, y, and z coordinates

Return type:

tuple[float], length 3