SketchNurbs#

class ansys.geometry.core.sketch.nurbs.SketchNurbs#

Bases: ansys.geometry.core.sketch.edge.SketchEdge

Represents a NURBS sketch curve.

Warning

NURBS sketching is only supported in 26R1 and later versions of Ansys.

Notes

This class is a wrapper around the NURBS curve class from the geomdl library. By leveraging the geomdl library, this class provides a high-level interface to create and manipulate NURBS curves. The geomdl library is a powerful library for working with NURBS curves and surfaces. For more information, see https://pypi.org/project/geomdl/.

Overview#

fit_curve_from_points

Fit a NURBS curve to a set of points.

partial_ellipse

Create an exact rational NURBS for a partial ellipse arc.

contains_point

Check if the curve contains a given point within a specified tolerance.

geomdl_nurbs_curve

Get the underlying NURBS curve.

control_points

Get the control points of the curve.

degree

Get the degree of the curve.

knots

Get the knot vector of the curve.

weights

Get the weights of the control points.

start

Get the start point of the curve.

end

Get the end point of the curve.

visualization_polydata

Get the VTK polydata representation for PyVista visualization.

Import detail#

from ansys.geometry.core.sketch.nurbs import SketchNurbs

Property detail#

property SketchNurbs.geomdl_nurbs_curve: geomdl.NURBS.Curve#

Get the underlying NURBS curve.

Notes

This property gives access to the full functionality of the NURBS curve coming from the geomdl library. Use with caution.

property SketchNurbs.control_points: list[ansys.geometry.core.math.point.Point2D]#

Get the control points of the curve.

property SketchNurbs.degree: int#

Get the degree of the curve.

property SketchNurbs.knots: list[ansys.geometry.core.typing.Real]#

Get the knot vector of the curve.

property SketchNurbs.weights: list[ansys.geometry.core.typing.Real]#

Get the weights of the control points.

property SketchNurbs.start: ansys.geometry.core.math.point.Point2D#

Get the start point of the curve.

property SketchNurbs.end: ansys.geometry.core.math.point.Point2D#

Get the end point of the curve.

property SketchNurbs.visualization_polydata: pyvista.PolyData#

Get the VTK polydata representation for PyVista visualization.

Returns:
pyvista.PolyData

VTK pyvista.Polydata configuration.

Notes

The representation lies in the X/Y plane within the standard global Cartesian coordinate system.

Method detail#

SketchNurbs.contains_point(point: ansys.geometry.core.math.point.Point2D, tol: float = 1e-06) bool#

Check if the curve contains a given point within a specified tolerance.

Parameters:
pointPoint2D

The point to check.

tolfloat, optional

The tolerance for the containment check, by default 1e-6.

Returns:
bool

True if the curve contains the point within the tolerance, False otherwise.

classmethod SketchNurbs.fit_curve_from_points(points: list[ansys.geometry.core.math.point.Point2D], degree: int = 3) SketchNurbs#

Fit a NURBS curve to a set of points.

Parameters:
pointslist[Point2D]

The points to fit the curve to.

degreeint, optional

The degree of the NURBS curve, by default 3.

Returns:
SketchNurbs

A new instance of SketchNurbs fitted to the given points.

classmethod SketchNurbs.partial_ellipse(center: ansys.geometry.core.math.point.Point2D, major_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, minor_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, start_angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real, end_angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0) SketchNurbs#

Create an exact rational NURBS for a partial ellipse arc.

Parameters:
centerPoint2D

Center of the ellipse.

major_radiusQuantity | Distance | Real

Semi-major axis length (x-direction before rotation).

minor_radiusQuantity | Distance | Real

Semi-minor axis length (y-direction before rotation).

start_angleQuantity | Angle | Real

Parametric start angle. Defaults to radians when given as a Real.

end_angleQuantity | Angle | Real

Parametric end angle. Defaults to radians when given as a Real. The arc sweeps counter-clockwise when end_angle > start_angle.

angleQuantity | Angle | Real, default: 0

Rotation of the ellipse about its center (radians when Real).

Returns:
SketchNurbs

Exact rational quadratic NURBS (degree 2) for the requested arc. The arc is split into segments of at most 90° for numerical stability.

Raises:
ValueError

If either radius is non-positive.

ValueError

If start_angle equals end_angle (zero-length arc).