Skip to content

Commit f604299

Browse files
dastan-ansysjonahrbRobPasMue
authored
MAINT: remove duplicate id safeguarding (#527)
Co-authored-by: Jonah Boling <56607167+jonahrb@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Co-authored-by: jonahrb <jonahboling@gmail.com>
1 parent f3d1485 commit f604299

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
* [Jorge Martínez](https://github.com/jorgepiloto)
1717
* [Alejandro Fernández](https://github.com/AlejandroFernandezLuces)
1818
* [Lance Lance](https://github.com/LanceX2214)
19+
* [Dastan Abdulla](https://github.com/dastan-ansys)

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

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(
132132
CreateRequest(name=name, parent=parent_component.id, template=template_id)
133133
)
134134
# Remove this method call once we know Service sends correct ObjectPath id
135-
self._id = self.__remove_duplicate_ids(new_component.component.id)
135+
self._id = new_component.component.id
136136
self._name = new_component.component.name
137137
else:
138138
self._name = name
@@ -246,26 +246,6 @@ def __create_children(self, template: "Component") -> None:
246246
)
247247
self.components.append(new)
248248

249-
def __remove_duplicate_ids(self, path: str) -> str:
250-
"""
251-
Remove duplicate entries in the ID path.
252-
253-
Notes
254-
-----
255-
This is a safeguard, as the server is known to have issues sometimes.
256-
257-
Examples
258-
--------
259-
This method converts "0:26/0:44/0:44/0:53" to "0:26/0:44/0:53".
260-
"""
261-
# Split the string into a list -> convert list into a set but maintain order
262-
res = []
263-
[res.append(x) for x in path.split("/") if x not in res]
264-
id = "/".join(res)
265-
if id != path:
266-
print("Removed duplicate!")
267-
return id
268-
269249
def get_world_transform(self) -> Matrix44:
270250
"""
271251
Get the full transformation matrix of this Component in world space.
@@ -423,9 +403,7 @@ def extrude_sketch(
423403
response = self._bodies_stub.CreateExtrudedBody(request)
424404
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=False)
425405
self._transformed_part.part.bodies.append(tb)
426-
# TODO: fix when DMS ObjectPath is fixed - previously we return the body with response.id
427-
body_id = f"{self.id}/{tb.id}" if self.parent_component else tb.id
428-
return Body(body_id, response.name, self, tb)
406+
return Body(response.id, response.name, self, tb)
429407

430408
@protect_grpc
431409
@check_input_types
@@ -472,9 +450,7 @@ def extrude_face(self, name: str, face: Face, distance: Union[Quantity, Distance
472450

473451
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=False)
474452
self._transformed_part.part.bodies.append(tb)
475-
# TODO: fix when DMS ObjectPath is fixed - previously we return the body with response.id
476-
body_id = f"{self.id}/{tb.id}" if self.parent_component else tb.id
477-
return Body(body_id, response.name, self, tb)
453+
return Body(response.id, response.name, self, tb)
478454

479455
@protect_grpc
480456
@check_input_types
@@ -511,9 +487,7 @@ def create_surface(self, name: str, sketch: Sketch) -> Body:
511487

512488
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=True)
513489
self._transformed_part.part.bodies.append(tb)
514-
# TODO: fix when DMS ObjectPath is fixed - previously we return the body with response.id
515-
body_id = f"{self.id}/{tb.id}" if self.parent_component else tb.id
516-
return Body(body_id, response.name, self, tb)
490+
return Body(response.id, response.name, self, tb)
517491

518492
@protect_grpc
519493
@check_input_types
@@ -553,9 +527,7 @@ def create_surface_from_face(self, name: str, face: Face) -> Body:
553527

554528
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=True)
555529
self._transformed_part.part.bodies.append(tb)
556-
# TODO: fix when DMS ObjectPath is fixed - previously we return the body with response.id
557-
body_id = f"{self.id}/{tb.id}" if self.parent_component else tb.id
558-
return Body(body_id, response.name, self, tb)
530+
return Body(response.id, response.name, self, tb)
559531

560532
@check_input_types
561533
def create_coordinate_system(self, name: str, frame: Frame) -> CoordinateSystem:

0 commit comments

Comments
 (0)