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

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

Inheritance diagram for Curve:
GeomEntity Entity

Public Member Functions

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

 
 closest_point (self, point)
 Get the curvature of the Curve at a particular point.

 
 closest_point_along_vector (self, location, along_vector)
 Get the nearest point on the Curve to point specified along the specified vector.

 
 closest_point_trimmed (self, point)
 Get the closest location on the Curve from a particular point.

 
 color (self)
 Get the color of the Curve.

 
 curvature (self, point)
 Get the curvature of the Curve at a particular point.

 
 curve_center (self)
 Get the center point of the Curve.

 
 dihedral_angle (self, other, common_surface)
 Get the dihedral angle between this curve and another curve relate to the given surface.

 
 end_param (self)
 Get the highest value of the Curve in uv space.

 
 fraction_from_arc_length (self, root_vertex, length)
 Get the fraction along the Curve a specified arc length is away from a given Vertex.

 
 is_periodic (self)
 Get whether the Curve is periodic or not.

 
 length (self)
 Get the length of the Curve.

 
 length_from_u (self, parameter1, parameter2)
 Get the length between two specified parameters on a Curve.

 
 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.

 
 position_from_fraction (self, fraction_along_curve)
 Get the position of the point a specified fraction along the Curve.

 
 position_from_u (self, u_value)
 Get the position of a particular u value for the Curve.

 
 set_color (self, value)
 Set the color of the Curve.

 
 spline_params (self)
 Retrieve the full set of spline parameters for this curve.

 
 start_param (self)
 Get the lowest value of the Curve in uv space.

 
 tangent (self, point)
 Get the tangent to the Curve at a particular point.

 
 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.

 
 u_from_position (self, position)
 Get the u value of a particular position on the Curve.

 
- 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 curve object that mostly parallels Cubit's RefEdge class.

Member Function Documentation

◆ arc_center_radius()

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()

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
pointA 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()

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
locationA 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()

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
pointA 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()

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()

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
pointA 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()

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

◆ dihedral_angle()

dihedral_angle ( self,
other,
common_surface )

Get the dihedral angle between this curve and another curve relate to the given surface.

:type other: :py:class:Curve

Parameters
otherThe other curve object that forms a dihedral angle with this one. :type common_surface: :py:class:Surface
common_surfaceSurface object that contains both curves. :rtype: float
Returns
the dihedral angle between the curves, in radians

◆ end_param()

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()

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_vertexThe Vertex to start from (vertex object)

type of length: float, in
lengthThe 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()

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()

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()

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
parameter1The beginning parameter.

type of parameter2: float, in
parameter2The ending parameter.

return type of : float
Returns
The length between the two specified paramters along the Curve.

◆ point_from_arc_length()

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_paramThe root parameter from which the arc length is added to.

type of arc_length: float, in
arc_lengthThe 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()

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_curveA 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()

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_valueThe 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()

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
valueThe color value that the curve will have.

◆ spline_params()

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}):")
curve(id_in)
Retrieve a curve object by its ID.
Definition cubit.py:23996
cmd(input_string)
Execute a raw Cubit command string immediately (modifies model state).
Definition cubit.py:5275

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()

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()

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
pointA 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()

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_paramThe beginning parameter from which the arc length is added to.

type of arc_length: float, in
arc_lengthThe 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()

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
positionA vector containing the coordinates of the input position

return type of : float
Returns
The u value of the position along the Curve.