Skip to content

fix!: Adapt to new visualizer version #2055

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

Merged
merged 6 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/2055.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adapt to new visualizer version
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ dependencies = [

[project.optional-dependencies]
graphics = [
"ansys-tools-visualization-interface>=0.2.6,<0.10",
"ansys-tools-visualization-interface>=0.10.0,<1",
"pygltflib>=1.16,<2",
"pyvista[jupyter]>=0.38.1,<1",
"vtk>=9,<10",
]
all = [
"ansys-platform-instancemanagement>=1.0.3,<2",
"ansys-tools-visualization-interface>=0.2.6,<0.10",
"ansys-tools-visualization-interface>=0.10.0,<1",
"docker>=6.0.1,<8",
"pygltflib>=1.16,<2",
"pyvista[jupyter]>=0.38.1,<1",
Expand All @@ -58,7 +58,7 @@ all = [
tests = [
"ansys-platform-instancemanagement==1.1.2",
"ansys-tools-path==0.7.3",
"ansys-tools-visualization-interface==0.9.2",
"ansys-tools-visualization-interface==0.10.0",
"beartype==0.21.0",
"docker==7.1.0",
"geomdl==5.4.0",
Expand Down Expand Up @@ -87,7 +87,7 @@ tests-minimal = [
doc = [
"ansys-sphinx-theme[autoapi]==1.5.2",
"ansys-tools-path==0.7.3",
"ansys-tools-visualization-interface==0.9.2",
"ansys-tools-visualization-interface==0.10.0",
"beartype==0.21.0",
"docker==7.1.0",
"geomdl==5.4.0",
Expand Down
7 changes: 6 additions & 1 deletion src/ansys/geometry/core/designer/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ def plot(
screenshot: str | None = None,
use_trame: bool | None = None,
use_service_colors: bool | None = None,
show_options: dict | None = {},
**plotting_options: dict | None,
) -> None:
"""Plot the body.
Expand All @@ -664,6 +665,8 @@ def plot(
Whether to use the colors assigned to the body in the service. The default
is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS``
global setting is used.
show_options : dict, default: {}
Keyword arguments for the show method of the plotter.
**plotting_options : dict, default: None
Keyword arguments for plotting. For allowable keyword arguments, see the
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
Expand Down Expand Up @@ -1281,6 +1284,7 @@ def plot( # noqa: D102
screenshot: str | None = None,
use_trame: bool | None = None,
use_service_colors: bool | None = None,
show_options: dict | None = {},
**plotting_options: dict | None,
) -> None:
raise NotImplementedError(
Expand Down Expand Up @@ -1743,6 +1747,7 @@ def plot( # noqa: D102
screenshot: str | None = None,
use_trame: bool | None = None,
use_service_colors: bool | None = None,
show_options: dict | None = {},
**plotting_options: dict | None,
) -> None:
# lazy import here to improve initial module load time
Expand Down Expand Up @@ -1774,7 +1779,7 @@ def plot( # noqa: D102
)
pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors)
pl.plot(mesh_object, **plotting_options)
pl.show(screenshot=screenshot, **plotting_options)
pl.show(screenshot=screenshot, **show_options)

def intersect(self, other: Union["Body", Iterable["Body"]], keep_other: bool = False) -> None: # noqa: D102
if self._template._grpc_client.backend_version < __TEMPORARY_BOOL_OPS_FIX__:
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/geometry/core/designer/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,7 @@ def plot(
use_trame: bool | None = None,
use_service_colors: bool | None = None,
allow_picking: bool | None = None,
show_options: dict | None = {},
**plotting_options: dict | None,
) -> None | list[Any]:
"""Plot the component.
Expand Down Expand Up @@ -1605,6 +1606,8 @@ def plot(
allow_picking : bool, default: None
Whether to enable picking. The default is ``None``, in which case the
picker is not enabled.
show_options : dict, default: {}
Keyword arguments for the show method of the plotter.
**plotting_options : dict, default: None
Keyword arguments for plotting. For allowable keyword arguments, see the

Expand Down Expand Up @@ -1692,7 +1695,7 @@ def plot(
allow_picking=allow_picking,
)
pl.plot(self, **plotting_options)
return pl.show(screenshot=screenshot, **plotting_options)
return pl.show(screenshot=screenshot, **show_options)

def __repr__(self) -> str:
"""Represent the ``Component`` as a string."""
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/geometry/core/designer/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ def plot(
screenshot: str | None = None,
use_trame: bool | None = None,
use_service_colors: bool | None = None,
show_options: dict | None = {},
**plotting_options: dict | None,
) -> None:
"""Plot the face.
Expand All @@ -553,6 +554,8 @@ def plot(
Whether to use the colors assigned to the face in the service. The default
is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS``
global setting is used.
show_options : dict, default: {}
Keyword arguments for the show method of the plotter.
**plotting_options : dict, default: None
Keyword arguments for plotting. For allowable keyword arguments, see the
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
Expand All @@ -574,4 +577,4 @@ def plot(
mesh_object = self if use_service_colors else MeshObjectPlot(self, self.tessellate())
pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors)
pl.plot(mesh_object, **plotting_options)
pl.show(screenshot=screenshot, **plotting_options)
pl.show(screenshot=screenshot, **show_options)
10 changes: 7 additions & 3 deletions src/ansys/geometry/core/plotting/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ def show(
self,
plotting_object: Any = None,
screenshot: str | None = None,
**plotting_options,
plotting_options: dict | None = {},
**show_options: dict | None,
) -> None | list[Any]:
"""Show the plotter.

Expand All @@ -515,13 +516,16 @@ def show(
Object you can add to the plotter.
screenshot : str, default: None
Path to save a screenshot of the plotter.
**plotting_options : dict, default: None
plotting_options : dict, default: {}
Keyword arguments for the plotter. Arguments depend of the backend implementation
you are using.
**show_options : dict, default: None
Keyword arguments for the show method. Arguments depend of the backend
implementation you are using.
"""
if plotting_object is not None:
self.plot(plotting_object, **plotting_options)
picked_objs = self._backend.show(screenshot=screenshot, **plotting_options)
picked_objs = self._backend.show(screenshot=screenshot, **show_options)

# Return the picked objects if picking is enabled... but as the actual PyAnsys
# Geometry objects (or PyVista objects if not)
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/geometry/core/sketch/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ def plot(
screenshot: str | None = None,
use_trame: bool | None = None,
selected_pd_objects: list["PolyData"] = None,
show_options: dict | None = {},
**plotting_options: dict | None,
):
"""Plot all objects of the sketch to the scene.
Expand Down Expand Up @@ -917,7 +918,7 @@ def plot(
view_2d_dict = {"vector": vector, "viewup": viewup}
else:
view_2d_dict = None
plotting_options.pop("view_2d", None)
# plotting_options.pop("view_2d", None)
if selected_pd_objects is not None:
pl = GeometryPlotter(use_trame=use_trame)
pl.plot(
Expand All @@ -928,13 +929,13 @@ def plot(
pl.show(
screenshot=screenshot,
view_2d=view_2d_dict,
**plotting_options,
**show_options,
)
else:
pl = GeometryPlotter(use_trame=use_trame)
pl.plot(self.sketch_polydata_faces(), opacity=0.7, **plotting_options)
pl.plot(self.sketch_polydata_edges(), **plotting_options)
pl.show(screenshot=screenshot, view_2d=view_2d_dict, **plotting_options)
pl.show(screenshot=screenshot, view_2d=view_2d_dict, **show_options)

@graphics_required
def plot_selection(
Expand Down
Loading