@@ -749,6 +749,46 @@ def from_nurbs_curve_to_grpc_nurbs_curve(curve: "NURBSCurve") -> GRPCNurbsCurve:
749749 )
750750
751751
752+ def from_grpc_nurbs_curve_to_nurbs_curve (curve : GRPCNurbsCurve ) -> "NURBSCurve" :
753+ """Convert a NURBS curve gRPC message to a ``NURBSCurve``.
754+
755+ Parameters
756+ ----------
757+ curve : GRPCNurbsCurve
758+ Geometry service gRPC NURBS curve message.
759+
760+ Returns
761+ -------
762+ NURBSCurve
763+ Resulting converted NURBS curve.
764+ """
765+ from ansys .geometry .core .shapes .curves .nurbs import NURBSCurve
766+
767+ # Extract control points
768+ control_points = [
769+ from_grpc_point_to_point3d (cp .position ) for cp in curve .control_points
770+ ]
771+
772+ # Extract weights
773+ weights = [cp .weight for cp in curve .control_points ]
774+
775+ # Extract degree
776+ degree = curve .nurbs_data .degree
777+
778+ # Convert gRPC knots to full knot vector
779+ knots = []
780+ for grpc_knot in curve .nurbs_data .knots :
781+ knots .extend ([grpc_knot .parameter ] * grpc_knot .multiplicity )
782+
783+ # Create and return the NURBS curve
784+ return NURBSCurve .from_control_points (
785+ control_points = control_points ,
786+ degree = degree ,
787+ knots = knots ,
788+ weights = weights ,
789+ )
790+
791+
752792def from_knots_to_grpc_knots (knots : list [float ]) -> list [GRPCKnot ]:
753793 """Convert a list of knots to a list of gRPC knot messages.
754794
@@ -813,6 +853,8 @@ def from_grpc_curve_to_curve(curve: GRPCCurveGeometry) -> "Curve":
813853 result = Circle (origin , curve .radius , reference , axis )
814854 elif curve .major_radius != 0 and curve .minor_radius != 0 :
815855 result = Ellipse (origin , curve .major_radius , curve .minor_radius , reference , axis )
856+ elif curve .nurbs_curve .nurbs_data .degree != 0 :
857+ result = from_grpc_nurbs_curve_to_nurbs_curve (curve .nurbs_curve )
816858 elif curve .direction is not None :
817859 result = Line (
818860 origin ,
0 commit comments