Cubit Python API  17.05
Public Member Functions
Curve

Defines a curve object that mostly parallels Cubit's RefEdge class. More...

Inheritance diagram for Curve:
GeomEntity Entity

Public Member Functions

def  arc_center_radius (self)
  Get the center and radius of an arc curve, otherwise returns 0 for non-arc. More...
 
def  closest_point (self, point)
  Get the curvature of the Curve at a particular point. More...
 
def  closest_point_along_vector (self, location, along_vector)
  Get the nearest point on the Curve to point specified along the specified vector. More...
 
def  closest_point_trimmed (self, point)
  Get the closest location on the Curve from a particular point. More...
 
def  color (self)
  Get the color of the Curve. More...
 
def  curvature (self, point)
  Get the curvature of the Curve at a particular point. More...
 
def  curve_center (self)
  Get the center point of the Curve. More...
 
def  end_param (self)
  Get the highest value of the Curve in uv space. More...
 
def  fraction_from_arc_length (self, root_vertex, length)
  Get the fraction along the Curve a specified arc length is away from a given Vertex. More...
 
def  is_periodic (self)
  Get whether the Curve is periodic or not. More...
 
def  length (self)
  Get the length of the Curve. More...
 
def  length_from_u (self, parameter1, parameter2)
  Get the length between two specified parameters on a Curve. More...
 
def  point_from_arc_length (self, root_param, arc_length)
  Get the position on a Curve that is a specified arc length away from the specified root parameter. More...
 
def  position_from_fraction (self, fraction_along_curve)
  Get the position of the point a specified fraction along the Curve. More...
 
def  position_from_u (self, u_value)
  Get the position of a particular u value for the Curve. More...
 
def  set_color (self, value)
  Set the color of the Curve. More...
 
def  spline_params (self)
  Retrieve the full set of spline parameters for this curve. More...
 
def  start_param (self)
  Get the lowest value of the Curve in uv space. More...
 
def  tangent (self, point)
  Get the tangent to the Curve at a particular point. More...
 
def  u_from_arc_length (self, root_param, arc_length)
  Get the u value for a point a specified arc length away from a specified root parameter on the Curve. More...
 
def  u_from_position (self, position)
  Get the u value of a particular position on the Curve. 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 curve object that mostly parallels Cubit's RefEdge class.

Member Function Documentation

◆ arc_center_radius()

def arc_center_radius (   self )

Get the center and radius of an arc curve, otherwise returns 0 for non-arc.

.. code-block:: python

center = curve.arc_center_radius()
     @n return type of : std:: array< double,4 >
Returns
A vector containing the coordinates of the Curve's center according to the following:
0 x coordinate
1 y coordinate
2 z coordinate
3 radius

◆ closest_point()

def closest_point (   self,
  point 
)

Get the curvature of the Curve at a particular point.

.. code-block:: python

close = curve.closest_point([0,0,0])
   @n type of point:  std::array< double,3 >, in
Parameters
point A vector containing 3 doubles representing coordinates of a location on the Curve.
return type of : std:: array< double,3 >
Returns
The closest point to the Curve from the location specified.

◆ closest_point_along_vector()

def closest_point_along_vector (   self,
  location,
  along_vector 
)

Get the nearest point on the Curve to point specified along the specified vector.

.. code-block:: python

nearest = curve.closest_point_along_vector([0,0,0], [1,1,1])
     @n type of location:  std::array< double,3 >, in
Parameters
location A vector containing three values that are the coordinates of a point.
return type of : std::pair< bool,std:: array< double,3 > >
Returns
A vector (or list) of doubles representing values of nearest point as follows:
0 x coordinate
1 y coordinate
2 z coordinate

◆ closest_point_trimmed()

def closest_point_trimmed (   self,
  point 
)

Get the closest location on the Curve from a particular point.

.. code-block:: python

close = curve.closest_point([0,0,0])
   @n type of point:  std::array< double,3 >, in
Parameters
point A vector containing 3 doubles representing coordinates of a location on the Curve.
return type of : std:: array< double,3 >
Returns
The closest point to the Curve from the location specified

◆ color()

def color (   self )

Get the color of the Curve .

.. code-block:: python

col = curve.color()
   @n return type of : std:: array< double,4 >
Returns
The color value associated with the curve's current color.

◆ curvature()

def curvature (   self,
  point 
)

Get the curvature of the Curve at a particular point.

.. code-block:: python

curvature = curve.curvature([0,0,0])
   @n type of point:  std::array< double,3 >, in
Parameters
point A curvature vector containing 3 doubles. This is related to the 2nd derivative of the curve.
return type of : std:: array< double,3 >
Returns
The curvature of the Curve at the location specified

◆ curve_center()

def curve_center (   self )

Get the center point of the Curve .

.. code-block:: python

center = curve.curve_center()
     @n return type of : std:: array< double,3 >
Returns
A vector containing the coordinates of the Curve's center according to the following:
0 x coordinate
1 y coordinate
2 z coordinate

◆ end_param()

def end_param (   self )

Get the highest value of the Curve in uv space.

.. code-block:: python

end = curve.end_param()
   @n return type of :  float
Returns
The ending value of the parameter.

◆ fraction_from_arc_length()

def fraction_from_arc_length (   self,
  root_vertex,
  length 
)

Get the fraction along the Curve a specified arc length is away from a given Vertex .

.. code-block:: python

fraction = curve.fraction_from_arc_length(vertex, 0.5)
   @n type of root_vertex:  :py:class:`Vertex`, in
Parameters
root_vertex The Vertex to start from (vertex object)
type of length: float, in
length The length along the Curve away from the root Vertex.
return type of : float
Returns
The fraction of the Curve that is the specified length away from the specified Vertex.

◆ is_periodic()

def is_periodic (   self )

Get whether the Curve is periodic or not.

.. code-block:: python

periodic = curve.is_periodic()
   @n return type of :  boolean
Returns
Whether the Curve is periodic or not.

◆ length()

def length (   self )

Get the length of the Curve .

.. code-block:: python

len = curve.length()
   @n return type of :  float
Returns
The length of the Curve.

◆ length_from_u()

def length_from_u (   self,
  parameter1,
  parameter2 
)

Get the length between two specified parameters on a Curve .

.. code-block:: python

length = curve.length_from_u(0, 0.5)
   @n type of parameter1:  float, in
Parameters
parameter1 The beginning parameter.
type of parameter2: float, in
parameter2 The ending parameter.
return type of : float
Returns
The length between the two specified paramters along the Curve.

◆ point_from_arc_length()

def point_from_arc_length (   self,
  root_param,
  arc_length 
)

Get the position on a Curve that is a specified arc length away from the specified root parameter.

.. code-block:: python

position = curve.point_from_arc_length(0, 0.5)
   @n type of root_param:  float, in
Parameters
root_param The root parameter from which the arc length is added to.
type of arc_length: float, in
arc_length The arc length along the Curve away from the root parameter.
return type of : std:: array< double,3 >
Returns
A vector that contains the coordinates of a position a specified arc length away from the root parameter.

◆ position_from_fraction()

def position_from_fraction (   self,
  fraction_along_curve 
)

Get the position of the point a specified fraction along the Curve .

.. code-block:: python

pos = curve.position_from_fraction(0.5)
     @n type of fraction_along_curve:  float, in
Parameters
fraction_along_curve A decimal value between 0 and 1 to determine a particular position along the Curve.
return type of : std:: array< double,3 >
Returns
A vector containing the coordinates of the position a specified fraction along the Curve:
0 x coordinate
1 y coordinate
2 z coordinate

◆ position_from_u()

def position_from_u (   self,
  u_value 
)

Get the position of a particular u value for the Curve .

.. code-block:: python

position = curve.position_from_u(0.5)
   @n type of u_value:  float, in
Parameters
u_value The u value of the position along the Curve.
return type of : std:: array< double,3 >
Returns
A vector containing the coordinates of the output position

◆ set_color()

def set_color (   self,
  value 
)

Set the color of the Curve .

.. code-block:: python

curve.set_color(0)
   @n type of value:  std::array< double,4 >, in
Parameters
value The color value that the curve will have.

◆ spline_params()

def spline_params (   self )

Retrieve the full set of spline parameters for this curve.

This method wraps the underlying geometry engine's spline-parameter routine (e.g., ACIS), extracting control point positions, weights, and knot data into a uniform flat vector. It throws InvalidEntityException for invalid entities and reports failure on non-spline curves.

Let
N = number of control points, M = number of weights, D = polynomial degree, K = number of knots (should equal D + N - 1). The total vector length S satisfies:
S = 6 + 3*N + M + K
which expands as: [0] : rational flag (1.0 if rational, 0.0 otherwise) [1] : D (polynomial degree) [2] : N (control points count) [3 ... 3+3*N-1] : control-point coordinates (x, y, z) for each of the N points [3+3*N] : M (weight count) [3+3*N+1 ... 3+3*N+M] : weight values [3+3*N+M+1] : K (knot count) [3+3*N+M+2 ... 3+3*N+M+1+K] : knot values [S-1] : reverse flag (1.0 if reversed, 0.0 otherwise)
        .. code-block:: python
import cubit
# Build a simple spline curve (Curve ID = 1)
cubit.cmd ("create vertex 0 0 0" )
cubit.cmd ("create vertex 1 1 0" )
cubit.cmd ("create vertex 2 0 0" )
cubit.cmd ("create curve vertex 1 3 2 spline" )
# Retrieve and unpack spline parameters
spline_curve = cubit.curve (1)
params = spline_curve.spline_params()
idx = 0
# Rationality
rational = (params[idx] == 1.0); idx += 1
# Degree of Spline
degree = int(params[idx]); idx += 1
# Control Points
n_pts = int(params[idx]); idx += 1
pts = []
for _ in range(n_pts): pts.append(tuple(params[idx:idx+3])); idx += 3
# Weights
m_w = int(params[idx]); idx += 1
weights = params[idx:idx+m_w]; idx += m_w
# Knots
k_n = int(params[idx]); idx += 1
knots = params[idx:idx+k_n]; idx += k_n
# Reversed Flag
reversed_flag = (params[idx] == 1.0)
# Print nicely
print(f"Rational: {rational}" )
print(f"Degree: {degree}" )
print(f"ControlPts({n_pts}):" )

for p in pts: print(f" {p}") print(f"Weights({m_w}): {weights}") print {knots}") print {reversed_flag}")

# Expected output:
# Rational: False
# Degree: 3
# ControlPts(5):
# (0, 0, 0)
# (0.333333, 0.5, 0)
# (1, 1.5, 0)
# (1.666667, 0.5, 0)
# (2, 0, 0)
# Weights(0): ()
# Knots(9): (0, 0, 0, 0, 1.41421, 2.82843, 2.82843, 2.82843, 2.82843)
# Reversed: False
       @n return type of : std::vector< double,std:: allocator< double > >
Returns
Packed spline parameters as a float sequence (std::vector<double> in C++, tuple in Python).

◆ start_param()

def start_param (   self )

Get the lowest value of the Curve in uv space.

.. code-block:: python

start = curve.start_param()
   @n return type of :  float
Returns
The beginning value of the parameter.

◆ tangent()

def tangent (   self,
  point 
)

Get the tangent to the Curve at a particular point.

.. code-block:: python

tan = curve.tangent([0,0,0])
   @n type of point:  std::array< double,3 >, in
Parameters
point A vector containing 3 doubles representing coordinates of a location on the Curve.
return type of : std:: array< double,3 >
Returns
The tangent to the Curve at the location specified

◆ u_from_arc_length()

def u_from_arc_length (   self,
  root_param,
  arc_length 
)

Get the u value for a point a specified arc length away from a specified root parameter on the Curve .

.. code-block:: python

u = curve.u_from_arc_length(0, 0.5)
   @n type of root_param:  float, in
Parameters
root_param The beginning parameter from which the arc length is added to.
type of arc_length: float, in
arc_length The length away from the root parameter of the output parameter.
return type of : float
Returns
The u value of the Curve the arc length away from the root parameter.

◆ u_from_position()

def u_from_position (   self,
  position 
)

Get the u value of a particular position on the Curve .

.. code-block:: python

u = curve.u_from_position([0,0,0])
   @n type of position:  std::array< double,3 >, in
Parameters
position A vector containing the coordinates of the input position
return type of : float
Returns
The u value of the position along the Curve.