Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename object #1648

Merged
merged 33 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
eae158e
wip
Jan 15, 2025
ee2299f
wip, failing test
Jan 15, 2025
4752da5
test written - not passing
Jan 15, 2025
7914676
rename_object fully implemented
Jan 16, 2025
08d073a
Merge branch 'blitz' of https://github.com/ansys/pyansys-geometry int…
Jan 16, 2025
bcaa5fb
fixing conflicts and repushing
Jan 16, 2025
b8fa7f9
adding decorators
Jan 16, 2025
e58c04b
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 16, 2025
9ce2c77
chore: adding changelog file 1648.added.md [dependabot-skip]
pyansys-ci-bot Jan 16, 2025
c3d05c1
fixed documentation
Jan 17, 2025
4b9ce29
Merge branch 'feat/jacob_rename_object' of https://github.com/ansys/p…
Jan 17, 2025
c3e4966
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 17, 2025
bdbc181
Merge branch 'blitz' into feat/jacob_rename_object
jacobrkerstetter Jan 17, 2025
9845ef7
Merge branch 'blitz' of https://github.com/ansys/pyansys-geometry int…
Jan 17, 2025
750e037
Merge branch 'feat/jacob_rename_object' of https://github.com/ansys/p…
Jan 17, 2025
91cfa5a
precommit fix
Jan 17, 2025
56df763
Merge branch 'blitz' into feat/jacob_rename_object
jacobrkerstetter Jan 17, 2025
832fc46
Merge branch 'blitz' into feat/jacob_rename_object
jacobrkerstetter Jan 17, 2025
830edfa
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 17, 2025
664a97e
wip
Jan 17, 2025
c5e5777
Merge branch 'blitz' of https://github.com/ansys/pyansys-geometry int…
Jan 20, 2025
b03bf48
Merge branch 'blitz' into feat/jacob_rename_object
jacobrkerstetter Jan 20, 2025
a07cc53
added rename component test
Jan 20, 2025
10ac3b6
Merge branch 'feat/jacob_rename_object' of https://github.com/ansys/p…
Jan 20, 2025
cb90c53
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 20, 2025
a53dc58
Merge branch 'blitz' into feat/jacob_rename_object
jacobrkerstetter Jan 20, 2025
9536f8c
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 20, 2025
6abfa16
fixed input types for rename_object
Jan 20, 2025
1984e45
Merge branch 'feat/jacob_rename_object' of https://github.com/ansys/p…
Jan 20, 2025
7c27e86
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 20, 2025
892d1e1
Update src/ansys/geometry/core/designer/geometry_commands.py
RobPasMue Jan 20, 2025
3863ff4
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] Jan 20, 2025
1f98aee
Update src/ansys/geometry/core/designer/geometry_commands.py
RobPasMue Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/1648.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rename object
21 changes: 20 additions & 1 deletion src/ansys/geometry/core/designer/geometry_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from enum import Enum, unique
from typing import TYPE_CHECKING, List, Union

from ansys.api.dbu.v0.dbumodels_pb2 import EntityIdentifier
from ansys.api.geometry.v0.commands_pb2 import (
ChamferRequest,
ExtrudeEdgesRequest,
Expand All @@ -32,6 +33,7 @@
ExtrudeFacesUpToRequest,
FilletRequest,
FullFilletRequest,
RenameObjectRequest,
)
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
from ansys.geometry.core.connection import GrpcClient
Expand Down Expand Up @@ -294,7 +296,7 @@ def extrude_faces_up_to(
seed_point : Point3D
Origin to define the extrusion.
direction : UnitVector3D, default: None
Direction of extrusion.
Direction of extrusion. If no direction is provided, it will be inferred.
extrude_type : ExtrudeType, default: ExtrudeType.ADD
Type of extrusion to be performed.
offset_mode : OffsetMode, default: OffsetMode.MOVE_FACES_TOGETHER
Expand Down Expand Up @@ -479,3 +481,20 @@ def extrude_edges_up_to(
else:
self._grpc_client.log.info("Failed to extrude edges.")
return []

@protect_grpc
@min_backend_version(25, 2, 0)
def rename_object(self, selection: List[EntityIdentifier], name: str) -> bool:
jacobrkerstetter marked this conversation as resolved.
Show resolved Hide resolved
jacobrkerstetter marked this conversation as resolved.
Show resolved Hide resolved
"""Rename an object.

selection : List[str]
Selection of the object to rename.
name : str
New name for the object.
bool
``True`` when successful, ``False`` when failed.
"""
jacobrkerstetter marked this conversation as resolved.
Show resolved Hide resolved
result = self._commands_stub.RenameObject(
RenameObjectRequest(selection=selection, name=name)
)
return result.success
23 changes: 22 additions & 1 deletion tests/integration/test_geometry_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pint import Quantity
import pytest

from ansys.geometry.core.designer.geometry_commands import ExtrudeType, OffsetMode
from ansys.geometry.core.designer.geometry_commands import EntityIdentifier, ExtrudeType, OffsetMode
from ansys.geometry.core.math import Point3D, UnitVector3D
from ansys.geometry.core.math.point import Point2D
from ansys.geometry.core.misc import UNITS
Expand Down Expand Up @@ -252,3 +252,24 @@ def test_extrude_edges_and_up_to(modeler: Modeler):
assert created_bodies[0].faces[3].area.m == pytest.approx(
Quantity(6, UNITS.m**2).m, rel=1e-6, abs=1e-8
)


def test_rename_object(modeler: Modeler):
jacobrkerstetter marked this conversation as resolved.
Show resolved Hide resolved
"""Test renaming objects."""
design = modeler.create_design("rename")
body = design.extrude_sketch("box", Sketch().box(Point2D([0, 0]), 1, 1), 1)

selection = [EntityIdentifier(id=body.id)]
result = modeler.geometry_commands.rename_object(selection, "new_name")
design._update_design_inplace()

body = design.bodies[0]
assert result == True
assert body.name == "new_name"

result = modeler.geometry_commands.rename_object(selection, "new_name2")
design._update_design_inplace()

body = design.bodies[0]
assert result == True
assert body.name == "new_name2"
Loading