Makes an Ellipse centered at the provided point, having normal in the provided direction. :param cls: :param x_radius: x radius of the ellipse (along the x-axis of plane the ellipse should lie in) :param y_radius: y radius of the ellipse (along the y-axis of plane t
(
cls,
x_radius: float,
y_radius: float,
pnt: VectorLike = Vector(0, 0, 0),
dir: VectorLike = Vector(0, 0, 1),
xdir: VectorLike = Vector(1, 0, 0),
angle1: float = 360.0,
angle2: float = 360.0,
sense: Literal[-1, 1] = 1,
)
| 2639 | |
| 2640 | @classmethod |
| 2641 | def makeEllipse( |
| 2642 | cls, |
| 2643 | x_radius: float, |
| 2644 | y_radius: float, |
| 2645 | pnt: VectorLike = Vector(0, 0, 0), |
| 2646 | dir: VectorLike = Vector(0, 0, 1), |
| 2647 | xdir: VectorLike = Vector(1, 0, 0), |
| 2648 | angle1: float = 360.0, |
| 2649 | angle2: float = 360.0, |
| 2650 | sense: Literal[-1, 1] = 1, |
| 2651 | ) -> Edge: |
| 2652 | """ |
| 2653 | Makes an Ellipse centered at the provided point, having normal in the provided direction. |
| 2654 | |
| 2655 | :param cls: |
| 2656 | :param x_radius: x radius of the ellipse (along the x-axis of plane the ellipse should lie in) |
| 2657 | :param y_radius: y radius of the ellipse (along the y-axis of plane the ellipse should lie in) |
| 2658 | :param pnt: vector representing the center of the ellipse |
| 2659 | :param dir: vector representing the direction of the plane the ellipse should lie in |
| 2660 | :param angle1: start angle of arc |
| 2661 | :param angle2: end angle of arc (angle2 == angle1 return closed ellipse = default) |
| 2662 | :param sense: clockwise (-1) or counter clockwise (1) |
| 2663 | :return: an Edge |
| 2664 | """ |
| 2665 | |
| 2666 | pnt_p = Vector(pnt).toPnt() |
| 2667 | dir_d = Vector(dir).toDir() |
| 2668 | xdir_d = Vector(xdir).toDir() |
| 2669 | |
| 2670 | ax1 = gp_Ax1(pnt_p, dir_d) |
| 2671 | ax2 = gp_Ax2(pnt_p, dir_d, xdir_d) |
| 2672 | |
| 2673 | if y_radius > x_radius: |
| 2674 | # swap x and y radius and rotate by 90° afterwards to create an ellipse with x_radius < y_radius |
| 2675 | correction_angle = radians(90.0) |
| 2676 | ellipse_gp = gp_Elips(ax2, y_radius, x_radius).Rotated( |
| 2677 | ax1, correction_angle |
| 2678 | ) |
| 2679 | else: |
| 2680 | correction_angle = 0.0 |
| 2681 | ellipse_gp = gp_Elips(ax2, x_radius, y_radius) |
| 2682 | |
| 2683 | if angle1 == angle2: # full ellipse case |
| 2684 | ellipse = cls(BRepBuilderAPI_MakeEdge(ellipse_gp).Edge()) |
| 2685 | else: # arc case |
| 2686 | # take correction_angle into account |
| 2687 | ellipse_geom = GC_MakeArcOfEllipse( |
| 2688 | ellipse_gp, |
| 2689 | radians(angle1) - correction_angle, |
| 2690 | radians(angle2) - correction_angle, |
| 2691 | sense == 1, |
| 2692 | ).Value() |
| 2693 | ellipse = cls(BRepBuilderAPI_MakeEdge(ellipse_geom).Edge()) |
| 2694 | |
| 2695 | return ellipse |
| 2696 | |
| 2697 | @classmethod |
| 2698 | def makeSpline( |