Cubit Python API 2026.6
Loading...
Searching...
No Matches

Defines a volume object that mostly parallels Cubit's RefVolume class. More...

Inheritance diagram for Volume:
GeomEntity Entity

Public Member Functions

 centroid (self)
 Get the centroid of the Volume.

 
 color (self)
 Get the RGBA color of this Volume entity.

 
 principal_axes (self)
 Retrieve the principal axes of this Volume entity.

 
 principal_moments (self)
 Get the principal moments of the Volume.

 
 set_color (self, value)
 Set the RGBA color of this Volume entity.

 
 volume (self)
 Compute the three-dimensional volume of this Volume entity.

 
- Public Member Functions inherited from GeomEntity
 bodies (self)
 Retrieve bodies contained within the geometry entity.

 
 curves (self)
 Retrieve curves (edges) associated with the geometry entity.

 
 dimension (self)
 Get the topological dimension of the geometry entity.

 
 entity_name (self)
 Retrieve the primary name of the geometry entity.

 
 entity_names (self)
 Retrieve all names assigned to the geometry entity.

 
 is_meshed (self)
 Returns the current mesh state of the GeomEntity.

 
 is_transparent (self)
 Get the transparency state of the geometry entity.

 
 is_visible (self)
 Get the visibility state of the geometry entity.

 
 mesh (self)
 Generates mesh on a GeomEntity and verifies meshing status.

 
 num_names (self)
 Get the count of names assigned to the geometry entity.

 
 remove_entity_name (self, name)
 Remove a specific name from the geometry entity.

 
 remove_entity_names (self)
 Remove all non-default names from the geometry entity.

 
 remove_mesh (self)
 Remove any mesh associated with the geometry entity.

 
 set_entity_name (self, name)
 Assign a name to the geometry entity.

 
 set_transparent (self, transparency_flag)
 Set the transparency state of the geometry entity.

 
 set_visible (self, visibility_flag)
 Set and verify the visibility state of the geometry entity.

 
 smooth (self)
 Smooths the mesh on a GeomEntity to improve element quality.

 
 surfaces (self)
 Retrieve surfaces associated with the geometry entity.

 
 vertices (self)
 Retrieve vertices (points) associated with the geometry entity.

 
 volumes (self)
 Retrieve volumes associated with the geometry entity.

 
- Public Member Functions inherited from Entity
 bounding_box (self)
 Returns the axis-aligned bounding box of the Entity.

 
 center_point (self)
 Returns the geometric center point of the Entity.

 
 id (self)
 Retrieves the unique identifier of the Entity.

 

Detailed Description

Defines a volume object that mostly parallels Cubit's RefVolume class.

Member Function Documentation

◆ centroid()

centroid ( self)

Get the centroid of the Volume.

      .. code-block:: python
centroid = volume.centroid()
     @n return type of : std:: array< double,3 >
Returns
A vector (or list) of the coordinates of the centroid of the volume with the indices of the vector corresponding to the values as follows:
0 x coordinate
1 y coordinate
2 z coordinate

◆ color()

color ( self)

Get the RGBA color of this Volume entity.

        Retrieves the current display color of the volume as RGBA channels.
Note
if a specific color has not been explicitly applied, this function returns (0.0, 0.0, 0.0, 0.0).

Example create a sphere with radius 1, apply a yellow color (via command or API), and retrieve its color.

         .. code-block:: python
# Create a sphere of radius 1
cubit.cmd("sphere rad 1")
# Obtain the Volume object for ID 1
vol_obj = cubit.volume(1)
# Method 1: apply yellow via command interface
cubit.cmd("color vol 1 yellow")
# Method 2: apply yellow via API call
vol_obj.set_color([1.0, 1.0, 0.0, 1.0])
# Get the RGBA color
col = vol_obj.color()
print("Color RGBA:", col) # Expected output: [1.0, 1.0, 0.0, 1.0]
volume(id_in)
Retrieve a volume by its ID.
Definition cubit.py:23939
cmd(input_string)
Execute a raw Cubit command string immediately (modifies model state).
Definition cubit.py:5275
        @n return type of : std:: array< double,4 >
Returns
Array of four doubles representing the RGBA channels of the volume's color.

◆ principal_axes()

principal_axes ( self)

Retrieve the principal axes of this Volume entity.

        Returns the three principal directions (axes) of the volume, corresponding to its principal moments of inertia, as a flattened 3x3 matrix.

Example create a unit sphere and get its principal axes (unit vectors along X, Y, Z).

         .. code-block:: python
# Create a sphere of radius 1
cubit.cmd("sphere rad 1")
# Obtain the Volume object for ID 1
vol_obj = cubit.volume(1)
# Retrieve principal axes
axes = vol_obj.principal_axes()
print("Axes:", axes) # Expected: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
        @n return type of : std:: array< double,9 >
Returns
: Array of nine doubles representing the principal axes indicesx0x2 = axisx1 (x,y,z), 3x5 = axisx2, 6x8 = axisx3.

◆ principal_moments()

principal_moments ( self)

Get the principal moments of the Volume.

      .. code-block:: python
moments = volume.principal_moments()
     @n return type of : std:: array< double,3 >
Returns
A vector (or list) of the principal moments of the volume with the indices of the vector corresponding to the values as follows:
0 x moment
1 y moment
2 z moment

◆ set_color()

set_color ( self,
value )

Set the RGBA color of this Volume entity.

        Applies a display color using red, green, blue, and alpha (opacity) channels.
Note
the alpha channel controls opacity (0.0 = fully transparent, 1.0 = fully opaque).

Example create a sphere with radius 1, apply yellow color (full and semi-transparent) via command and API, and force graphics updates.

         .. code-block:: python
# Create a sphere of radius 1
cubit.cmd("sphere rad 1")
# Obtain the Volume object for ID 1
vol_obj = cubit.volume(1)
# Method 1: set yellow via command interface (opaque)
cubit.cmd("color vol 1 yellow")
# Force graphics update
cubit.cmd("display")
# Method 2: set semi-transparent yellow via API (alpha = 0.5)
vol_obj.set_color([1.0, 1.0, 0.0, 0.5])
# Force graphics update
cubit.cmd("display")
        @n type of value:  std::array< double,4 >, in
Parameters
valueArray of four doubles [R,G,B,A] in [0,1], where A controls opacity.

◆ volume()

volume ( self)

Compute the three-dimensional volume of this Volume entity.

        Calculates the geometric volume enclosed by this Volume object.

Example create a sphere with radius 1 via command-line, obtain its Volume object, and measure its volume.

         .. code-block:: python
# Create a sphere of radius 1
cubit.cmd("sphere rad 1")
# Obtain the Volume object for ID 1
vol_obj = cubit.volume(1)
# Compute the geometric volume
geo_vol = vol_obj.volume()
print("Computed volume:", geo_vol) # Expected output: 4.18879
        @n return type of :  float
Returns
The computed three-dimensional volume.