Skip to content
Merged
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
* [Jorge Martínez](https://github.com/jorgepiloto)
* [Alejandro Fernández](https://github.com/AlejandroFernandezLuces)
* [Lance Lance](https://github.com/LanceX2214)
* [Dastan Abdulla](https://github.com/dastan-ansys)
38 changes: 5 additions & 33 deletions src/ansys/geometry/core/designer/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(
CreateRequest(name=name, parent=parent_component.id, template=template_id)
)
# Remove this method call once we know Service sends correct ObjectPath id
self._id = self.__remove_duplicate_ids(new_component.component.id)
self._id = new_component.component.id
self._name = new_component.component.name
else:
self._name = name
Expand Down Expand Up @@ -246,26 +246,6 @@ def __create_children(self, template: "Component") -> None:
)
self.components.append(new)

def __remove_duplicate_ids(self, path: str) -> str:
"""
Remove duplicate entries in the ID path.

Notes
-----
This is a safeguard, as the server is known to have issues sometimes.

Examples
--------
This method converts "0:26/0:44/0:44/0:53" to "0:26/0:44/0:53".
"""
# Split the string into a list -> convert list into a set but maintain order
res = []
[res.append(x) for x in path.split("/") if x not in res]
id = "/".join(res)
if id != path:
print("Removed duplicate!")
return id

def get_world_transform(self) -> Matrix44:
"""
Get the full transformation matrix of this Component in world space.
Expand Down Expand Up @@ -423,9 +403,7 @@ def extrude_sketch(
response = self._bodies_stub.CreateExtrudedBody(request)
tb = TemplateBody(response.master_id, name, self._grpc_client, is_surface=False)
self._transformed_part.part.bodies.append(tb)
# TODO: fix when DMS ObjectPath is fixed - previously we return the body with response.id
body_id = f"{self.id}/{tb.id}" if self.parent_component else tb.id
return Body(body_id, response.name, self, tb)
return Body(response.id, response.name, self, tb)

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

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

@protect_grpc
@check_input_types
Expand Down Expand Up @@ -511,9 +487,7 @@ def create_surface(self, name: str, sketch: Sketch) -> Body:

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

@protect_grpc
@check_input_types
Expand Down Expand Up @@ -553,9 +527,7 @@ def create_surface_from_face(self, name: str, face: Face) -> Body:

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

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