The auxiliary.py module#

Summary#

get_design_from_component

Get the Design of the given Component object.

get_design_from_body

Get the Design of the given Body object.

get_design_from_face

Get the Design of the given Face object.

get_design_from_edge

Get the Design of the given Edge object.

get_all_bodies_from_design

Find all the Body objects inside a Design.

get_bodies_from_ids

Find the Body objects inside a Design from its ids.

get_components_from_ids

Find the Component objects inside a Design from its ids.

get_faces_from_ids

Find the Face objects inside a Design from its ids.

get_edges_from_ids

Find the Edge objects inside a Design from its ids.

build_edge_id_map

Build a mapping of edge id to Edge object for all edges in a Design.

get_vertices_from_ids

Find the Vertex objects inside a Design from its ids.

get_beams_from_ids

Find the Beam objects inside a Design from its ids.

get_design_points_from_ids

Find the DesignPoint objects inside a Design from its ids.

get_design_curves_from_ids

Find the DesignCurve objects inside a Design from its ids.

convert_color_to_hex

Get the hex string color from input formats.

convert_opacity_to_hex

Get the hex string from an opacity value.

prepare_file_for_server_upload

Create a zip file from the given file path.

extract_project_from_zip

Extract a zip file to a specified directory.

Description#

Auxiliary functions for the PyAnsys Geometry library.

Module detail#

ansys.geometry.core.misc.auxiliary.get_design_from_component(component: ansys.geometry.core.designer.component.Component) ansys.geometry.core.designer.design.Design#

Get the Design of the given Component object.

Parameters:
componentComponent

The component object for which to find the Design.

Returns:
Design

The Design of the provided component object.

ansys.geometry.core.misc.auxiliary.get_design_from_body(body: ansys.geometry.core.designer.body.Body) ansys.geometry.core.designer.design.Design#

Get the Design of the given Body object.

Parameters:
bodyBody

The body object for which to find the Design.

Returns:
Design

The Design of the provided body object.

ansys.geometry.core.misc.auxiliary.get_design_from_face(face: ansys.geometry.core.designer.face.Face) ansys.geometry.core.designer.design.Design#

Get the Design of the given Face object.

Parameters:
faceFace

The face object for which to find the Design.

Returns:
Design

The Design of the provided face object.

ansys.geometry.core.misc.auxiliary.get_design_from_edge(edge: ansys.geometry.core.designer.edge.Edge) ansys.geometry.core.designer.design.Design#

Get the Design of the given Edge object.

Parameters:
edgeEdge

The edge object for which to find the Design.

Returns:
Design

The Design of the provided edge object.

ansys.geometry.core.misc.auxiliary.get_all_bodies_from_design(design: ansys.geometry.core.designer.design.Design) list[ansys.geometry.core.designer.body.Body]#

Find all the Body objects inside a Design.

Parameters:
designDesign

Parent design for the bodies.

Returns:
list[Body]

List of Body objects.

Notes

This method takes a design and gets the corresponding Body objects.

ansys.geometry.core.misc.auxiliary.get_bodies_from_ids(design: ansys.geometry.core.designer.design.Design, body_ids: list[str]) list[ansys.geometry.core.designer.body.Body]#

Find the Body objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the faces.

body_idslist[str]

List of body ids.

Returns:
list[Body]

List of Body objects.

Notes

This method takes a design and body ids, and gets their corresponding Body object.

ansys.geometry.core.misc.auxiliary.get_components_from_ids(design: ansys.geometry.core.designer.design.Design, component_ids: list[str]) list[ansys.geometry.core.designer.component.Component]#

Find the Component objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the components.

component_idslist[str]

List of component ids.

Returns:
list[Component]

List of Component objects.

Notes

This method takes a design and component ids, and gets their corresponding Component object.

ansys.geometry.core.misc.auxiliary.get_faces_from_ids(design: ansys.geometry.core.designer.design.Design, face_ids: list[str]) list[ansys.geometry.core.designer.face.Face]#

Find the Face objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the faces.

face_idslist[str]

List of face ids.

Returns:
list[Face]

List of Face objects.

Notes

This method takes a design and face ids, and gets their corresponding Face object.

ansys.geometry.core.misc.auxiliary.get_edges_from_ids(design: ansys.geometry.core.designer.design.Design, edge_ids: list[str]) list[ansys.geometry.core.designer.edge.Edge]#

Find the Edge objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the edges.

edge_idslist[str]

List of edge ids.

Returns:
list[Edge]

List of Edge objects.

Notes

This method takes a design and edge ids, and gets their corresponding Edge objects.

ansys.geometry.core.misc.auxiliary.build_edge_id_map(design: ansys.geometry.core.designer.design.Design) dict[str, Edge]#

Build a mapping of edge id to Edge object for all edges in a Design.

Parameters:
designDesign

Parent design to traverse.

Returns:
dict[str, Edge]

Dictionary mapping each edge id to its corresponding Edge object.

Notes

This method traverses the design tree once and issues one gRPC call per body (body.edges). Use this instead of repeated calls to get_edges_from_ids when you need to resolve multiple sets of edge ids from the same design, so that the full traversal is paid only once.

ansys.geometry.core.misc.auxiliary.get_vertices_from_ids(design: ansys.geometry.core.designer.design.Design, vertex_ids: list[str]) list[ansys.geometry.core.designer.vertex.Vertex]#

Find the Vertex objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the vertices.

vertex_idslist[str]

List of vertex ids.

Returns:
list[Vertex]

List of Vertex objects.

Notes

This method takes a design and vertex ids, and gets their corresponding Vertex objects.

ansys.geometry.core.misc.auxiliary.get_beams_from_ids(design: ansys.geometry.core.designer.design.Design, beam_ids: list[str]) list[ansys.geometry.core.designer.beam.Beam]#

Find the Beam objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the beams.

beam_idslist[str]

List of beam ids.

Returns:
list[Beam]

List of Beam objects.

Notes

This method takes a design and beam ids, and gets their corresponding Beam objects.

ansys.geometry.core.misc.auxiliary.get_design_points_from_ids(design: ansys.geometry.core.designer.design.Design, design_point_ids: list[str]) list[ansys.geometry.core.designer.designpoint.DesignPoint]#

Find the DesignPoint objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the design points.

design_point_idslist[str]

List of design point ids.

Returns:
list[DesignPoint]

List of DesignPoint objects.

Notes

This method takes a design and design point ids, and gets their corresponding DesignPoint objects.

ansys.geometry.core.misc.auxiliary.get_design_curves_from_ids(design: ansys.geometry.core.designer.design.Design, design_curve_ids: list[str]) list[ansys.geometry.core.designer.designcurve.DesignCurve]#

Find the DesignCurve objects inside a Design from its ids.

Parameters:
designDesign

Parent design for the design curves.

design_curve_idslist[str]

List of design curve ids.

Returns:
list[DesignCurve]

List of DesignCurve objects.

Notes

This method takes a design and design curve ids, and gets their corresponding DesignCurve objects.

ansys.geometry.core.misc.auxiliary.convert_color_to_hex(color: str | tuple[float, float, float] | tuple[float, float, float, float]) str#

Get the hex string color from input formats.

Parameters:
colorstr | tuple[float, float, float] | tuple[float, float, float, float]

Color to set the body to. This can be a string representing a color name or a tuple of RGB values in the range [0, 1] (RGBA) or [0, 255] (pure RGB).

Returns:
str

The hex code string for the color, formatted #rrggbbaa.

ansys.geometry.core.misc.auxiliary.convert_opacity_to_hex(opacity: float) str#

Get the hex string from an opacity value.

Parameters:
opacityfloat

Opacity to set body to. Must be in the range [0, 1].

Returns:
The hex code for the opacity formatted #aa
ansys.geometry.core.misc.auxiliary.prepare_file_for_server_upload(file_path: pathlib.Path) pathlib.Path#

Create a zip file from the given file path.

Parameters:
file_pathPath

The path to the file to be zipped.

Returns:
Path

The path to the created zip file.

ansys.geometry.core.misc.auxiliary.extract_project_from_zip(file_path: pathlib.Path, extract_to: pathlib.Path) pathlib.Path#

Extract a zip file to a specified directory.

Parameters:
file_pathstr

The path to the zip file to be extracted.

extract_tostr

The path to the directory where the zip file should be extracted.

Returns:
Path

The path to the directory where the zip file was extracted.

ansys.geometry.core.misc.auxiliary.DEFAULT_COLOR = '#D6F7D1'#