Skip to content
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
4 changes: 2 additions & 2 deletions examples/modeling_features/01-sandwich-panel-layup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _sandwich_panel:

Sandwich panel example
======================
Sandwich panel
==============

This example defines a composite lay-up for a sandwich panel using PyACP.
It only shows the PyACP part of the setup. For a complete composite analysis,
Expand Down
4 changes: 2 additions & 2 deletions examples/modeling_features/02-simple-selection-rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _basic_selection_rules_example:

Basic selection rules example
=============================
Basic selection rules
=====================

This example shows the basic usage of selection rules, which enable you to select elements through
geometrical operations and thus to shape plies. The example only shows the PyACP part of the setup.
Expand Down
40 changes: 23 additions & 17 deletions examples/modeling_features/020-solid_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
get_directions_plotter,
launch_acp,
)
from ansys.acp.core.extras import ExampleKeys, get_example_file
from ansys.acp.core.extras import FLAT_PLATE_SOLID_CAMERA, ExampleKeys, get_example_file

# sphinx_gallery_thumbnail_number = 4

Expand Down Expand Up @@ -92,7 +92,23 @@
)

model.update()
model.solid_mesh.to_pyvista().plot(show_edges=True)


def plot_model_with_geometry(cad_geometry: CADGeometry | None, cad_geom_opacity: float = 0.1):
"""Plot solid model and geometry."""
plotter = pyvista.Plotter()
if cad_geometry:
geom_mesh = cad_geometry.visualization_mesh.to_pyvista()
plotter.add_mesh(geom_mesh, color="green", opacity=cad_geom_opacity)
edges = geom_mesh.extract_feature_edges()
plotter.add_mesh(edges, color="white", line_width=4)
plotter.add_mesh(edges, color="black", line_width=2)
plotter.add_mesh(model.solid_mesh.to_pyvista(), show_edges=True)
plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
plotter.show()


plot_model_with_geometry(None)


def create_virtual_geometry_from_file(
Expand All @@ -109,18 +125,6 @@ def create_virtual_geometry_from_file(
return geometry_obj, virtual_geometry


def plot_model_with_geometry(cad_geometry: CADGeometry, cad_geom_opacity: float = 0.1):
"""Plot solid model and geometry."""
plotter = pyvista.Plotter()
geom_mesh = cad_geometry.visualization_mesh.to_pyvista()
plotter.add_mesh(geom_mesh, color="green", opacity=cad_geom_opacity)
edges = geom_mesh.extract_feature_edges()
plotter.add_mesh(edges, color="white", line_width=4)
plotter.add_mesh(edges, color="black", line_width=2)
plotter.add_mesh(model.solid_mesh.to_pyvista(), show_edges=True)
plotter.show()


# %%
# Snap the top to a geometry
# --------------------------
Expand Down Expand Up @@ -160,7 +164,7 @@ def plot_model_with_geometry(cad_geometry: CADGeometry, cad_geom_opacity: float
depth=0.6,
)
model.update()
model.solid_mesh.to_pyvista().plot(show_edges=True)
plot_model_with_geometry(None)

# %%
# Cut-off an edge
Expand Down Expand Up @@ -208,7 +212,8 @@ def plot_model_with_geometry(cad_geometry: CADGeometry, cad_geom_opacity: float
length_factor=10.0,
culling_factor=10,
)
direction_plotter.add_mesh(model.solid_mesh.to_pyvista(), opacity=0.2, show_edges=True)
direction_plotter.add_mesh(model.solid_mesh.to_pyvista(), opacity=0.2, show_edges=False)
direction_plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
direction_plotter.show()

# %%
Expand All @@ -218,5 +223,6 @@ def plot_model_with_geometry(cad_geometry: CADGeometry, cad_geom_opacity: float
thickness_pyvista_mesh = thickness_data.get_pyvista_mesh(mesh=ap.solid_mesh) # type: ignore
plotter = pyvista.Plotter()
plotter.add_mesh(thickness_pyvista_mesh)
plotter.add_mesh(model.solid_mesh.to_pyvista(), opacity=0.2, show_edges=True)
plotter.add_mesh(model.solid_mesh.to_pyvista(), opacity=0.2, show_edges=False)
plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
plotter.show()
7 changes: 5 additions & 2 deletions examples/modeling_features/021-imported-solid-model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""
.. _imported_solid_model_example:

Imported Solid model
Imported solid model
====================

This example guides you through the definition of an :class:`.ImportedSolidModel`
Expand Down Expand Up @@ -58,7 +58,7 @@
from ansys.acp.core import ElementTechnology, LayupMappingRosetteSelectionMethod, launch_acp
from ansys.acp.core.extras import ExampleKeys, get_example_file

# sphinx_gallery_thumbnail_number = 3
# sphinx_gallery_thumbnail_number = 4


# %%
Expand Down Expand Up @@ -262,6 +262,9 @@
# as well. See example :ref:`solid_model_example` for more details.
# More plotting capabilities are shown in the example :ref:`solid_model_example` as well.
#
# An example of an :class:`.ImportedSolidModel` in combination with :class:`.ImportedModelingPly`
# is shown in :ref:`imported_plies_example`.
#
# The solid mesh can be exported as CDB for MAPDL or to PyMechanical for further analysis.
# These workflows are shown in :ref:`pymapdl_workflow_example` and
# :ref:`pymechanical_solid_example`.
4 changes: 2 additions & 2 deletions examples/modeling_features/03-advanced-selection-rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _advanced_selection_rules_example:

Advanced selection rules example
================================
Advanced selection rules
========================

This example shows how to use advanced rules, including the geometrical,
cut-off, and variable offset rules. It also demonstrates how rules can be templated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _thickness_definition_example:

Thickness definition example
============================
Thickness definition
====================

This example shows how the thickness of a ply can be defined by a geometry or a lookup table.
The example only shows the PyACP part of the setup. For a complete composite analysis,
Expand All @@ -46,7 +46,7 @@
# %%
# Import the PyACP dependencies.
from ansys.acp.core import DimensionType, ThicknessType, launch_acp
from ansys.acp.core.extras import ExampleKeys, get_example_file
from ansys.acp.core.extras import FLAT_PLATE_SOLID_CAMERA, ExampleKeys, get_example_file

# sphinx_gallery_thumbnail_number = 2

Expand Down Expand Up @@ -117,7 +117,7 @@
plotter.add_mesh(edges, color="black", line_width=2)
# Plot the ply thickness
plotter.add_mesh(model.elemental_data.thickness.get_pyvista_mesh(mesh=model.mesh), show_edges=True)

plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
plotter.show()

# %%
Expand Down
4 changes: 2 additions & 2 deletions examples/modeling_features/05-rosettes-ply-directions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _rosette_example:

Rosette example
===============
Rosette
=======

This example illustrates how you can use rosettes to define the reference directions of a ply.
It only shows the PyACP part of the setup. For a complete composite analysis,
Expand Down
Loading