Skip to content

Commit 585f721

Browse files
needs test
1 parent de8df27 commit 585f721

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

src/ansys/geometry/core/_grpc/_services/base/bodies.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,8 @@ def get_tesellation_with_options(self, **kwargs) -> dict:
218218
def boolean(self, **kwargs) -> dict:
219219
"""Boolean operation."""
220220
pass
221+
222+
@abstractmethod
223+
def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict:
224+
"""Create a body from loft profiles with guides."""
225+
pass

src/ansys/geometry/core/_grpc/_services/v0/bodies.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,3 +759,39 @@ def boolean(self, **kwargs) -> dict: # noqa: D102
759759

760760
# Return the response - formatted as a dictionary
761761
return {}
762+
763+
@protect_grpc
764+
def create_body_from_loft_profiles_with_guides(self, **kwargs): # noqa: D102
765+
from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier
766+
from ansys.api.geometry.v0.bodies_pb2 import (
767+
CreateBodyFromLoftWithGuidesRequest,
768+
CreateBodyFromLoftWithGuidesRequestData,
769+
)
770+
from ansys.api.geometry.v0.models_pb2 import TrimmedCurveList
771+
772+
# Create request object - assumes all inputs are valid and of the proper type
773+
request = CreateBodyFromLoftWithGuidesRequest(
774+
request_data=CreateBodyFromLoftWithGuidesRequestData(
775+
name=kwargs["name"],
776+
parent=EntityIdentifier(id=kwargs["parent_id"]),
777+
profiles=[TrimmedCurveList(
778+
curves=[from_trimmed_curve_to_grpc_trimmed_curve(tc) for tc in profile]
779+
) for profile in kwargs["profiles"]],
780+
guide_ids=TrimmedCurveList(
781+
curves=[from_trimmed_curve_to_grpc_trimmed_curve(tc) for tc in kwargs["guides"]]
782+
),
783+
)
784+
)
785+
786+
# Call the gRPC service
787+
response = self.stub.CreateBodyFromLoftWithGuides(request)
788+
789+
# Return the response - formatted as a dictionary
790+
return {
791+
[{
792+
"id": body.id,
793+
"name": body.name,
794+
"master_id": body.master_id,
795+
"is_surface": body.is_surface,
796+
}] for body in response.created_bodies
797+
}

src/ansys/geometry/core/_grpc/_services/v1/bodies.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,7 @@ def get_tesellation_with_options(self, **kwargs) -> dict: # noqa: D102
191191
@protect_grpc
192192
def boolean(self, **kwargs) -> dict: # noqa: D102
193193
raise NotImplementedError
194+
195+
@protect_grpc
196+
def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa: D102
197+
raise NotImplementedError

src/ansys/geometry/core/designer/component.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,40 @@ def create_body_from_loft_profile(
964964
ruled=ruled,
965965
)
966966
return self.__build_body_from_response(response)
967+
968+
@check_input_types
969+
@ensure_design_is_active
970+
@min_backend_version(26, 1, 0)
971+
def create_body_from_loft_profiles_with_guides(
972+
self, name: str,
973+
profiles: list[list[TrimmedCurve]],
974+
guides: list[TrimmedCurve],
975+
) -> Body:
976+
"""Create a lofted body from a collection of trimmed curves with guide curves.
977+
978+
Parameters
979+
----------
980+
name : str
981+
Name of the lofted body.
982+
profiles : list[list[TrimmedCurve]]
983+
Collection of lists of trimmed curves (profiles) defining the lofted body's shape.
984+
guides : list[TrimmedCurve]
985+
Collection of guide curves to influence the lofting process.
986+
987+
Returns
988+
-------
989+
Body
990+
Created lofted body object.
991+
"""
992+
self._grpc_client.log.debug(f"Creating a loft profile body with guides on {self.id}.")
993+
response = self._grpc_client._services.bodies.create_body_from_loft_profiles_with_guides(
994+
name=name,
995+
parent_id=self.id,
996+
profiles=profiles,
997+
guides=guides,
998+
)
999+
1000+
return self.__build_body_from_response(response)
9671001

9681002
@check_input_types
9691003
@ensure_design_is_active

0 commit comments

Comments
 (0)