Skip to content

Commit c9b613a

Browse files
reverting v1 hardcode
fixing some conversions and small bugs
1 parent 2e1887d commit c9b613a

File tree

4 files changed

+39
-38
lines changed

4 files changed

+39
-38
lines changed

src/ansys/geometry/core/_grpc/_services/_service.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,15 @@ def edges(self) -> GRPCEdgesService:
410410
# Import the appropriate edges service based on the version
411411
from .v0.edges import GRPCEdgesServiceV0
412412
from .v1.edges import GRPCEdgesServiceV1
413-
self._edges = GRPCEdgesServiceV1(self.channel)
414413

415-
# if self.version == GeometryApiProtos.V0:
416-
# self._edges = GRPCEdgesServiceV0(self.channel)
417-
# elif self.version == GeometryApiProtos.V1: # pragma: no cover
418-
# # V1 is not implemented yet
419-
# self._edges = GRPCEdgesServiceV1(self.channel)
420-
# else: # pragma: no cover
421-
# # This should never happen as the version is set in the constructor
422-
# raise ValueError(f"Unsupported version: {self.version}")
414+
if self.version == GeometryApiProtos.V0:
415+
self._edges = GRPCEdgesServiceV0(self.channel)
416+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
417+
# V1 is not implemented yet
418+
self._edges = GRPCEdgesServiceV1(self.channel)
419+
else: # pragma: no cover
420+
# This should never happen as the version is set in the constructor
421+
raise ValueError(f"Unsupported version: {self.version}")
423422

424423
return self._edges
425424

@@ -437,16 +436,15 @@ def faces(self) -> GRPCFacesService:
437436
# Import the appropriate faces service based on the version
438437
from .v0.faces import GRPCFacesServiceV0
439438
from .v1.faces import GRPCFacesServiceV1
440-
self._faces = GRPCFacesServiceV1(self.channel)
441-
442-
# if self.version == GeometryApiProtos.V0:
443-
# self._faces = GRPCFacesServiceV0(self.channel)
444-
# elif self.version == GeometryApiProtos.V1: # pragma: no cover
445-
# # V1 is not implemented yet
446-
# self._faces = GRPCFacesServiceV1(self.channel)
447-
# else: # pragma: no cover
448-
# # This should never happen as the version is set in the constructor
449-
# raise ValueError(f"Unsupported version: {self.version}")
439+
440+
if self.version == GeometryApiProtos.V0:
441+
self._faces = GRPCFacesServiceV0(self.channel)
442+
elif self.version == GeometryApiProtos.V1: # pragma: no cover
443+
# V1 is not implemented yet
444+
self._faces = GRPCFacesServiceV1(self.channel)
445+
else: # pragma: no cover
446+
# This should never happen as the version is set in the constructor
447+
raise ValueError(f"Unsupported version: {self.version}")
450448

451449
return self._faces
452450

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ def from_point3d_to_grpc_point(point: "Point3D") -> GRPCPoint:
179179
from ansys.geometry.core.misc.measurements import DEFAULT_UNITS
180180

181181
return GRPCPoint(
182-
x=point.x.m_as(DEFAULT_UNITS.SERVER_LENGTH),
183-
y=point.y.m_as(DEFAULT_UNITS.SERVER_LENGTH),
184-
z=point.z.m_as(DEFAULT_UNITS.SERVER_LENGTH),
182+
x=GRPCQuantity(value_in_geometry_units=point.x.m_as(DEFAULT_UNITS.SERVER_LENGTH)),
183+
y=GRPCQuantity(value_in_geometry_units=point.y.m_as(DEFAULT_UNITS.SERVER_LENGTH)),
184+
z=GRPCQuantity(value_in_geometry_units=point.z.m_as(DEFAULT_UNITS.SERVER_LENGTH)),
185185
)
186186

187187

@@ -987,7 +987,6 @@ def from_grpc_curve_to_curve(curve: GRPCCurveGeometry) -> "Curve":
987987
Curve
988988
Resulting converted curve.
989989
"""
990-
from ansys.geometry.core.math.point import Point3D
991990
from ansys.geometry.core.math.vector import UnitVector3D
992991
from ansys.geometry.core.shapes.curves.circle import Circle
993992
from ansys.geometry.core.shapes.curves.ellipse import Ellipse
@@ -1000,10 +999,13 @@ def from_grpc_curve_to_curve(curve: GRPCCurveGeometry) -> "Curve":
1000999
except ValueError:
10011000
# curve will be a line
10021001
pass
1003-
if curve.radius != 0:
1004-
result = Circle(origin, curve.radius, reference, axis)
1005-
elif curve.major_radius != 0 and curve.minor_radius != 0:
1006-
result = Ellipse(origin, curve.major_radius, curve.minor_radius, reference, axis)
1002+
1003+
major_radius = curve.major_radius.value_in_geometry_units
1004+
minor_radius = curve.minor_radius.value_in_geometry_units
1005+
if curve.radius.value_in_geometry_units != 0:
1006+
result = Circle(origin, curve.radius.value_in_geometry_units, reference, axis)
1007+
elif major_radius != 0 and minor_radius != 0:
1008+
result = Ellipse(origin, major_radius, minor_radius, reference, axis)
10071009
elif curve.nurbs_curve.nurbs_data.degree != 0:
10081010
result = from_grpc_nurbs_curve_to_nurbs_curve(curve.nurbs_curve)
10091011
elif curve.direction is not None:
@@ -1446,15 +1448,15 @@ def serialize_entity_identifier(entity):
14461448
}
14471449

14481450
return {
1449-
"success": getattr(response, "success", False),
1451+
"success": getattr(response.command_response, "success", False),
14501452
"created_bodies": [
1451-
serialize_body(body) for body in getattr(response, "created_bodies", [])
1453+
serialize_body(body) for body in getattr(response.tracked_changes, "created_bodies", [])
14521454
],
14531455
"modified_bodies": [
1454-
serialize_body(body) for body in getattr(response, "modified_bodies", [])
1456+
serialize_body(body) for body in getattr(response.tracked_changes, "modified_bodies", [])
14551457
],
14561458
"deleted_bodies": [
14571459
serialize_entity_identifier(entity)
1458-
for entity in getattr(response, "deleted_bodies", [])
1460+
for entity in getattr(response.tracked_changes, "deleted_bodies", [])
14591461
],
14601462
}

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def revolve_faces(self, **kwargs) -> dict: # noqa: D102
433433
RevolveFacesRequestData(
434434
selection_id=[build_grpc_id(id) for id in kwargs["selection_ids"]],
435435
axis=from_line_to_grpc_line(kwargs["axis"]),
436-
angle=from_measurement_to_server_angle(kwargs["angle"]),
436+
angle=from_angle_to_grpc_quantity(kwargs["angle"]),
437437
extrude_type=kwargs["extrude_type"].value,
438438
)
439439
]
@@ -493,9 +493,9 @@ def revolve_faces_by_helix(self, **kwargs) -> dict: # noqa: D102
493493
selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]],
494494
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
495495
axis=from_line_to_grpc_line(kwargs["axis"]),
496-
height=from_measurement_to_server_length(kwargs["height"]),
497-
pitch=from_measurement_to_server_length(kwargs["pitch"]),
498-
taper_angle=from_measurement_to_server_angle(kwargs["taper_angle"]),
496+
height=from_length_to_grpc_quantity(kwargs["height"]),
497+
pitch=from_length_to_grpc_quantity(kwargs["pitch"]),
498+
taper_angle=from_angle_to_grpc_quantity(kwargs["taper_angle"]),
499499
right_handed=kwargs["right_handed"],
500500
both_sides=kwargs["both_sides"],
501501
extrude_type=kwargs["extrude_type"].value,
@@ -510,7 +510,9 @@ def revolve_faces_by_helix(self, **kwargs) -> dict: # noqa: D102
510510
# Return the response - formatted as a dictionary
511511
return {
512512
"success": tracked_response.get("success"),
513-
"created_bodies": [body.get("id") for body in tracked_response.get("created_bodies")],
513+
"created_bodies": [
514+
body.get("id").id for body in tracked_response.get("created_bodies")
515+
],
514516
}
515517

516518
@protect_grpc
@@ -613,7 +615,7 @@ def offset_faces(self, **kwargs) -> dict: # noqa: D102
613615
request = OffsetFacesRequest(
614616
request_data=[
615617
OffsetFacesRequestData(
616-
faces=[build_grpc_id(id) for id in kwargs["face_ids"]],
618+
face_ids=[build_grpc_id(id) for id in kwargs["face_ids"]],
617619
offset=from_measurement_to_server_length(kwargs["distance"]),
618620
direction=from_unit_vector_to_grpc_direction(kwargs["direction"]),
619621
extrude_type=kwargs["extrude_type"].value,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ def get_named_selections(self) -> list["NamedSelection"]:
543543
"""
544544
included_ns = []
545545
for ns in get_design_from_body(self.body).named_selections:
546-
print([face.id for face in ns.faces])
547546
if any(face.id == self.id for face in ns.faces):
548547
included_ns.append(ns)
549548

0 commit comments

Comments
 (0)