|
28 | 28 | from ansys.api.geometry.v0.bodies_pb2 import (
|
29 | 29 | CreateBodyFromFaceRequest,
|
30 | 30 | CreateExtrudedBodyFromFaceProfileRequest,
|
| 31 | + CreateExtrudedBodyFromLoftProfilesRequest, |
31 | 32 | CreateExtrudedBodyRequest,
|
32 | 33 | CreatePlanarBodyRequest,
|
33 | 34 | CreateSphereBodyRequest,
|
|
44 | 45 | SetSharedTopologyRequest,
|
45 | 46 | )
|
46 | 47 | from ansys.api.geometry.v0.components_pb2_grpc import ComponentsStub
|
47 |
| -from ansys.api.geometry.v0.models_pb2 import Direction, Line |
| 48 | +from ansys.api.geometry.v0.models_pb2 import Direction, Line, TrimmedCurveList |
48 | 49 | from beartype import beartype as check_input_types
|
49 | 50 | from beartype.typing import TYPE_CHECKING, List, Optional, Tuple, Union
|
50 | 51 | from pint import Quantity
|
@@ -684,6 +685,73 @@ def create_sphere(self, name: str, center: Point3D, radius: Distance) -> Body:
|
684 | 685 | self._master_component.part.bodies.append(tb)
|
685 | 686 | return Body(response.id, response.name, self, tb)
|
686 | 687 |
|
| 688 | + @protect_grpc |
| 689 | + @check_input_types |
| 690 | + @ensure_design_is_active |
| 691 | + @min_backend_version(24, 2, 0) |
| 692 | + def create_body_from_loft_profile( |
| 693 | + self, |
| 694 | + name: str, |
| 695 | + profiles: List[List[TrimmedCurve]], |
| 696 | + periodic: bool = False, |
| 697 | + ruled: bool = False, |
| 698 | + ) -> Body: |
| 699 | + """ |
| 700 | + Create a lofted body from a collection of trimmed curves. |
| 701 | +
|
| 702 | + Parameters |
| 703 | + ---------- |
| 704 | + name : str |
| 705 | + Name of the lofted body. |
| 706 | + profiles : List[List[TrimmedCurve]] |
| 707 | + Collection of lists of trimmed curves (profiles) defining the lofted body's shape. |
| 708 | + periodic : bool, default: False |
| 709 | + Whether the lofted body should have periodic continuity. |
| 710 | + ruled : bool |
| 711 | + Whether the lofted body should be ruled. |
| 712 | +
|
| 713 | + Returns |
| 714 | + ------- |
| 715 | + Body |
| 716 | + Created lofted body object. |
| 717 | +
|
| 718 | + Notes |
| 719 | + ----- |
| 720 | + Surfaces produced have a U parameter in the direction of the profile curves, |
| 721 | + and a V parameter in the direction of lofting. |
| 722 | + Profiles can have different numbers of segments. A minimum twist solution is |
| 723 | + produced. |
| 724 | + Profiles should be all closed or all open. Closed profiles cannot contain inner |
| 725 | + loops. If closed profiles are supplied, a closed (solid) body is produced, if |
| 726 | + possible. Otherwise, an open (sheet) body is produced. |
| 727 | + The periodic argument applies when the profiles are closed. It is ignored if |
| 728 | + the profiles are open. |
| 729 | +
|
| 730 | + If ``periodic=True``, at least three profiles must be supplied. The loft continues |
| 731 | + from the last profile back to the first profile to produce surfaces that are |
| 732 | + periodic in V. |
| 733 | +
|
| 734 | + If ``periodic=False``, at least two profiles must be supplied. If the first |
| 735 | + and last profiles are planar, end capping faces are created. Otherwise, an open |
| 736 | + (sheet) body is produced. |
| 737 | + If ``ruled=True``, separate ruled surfaces are produced between each pair of profiles. |
| 738 | + If ``periodic=True``, the loft continues from the last profile back to the first |
| 739 | + profile, but the surfaces are not periodic. |
| 740 | + """ |
| 741 | + profiles_grpc = [ |
| 742 | + TrimmedCurveList(curves=[trimmed_curve_to_grpc_trimmed_curve(tc) for tc in profile]) |
| 743 | + for profile in profiles |
| 744 | + ] |
| 745 | + |
| 746 | + request = CreateExtrudedBodyFromLoftProfilesRequest( |
| 747 | + name=name, parent=self.id, profiles=profiles_grpc, periodic=periodic, ruled=ruled |
| 748 | + ) |
| 749 | + self._grpc_client.log.debug(f"Creating a loft profile body on {self.id} .") |
| 750 | + response = self._bodies_stub.CreateExtrudedBodyFromLoftProfiles(request) |
| 751 | + tb = MasterBody(response.master_id, name, self._grpc_client, is_surface=False) |
| 752 | + self._master_component.part.bodies.append(tb) |
| 753 | + return Body(response.id, response.name, self, tb) |
| 754 | + |
687 | 755 | @protect_grpc
|
688 | 756 | @check_input_types
|
689 | 757 | @ensure_design_is_active
|
|
0 commit comments