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 27 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
31 changes: 25 additions & 6 deletions 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,
CreateCircularPatternRequest,
Expand All @@ -37,6 +38,7 @@
FullFilletRequest,
ModifyLinearPatternRequest,
PatternRequest,
RenameObjectRequest,
)
from ansys.api.geometry.v0.commands_pb2_grpc import CommandsStub
from ansys.geometry.core.connection import GrpcClient
Expand Down Expand Up @@ -308,7 +310,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 @@ -496,6 +498,28 @@ def extrude_edges_up_to(

@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.

Parameters
----------
selection : List[str]
Selection of the object to rename.
name : str
New name for the object.

Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
result = self._commands_stub.RenameObject(
RenameObjectRequest(
selection=[EntityIdentifier(id=entity_id) for entity_id in selection], name=name
)
)
return result.success

def create_linear_pattern(
self,
selection: Union["Face", List["Face"]],
Expand Down Expand Up @@ -524,11 +548,6 @@ def create_linear_pattern(
How many times the pattern repeats in the y direction.
pitch_y : Real, default: None
The spacing between each pattern member in the y direction.
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved

Returns
-------
bool
``True`` when successful, ``False`` when failed.
"""
from ansys.geometry.core.designer.face import Face

Expand Down
42 changes: 42 additions & 0 deletions tests/integration/test_geometry_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,48 @@ def test_extrude_edges_and_up_to(modeler: Modeler):
)


def test_rename_body_object(modeler: Modeler):
"""Test renaming body objects."""
design = modeler.create_design("rename")
body = design.extrude_sketch("box", Sketch().box(Point2D([0, 0]), 1, 1), 1)

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

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

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

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


def test_rename_component_object(modeler: Modeler):
"""Test renaming component objects."""
design = modeler.create_design("rename_component")
body = design.extrude_sketch("box", Sketch().box(Point2D([0, 0]), 1, 1), 1)

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

component = body.parent_component
assert result
assert component.name == "new_name"

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

component = body.parent_component
assert result
assert component.name == "new_name2"


def test_linear_pattern(modeler: Modeler):
design = modeler.create_design("linear_pattern")
body = design.extrude_sketch("box", Sketch().box(Point2D([0, 0]), 1, 1), 1)
Expand Down
Loading