-
Notifications
You must be signed in to change notification settings - Fork 22
chore: v1 implementation of patterns stub #2416
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
Open
jacobrkerstetter
wants to merge
21
commits into
main
Choose a base branch
from
chore/v1_patterns_impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8d16dc3
implement faces v1 - needs testing
jacobrkerstetter fb08ca4
Merge branch 'main' of https://github.com/ansys/pyansys-geometry into…
jacobrkerstetter 2a3fe73
added quantity conversion and fixed a few faces bugs
jacobrkerstetter 6ee5a1d
wip
jacobrkerstetter 2e1887d
faces/edges wip - failing some tests
jacobrkerstetter c9b613a
reverting v1 hardcode
jacobrkerstetter f3b7477
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] 5e8b48c
chore: adding changelog file 2412.maintenance.md [dependabot-skip]
pyansys-ci-bot c421ab3
extracting entity identifier id's
jacobrkerstetter f9a6f39
Merge branch 'chore/v1_faces_edges_impl' of https://github.com/ansys/…
jacobrkerstetter 903bd46
fix offsetfaces todo
jacobrkerstetter b7b53f9
Merge branch 'main' into chore/v1_faces_edges_impl
jacobrkerstetter 7ef54ea
resolving comments
jacobrkerstetter 1fa600b
Merge branch 'main' into chore/v1_faces_edges_impl
jacobrkerstetter bf487d4
Merge branch 'main' into chore/v1_faces_edges_impl
jacobrkerstetter b8ce12f
wip
jacobrkerstetter 2a0fdc9
final impl's
jacobrkerstetter f2d3bc3
full impl of patterns
jacobrkerstetter 7187ea1
Merge branch 'main' into chore/v1_patterns_impl
jacobrkerstetter 023b071
chore: auto fixes from pre-commit hooks
pre-commit-ci[bot] 5f8ede5
chore: adding changelog file 2416.maintenance.md [dependabot-skip]
pyansys-ci-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| V1 implementation of patterns stub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,8 +24,14 @@ | |
| import grpc | ||
|
|
||
| from ansys.geometry.core.errors import protect_grpc | ||
| from ansys.geometry.core.misc.measurements import Distance | ||
|
|
||
| from ..base.patterns import GRPCPatternsService | ||
| from .conversions import ( | ||
| build_grpc_id, | ||
| from_angle_to_grpc_quantity, | ||
| from_length_to_grpc_quantity, | ||
| ) | ||
|
|
||
|
|
||
| class GRPCPatternsServiceV1(GRPCPatternsService): # pragma: no cover | ||
|
|
@@ -43,30 +49,205 @@ class GRPCPatternsServiceV1(GRPCPatternsService): # pragma: no cover | |
|
|
||
| @protect_grpc | ||
| def __init__(self, channel: grpc.Channel): # noqa: D102 | ||
| from ansys.api.geometry.v1.patterns_pb2_grpc import PatternsStub | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2_grpc import PatternStub | ||
|
|
||
| self.stub = PatternsStub(channel) | ||
| self.stub = PatternStub(channel) | ||
|
|
||
| @protect_grpc | ||
| def create_linear_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import ( | ||
| LinearPatternCreationRequest, | ||
| LinearPatternCreationRequestData, | ||
| ) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = LinearPatternCreationRequest( | ||
| request_data=[ | ||
| LinearPatternCreationRequestData( | ||
| selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| linear_direction_id=build_grpc_id(kwargs["linear_direction_id"]), | ||
| count_x=kwargs["count_x"], | ||
| pitch_x=from_length_to_grpc_quantity(kwargs["pitch_x"]), | ||
| two_dimensional=kwargs["two_dimensional"], | ||
| count_y=kwargs["count_y"], | ||
| pitch_y=( | ||
| from_length_to_grpc_quantity(kwargs["pitch_y"]) | ||
| if kwargs["pitch_y"] | ||
| else from_length_to_grpc_quantity(Distance(0)) | ||
| ), | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.CreateLinear(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_creation_response.creation_response.success, | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def modify_linear_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import ( | ||
| SetLinearPatternDataRequest, | ||
| SetLinearPatternDataRequestData, | ||
| ) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = SetLinearPatternDataRequest( | ||
| request_data=[ | ||
| SetLinearPatternDataRequestData( | ||
| selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| count_x=kwargs["count_x"], | ||
| pitch_x=from_length_to_grpc_quantity(kwargs["pitch_x"]), | ||
| count_y=kwargs["count_y"], | ||
| pitch_y=from_length_to_grpc_quantity(kwargs["pitch_y"]), | ||
| new_seed_index=kwargs["new_seed_index"], | ||
| old_seed_index=kwargs["old_seed_index"], | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.SetLinearData(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_set_response.set_response.success, | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def create_circular_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import ( | ||
| CircularPatternCreationRequest, | ||
| CircularPatternCreationRequestData, | ||
| ) | ||
|
|
||
| from ansys.geometry.core.shapes.curves.line import Line | ||
|
|
||
| from .conversions import from_line_to_grpc_line, from_unit_vector_to_grpc_direction | ||
|
|
||
| # Create direction if not None | ||
| radial_direction = ( | ||
| from_unit_vector_to_grpc_direction(kwargs["radial_direction"]) | ||
| if kwargs["radial_direction"] is not None | ||
| else None | ||
| ) | ||
|
|
||
| # Create linear pitch if not None | ||
| linear_pitch = ( | ||
| from_length_to_grpc_quantity(kwargs["linear_pitch"]) | ||
| if kwargs["linear_pitch"] | ||
| else from_length_to_grpc_quantity(Distance(0.0)) | ||
| ) | ||
|
Comment on lines
+138
to
+143
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
|
|
||
| # Create line if axis is a line object | ||
| circular_axis, axis = None, None | ||
| if isinstance(kwargs["circular_axis"], Line): | ||
| axis = from_line_to_grpc_line(kwargs["circular_axis"]) | ||
| else: | ||
| circular_axis = build_grpc_id(kwargs["circular_axis"]) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = CircularPatternCreationRequest( | ||
| request_data=[ | ||
| CircularPatternCreationRequestData( | ||
| selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| circular_count=kwargs["circular_count"], | ||
| edge_axis_id=circular_axis, | ||
| circular_angle=from_angle_to_grpc_quantity(kwargs["circular_angle"]), | ||
| two_dimensional=kwargs["two_dimensional"], | ||
| linear_count=kwargs["linear_count"], | ||
| linear_pitch=linear_pitch, | ||
| radial_direction=radial_direction, | ||
| line_axis=axis, | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.CreateCircular(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_creation_response.creation_response.success, | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def modify_circular_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import ( | ||
| SetCircularPatternDataRequest, | ||
| SetCircularPatternDataRequestData, | ||
| ) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = SetCircularPatternDataRequest( | ||
| request_data=[ | ||
| SetCircularPatternDataRequestData( | ||
| selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| circular_count=kwargs["circular_count"], | ||
| linear_count=kwargs["linear_count"], | ||
| step_angle=from_angle_to_grpc_quantity(kwargs["step_angle"]), | ||
| step_linear=from_length_to_grpc_quantity(kwargs["step_linear"]), | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.SetCircularData(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_set_response.set_response.success, | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def create_fill_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import ( | ||
| FillPatternCreationRequest, | ||
| FillPatternCreationRequestData, | ||
| ) | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = FillPatternCreationRequest( | ||
| request_data=[ | ||
| FillPatternCreationRequestData( | ||
| selection_ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| linear_direction_id=build_grpc_id(kwargs["linear_direction_id"]), | ||
| fill_pattern_type=kwargs["fill_pattern_type"].value, | ||
| margin=from_length_to_grpc_quantity(kwargs["margin"]), | ||
| x_spacing=from_length_to_grpc_quantity(kwargs["x_spacing"]), | ||
| y_spacing=from_length_to_grpc_quantity(kwargs["y_spacing"]), | ||
| row_x_offset=from_length_to_grpc_quantity(kwargs["row_x_offset"]), | ||
| row_y_offset=from_length_to_grpc_quantity(kwargs["row_y_offset"]), | ||
| column_x_offset=from_length_to_grpc_quantity(kwargs["column_x_offset"]), | ||
| column_y_offset=from_length_to_grpc_quantity(kwargs["column_y_offset"]), | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.CreateFill(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_creation_response.creation_response.success, | ||
| } | ||
|
|
||
| @protect_grpc | ||
| def update_fill_pattern(self, **kwargs) -> dict: # noqa: D102 | ||
| raise NotImplementedError | ||
| from ansys.api.discovery.v1.design.relationships.pattern_pb2 import UpdateFillRequest | ||
|
|
||
| # Create the request - assumes all inputs are valid and of the proper type | ||
| request = UpdateFillRequest( | ||
| ids=[build_grpc_id(id) for id in kwargs["selection_ids"]], | ||
| ) | ||
|
|
||
| # Call the gRPC service | ||
| response = self.stub.UpdateFill(request) | ||
|
|
||
| # Return the response - formatted as a dictionary | ||
| return { | ||
| "success": response.tracked_command_response.command_response.success, | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this come from the call itself? I would rather avoid any logic inside the _grpc layer