Cubit Python API  17.05
Public Member Functions
Body

Defines a body object that mostly parallels Cubit's Body class. More...

Inheritance diagram for Body:
GeomEntity Entity

Public Member Functions

def  get_mass_props (self)
  Get the center of gravity of the Body. More...
 
def  is_sheet_body (self)
  Get whether the Body is a sheet body or not. More...
 
def  point_containment (self, loc_in)
  Determine point containment relative to the Body. More...
 
def  volume (self)
  Get the volume of the Body. More...
 
- Public Member Functions inherited from GeomEntity
def  bodies (self)
  Retrieve bodies contained within the geometry entity. More...
 
def  curves (self)
  Retrieve curves (edges) associated with the geometry entity. More...
 
def  dimension (self)
  Get the topological dimension of the geometry entity. More...
 
def  entity_name (self)
  Retrieve the primary name of the geometry entity. More...
 
def  entity_names (self)
  Retrieve all names assigned to the geometry entity. More...
 
def  is_meshed (self)
  Returns the current mesh state of the GeomEntity. More...
 
def  is_transparent (self)
  Get the transparency state of the geometry entity. More...
 
def  is_visible (self)
  Get the visibility state of the geometry entity. More...
 
def  mesh (self)
  Generates mesh on a GeomEntity and verifies meshing status. More...
 
def  num_names (self)
  Get the count of names assigned to the geometry entity. More...
 
def  remove_entity_name (self, name)
  Remove a specific name from the geometry entity. More...
 
def  remove_entity_names (self)
  Remove all non-default names from the geometry entity. More...
 
def  remove_mesh (self)
  Remove any mesh associated with the geometry entity. More...
 
def  set_entity_name (self, name)
  Assign a name to the geometry entity. More...
 
def  set_transparent (self, transparency_flag)
  Set the transparency state of the geometry entity. More...
 
def  set_visible (self, visibility_flag)
  Set and verify the visibility state of the geometry entity. More...
 
def  smooth (self)
  Smooths the mesh on a GeomEntity to improve element quality. More...
 
def  surfaces (self)
  Retrieve surfaces associated with the geometry entity. More...
 
def  vertices (self)
  Retrieve vertices (points) associated with the geometry entity. More...
 
def  volumes (self)
  Retrieve volumes associated with the geometry entity. More...
 
- Public Member Functions inherited from Entity
def  bounding_box (self)
  Returns the axis-aligned bounding box of the Entity. More...
 
def  center_point (self)
  Returns the geometric center point of the Entity. More...
 
def  id (self)
  Retrieves the unique identifier of the Entity. More...
 

Detailed Description

Defines a body object that mostly parallels Cubit's Body class.

Member Function Documentation

◆ get_mass_props()

def get_mass_props (   self )

Get the center of gravity of the Body .

Computes and returns the mass properties of this Body , specifically the center of gravity coordinates.

         .. code-block:: python
# Create and unite two bricks: a cube and a long rectangular brick
cubit.cmd ("brick x 1 y 1 z 1" )
cubit.cmd ("brick x 10 y 1 z 1" )
cubit.cmd ("vol 2 move x 10" )
cubit.cmd ("unite vol all" )
# Retrieve the unified body
b = cubit.body (1)
# Get geometric center and center of gravity
center_pt = b.center_point()
cg = b.get_mass_props()
print("Geometric center:" , center_pt)
print("Center of gravity:" , cg)
# Expected: geometric center != center of gravity
        @n return type of : std:: array< double,3 >
Returns
: A std::array of three double values the x, y, and z coordinates of the Body's center of gravity.

◆ is_sheet_body()

def is_sheet_body (   self )

Get whether the Body is a sheet body or not.

Determines if this Body represents a sheet (2D) geometry rather than a volume (3D).

         .. code-block:: python
# Create a 3D brick (volume)
cubit.cmd ("reset" )
vol_body = cubit.brick (1)
print("Is sheet body?" , vol_body.is_sheet_body()) # Expected output: False
# Create a 2D rectangular sheet via command
cubit.cmd ("reset" )
cubit.cmd ("create surface rectangle width 1" )
surf = cubit.surface (1)
# Extract the sheet body from the surface
sheet_bodies = surf.bodies()
sheet_body = sheet_bodies[0]
print("Is sheet body?" , sheet_body.is_sheet_body()) # Expected output: True
        @n return type of :  boolean
Returns
True if the Body is a sheet body, False otherwise.

◆ point_containment()

def point_containment (   self,
  loc_in 
)

Determine point containment relative to the Body .

Checks whether a given point is inside, on, or outside this Body

         .. code-block:: python
# Create a unit cube body (1x1x1) centered at origin (extends -0.5 to 0.5)
b = cubit.brick (1)
# Point strictly inside the volume
print("Inside:" , b.point_containment([0.0, 0.0, 0.0])) # Expected output: 1
# Point on the boundary
print("On:" , b.point_containment([0.5, 0.0, 0.0])) # Expected output: 2
# Point outside the volume
print("Outside:" ,b.point_containment([1.0, 0.0, 0.0])) # Expected output: 0
        @n type of loc_in:  std::array< double,3 >, in
Parameters
loc_in A three-element array specifying the point coordinates (x, y, z).
return type of : int
Returns
: An integer code -1 if unknown, 0 if outside, 1 if inside, or 2 if on the boundary of the Body.

◆ volume()

def volume (   self )

Get the volume of the Body .

Notes This function is only available on Body objects.

     Returns the computed geometric volume of this Body.




     .. code-block:: python
# Create a unit cube body (1x1x1)
b = cubit.brick (1)
# Compute and print its volume
vol = b.volume()
print("Body volume:" , vol) # Expected output: 1.0
        @n return type of :  float
Returns
The volume of the Body.