Skip to content

Commit f7e45d7

Browse files
removed commands stub fully from body
1 parent dc8f4f1 commit f7e45d7

File tree

5 files changed

+304
-108
lines changed

5 files changed

+304
-108
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,38 @@ def split_body(self, **kwargs) -> dict:
231231
def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict:
232232
"""Create a body from loft profiles with guides."""
233233
pass
234+
235+
@abstractmethod
236+
def assign_midsurface_thickness(self, **kwargs) -> dict:
237+
"""Assign a thickness to a midsurface body."""
238+
pass
239+
240+
@abstractmethod
241+
def assign_midsurface_offset(self, **kwargs) -> dict:
242+
"""Assign a offset to a midsurface body."""
243+
pass
244+
245+
@abstractmethod
246+
def shell(self, **kwargs) -> dict:
247+
"""Shell a body."""
248+
pass
249+
250+
@abstractmethod
251+
def remove_faces(self, **kwargs) -> dict:
252+
"""Remove faces from a body."""
253+
pass
254+
255+
@abstractmethod
256+
def imprint_curves(self, **kwargs) -> dict:
257+
"""Imprint curves on a body."""
258+
pass
259+
260+
@abstractmethod
261+
def project_curves(self, **kwargs) -> dict:
262+
"""Project curves on a body."""
263+
pass
264+
265+
@abstractmethod
266+
def imprint_projected_curves(self, **kwargs) -> dict:
267+
"""Imprint projected curves on a body."""
268+
pass

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

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,3 +890,185 @@ def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa:
890890
"master_id": new_body.master_id,
891891
"is_surface": new_body.is_surface,
892892
}
893+
894+
@protect_grpc
895+
def assign_midsurface_thickness(self, **kwargs) -> dict: # noqa: D102
896+
from ansys.api.geometry.v0.commands_pb2 import AssignMidSurfaceThicknessRequest
897+
898+
# Create the request - assumes all inputs are valid and of the proper type
899+
request = AssignMidSurfaceThicknessRequest(
900+
bodies_or_faces=kwargs["ids"],
901+
thickness=from_measurement_to_server_length(kwargs["thickness"]),
902+
)
903+
904+
# Call the gRPC service
905+
self.command_stub.AssignMidSurfaceThickness(request=request)
906+
907+
# Return the response - formatted as a dictionary
908+
return {}
909+
910+
@protect_grpc
911+
def assign_midsurface_offset(self, **kwargs) -> dict: # noqa: D102
912+
from ansys.api.geometry.v0.commands_pb2 import AssignMidSurfaceOffsetTypeRequest
913+
914+
# Create the request - assumes all inputs are valid and of the proper type
915+
request = AssignMidSurfaceOffsetTypeRequest(
916+
bodies_or_faces=kwargs["ids"],
917+
offset_type=kwargs["offset_type"].value,
918+
)
919+
920+
# Call the gRPC service
921+
self.command_stub.AssignMidSurfaceOffsetType(request=request)
922+
923+
# Return the response - formatted as a dictionary
924+
return {}
925+
926+
@protect_grpc
927+
def shell(self, **kwargs) -> dict: # noqa: D102
928+
from ansys.api.geometry.v0.commands_pb2 import ShellRequest
929+
930+
# Create the request - assumes all inputs are valid and of the proper type
931+
request = ShellRequest(
932+
selection=build_grpc_id(kwargs["id"]),
933+
offset=from_measurement_to_server_length(kwargs["offset"]),
934+
)
935+
936+
# Call the gRPC service
937+
response = self.command_stub.Shell(request=request)
938+
939+
# Return the response - formatted as a dictionary
940+
return {
941+
"success": response.success,
942+
}
943+
944+
@protect_grpc
945+
def remove_faces(self, **kwargs) -> dict: # noqa: D102
946+
from ansys.api.geometry.v0.commands_pb2 import RemoveFacesRequest
947+
948+
# Create the request - assumes all inputs are valid and of the proper type
949+
request = RemoveFacesRequest(
950+
selection=[build_grpc_id(id) for id in kwargs["face_ids"]],
951+
offset=from_measurement_to_server_length(kwargs["offset"]),
952+
)
953+
954+
# Call the gRPC service
955+
response = self.command_stub.RemoveFaces(request=request)
956+
957+
# Return the response - formatted as a dictionary
958+
return {
959+
"success": response.success,
960+
}
961+
962+
@protect_grpc
963+
def imprint_curves(self, **kwargs) -> dict: # noqa: D102
964+
from ansys.api.geometry.v0.commands_pb2 import ImprintCurvesRequest
965+
966+
# Convert sketch and trimmed curves to gRPC format
967+
sketch = kwargs["sketch"]
968+
curves = None
969+
if sketch:
970+
curves = from_sketch_shapes_to_grpc_geometries(sketch.plane, sketch.edges, sketch.faces)
971+
972+
trimmed_curves = None
973+
if kwargs["tc"]:
974+
trimmed_curves = [from_trimmed_curve_to_grpc_trimmed_curve(tc) for tc in kwargs["tc"]]
975+
976+
# Create the request - assumes all inputs are valid and of the proper type
977+
request = ImprintCurvesRequest(
978+
body=kwargs["id"],
979+
curves=curves,
980+
faces=kwargs["face_ids"],
981+
plane=from_plane_to_grpc_plane(sketch.plane) if sketch else None,
982+
trimmed_curves=trimmed_curves,
983+
)
984+
985+
# Call the gRPC service
986+
response = self.command_stub.ImprintCurves(request=request)
987+
988+
# Return the response - formatted as a dictionary
989+
return {
990+
"edges": [
991+
{
992+
"id": edge.id,
993+
"curve_type": edge.curve_type,
994+
"is_reversed": edge.is_reversed,
995+
}
996+
for edge in response.edges
997+
],
998+
"faces": [
999+
{
1000+
"id": face.id,
1001+
"surface_type": face.surface_type,
1002+
"is_reversed": face.is_reversed,
1003+
}
1004+
for face in response.faces
1005+
],
1006+
}
1007+
1008+
@protect_grpc
1009+
def project_curves(self, **kwargs) -> dict: # noqa: D102
1010+
from ansys.api.geometry.v0.commands_pb2 import ProjectCurvesRequest
1011+
1012+
# Convert sketch and trimmed curves to gRPC format
1013+
sketch = kwargs["sketch"]
1014+
curves = from_sketch_shapes_to_grpc_geometries(
1015+
sketch.plane, sketch.edges, sketch.faces, kwargs["only_one_curve"]
1016+
)
1017+
1018+
# Create the request - assumes all inputs are valid and of the proper type
1019+
request = ProjectCurvesRequest(
1020+
body=kwargs["id"],
1021+
curves=curves,
1022+
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
1023+
closest_face=kwargs["closest_face"],
1024+
plane=from_plane_to_grpc_plane(sketch.plane),
1025+
)
1026+
1027+
# Call the gRPC service
1028+
response = self.command_stub.ProjectCurves(request=request)
1029+
1030+
# Return the response - formatted as a dictionary
1031+
return {
1032+
"faces": [
1033+
{
1034+
"id": face.id,
1035+
"surface_type": face.surface_type,
1036+
"is_reversed": face.is_reversed,
1037+
}
1038+
for face in response.faces
1039+
],
1040+
}
1041+
1042+
@protect_grpc
1043+
def imprint_projected_curves(self, **kwargs) -> dict: # noqa: D102
1044+
from ansys.api.geometry.v0.commands_pb2 import ProjectCurvesRequest
1045+
1046+
# Convert sketch and trimmed curves to gRPC format
1047+
sketch = kwargs["sketch"]
1048+
curves = from_sketch_shapes_to_grpc_geometries(
1049+
sketch.plane, sketch.edges, sketch.faces, kwargs["only_one_curve"]
1050+
)
1051+
1052+
# Create the request - assumes all inputs are valid and of the proper type
1053+
request = ProjectCurvesRequest(
1054+
body=kwargs["id"],
1055+
curves=curves,
1056+
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
1057+
closest_face=kwargs["closest_face"],
1058+
plane=from_plane_to_grpc_plane(sketch.plane),
1059+
)
1060+
1061+
# Call the gRPC service
1062+
response = self.command_stub.ImprintProjectedCurves(request=request)
1063+
1064+
# Return the response - formatted as a dictionary
1065+
return {
1066+
"faces": [
1067+
{
1068+
"id": face.id,
1069+
"surface_type": face.surface_type,
1070+
"is_reversed": face.is_reversed,
1071+
}
1072+
for face in response.faces
1073+
],
1074+
}

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,31 @@ def split_body(self, **kwargs) -> dict: # noqa: D102
203203
@protect_grpc
204204
def create_body_from_loft_profiles_with_guides(self, **kwargs) -> dict: # noqa: D102
205205
raise NotImplementedError
206+
207+
@protect_grpc
208+
def assign_midsurface_thickness(self, **kwargs) -> dict: # noqa: D102
209+
raise NotImplementedError
210+
211+
@protect_grpc
212+
def assign_midsurface_offset(self, **kwargs) -> dict: # noqa: D102
213+
raise NotImplementedError
214+
215+
@protect_grpc
216+
def shell(self, **kwargs) -> dict: # noqa: D102
217+
raise NotImplementedError
218+
219+
@protect_grpc
220+
def remove_faces(self, **kwargs) -> dict: # noqa: D102
221+
raise NotImplementedError
222+
223+
@protect_grpc
224+
def imprint_curves(self, **kwargs) -> dict: # noqa: D102
225+
raise NotImplementedError
226+
227+
@protect_grpc
228+
def project_curves(self, **kwargs) -> dict: # noqa: D102
229+
raise NotImplementedError
230+
231+
@protect_grpc
232+
def imprint_projected_curves(self, **kwargs) -> dict: # noqa: D102
233+
raise NotImplementedError

0 commit comments

Comments
 (0)