Sketch#

class ansys.geometry.core.sketch.sketch.Sketch(plane: ansys.geometry.core.math.plane.Plane = Plane())#

Provides for building 2D sketch elements.

Overview#

translate_sketch_plane

Translate the origin location of the active sketch plane.

translate_sketch_plane_by_offset

Translate the origin location of the active sketch plane by offsets.

translate_sketch_plane_by_distance

Translate the origin location active sketch plane by distance.

get

Get a list of shapes with a given tag.

face

Add a sketch face to the sketch.

edge

Add a sketch edge to the sketch.

select

Add all objects that match provided tags to the current context.

segment

Add a segment sketch object to the sketch plane.

segment_to_point

Add a segment to the sketch plane starting from the previous end point.

segment_from_point_and_vector

Add a segment to the sketch starting from a given starting point.

segment_from_vector

Add a segment to the sketch starting from the previous end point.

arc

Add an arc to the sketch plane.

arc_to_point

Add an arc to the sketch starting from the previous end point.

arc_from_three_points

Add an arc to the sketch plane from three given points.

arc_from_start_end_and_radius

Add an arc from the start, end points and a radius.

arc_from_start_center_and_angle

Add an arc from the start, center point, and angle.

triangle

Add a triangle to the sketch using given vertex points.

trapezoid

Add a trapezoid to the sketch using given vertex points.

circle

Add a circle to the plane at a given center.

box

Create a box on the sketch.

slot

Create a slot on the sketch.

ellipse

Create an ellipse on the sketch.

polygon

Create a polygon on the sketch.

dummy_gear

Create a dummy gear on the sketch.

spur_gear

Create a spur gear on the sketch.

tag

Add a tag to the active selection of sketch objects.

plot

Plot all objects of the sketch to the scene.

plot_selection

Plot the current selection to the scene.

sketch_polydata

Get polydata configuration for all objects of the sketch.

sketch_polydata_faces

Get polydata configuration for all faces of the sketch to the scene.

sketch_polydata_edges

Get polydata configuration for all edges of the sketch to the scene.

plane

Sketch plane configuration.

edges

List of all independently sketched edges.

faces

List of all independently sketched faces.

Import detail#

from ansys.geometry.core.sketch.sketch import Sketch

Property detail#

property Sketch.plane: ansys.geometry.core.math.plane.Plane#

Sketch plane configuration.

property Sketch.edges: list[ansys.geometry.core.sketch.edge.SketchEdge]#

List of all independently sketched edges.

Notes

Independently sketched edges are not assigned to a face. Face edges are not included in this list.

property Sketch.faces: list[ansys.geometry.core.sketch.face.SketchFace]#

List of all independently sketched faces.

Method detail#

Sketch.translate_sketch_plane(translation: ansys.geometry.core.math.vector.Vector3D) Sketch#

Translate the origin location of the active sketch plane.

Parameters:
translationVector3D

Vector defining the translation. Meters is the expected unit.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.translate_sketch_plane_by_offset(x: pint.Quantity | ansys.geometry.core.misc.measurements.Distance = Quantity(0, DEFAULT_UNITS.LENGTH), y: pint.Quantity | ansys.geometry.core.misc.measurements.Distance = Quantity(0, DEFAULT_UNITS.LENGTH), z: pint.Quantity | ansys.geometry.core.misc.measurements.Distance = Quantity(0, DEFAULT_UNITS.LENGTH)) Sketch#

Translate the origin location of the active sketch plane by offsets.

Parameters:
xQuantity | Distance, default: Quantity(0, DEFAULT_UNITS.LENGTH)

Amount to translate the origin of the x-direction.

yQuantity | Distance, default: Quantity(0, DEFAULT_UNITS.LENGTH)

Amount to translate the origin of the y-direction.

zQuantity | Distance, default: Quantity(0, DEFAULT_UNITS.LENGTH)

Amount to translate the origin of the z-direction.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.translate_sketch_plane_by_distance(direction: ansys.geometry.core.math.vector.UnitVector3D, distance: pint.Quantity | ansys.geometry.core.misc.measurements.Distance) Sketch#

Translate the origin location active sketch plane by distance.

Parameters:
directionUnitVector3D

Direction to translate the origin.

distanceQuantity | Distance

Distance to translate the origin.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.get(tag: str) list[SketchObject]#

Get a list of shapes with a given tag.

Parameters:
tagstr

Tag to query against.

Sketch.face(face: ansys.geometry.core.sketch.face.SketchFace, tag: str | None = None) Sketch#

Add a sketch face to the sketch.

Parameters:
faceSketchFace

Face to add.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.edge(edge: ansys.geometry.core.sketch.edge.SketchEdge, tag: str | None = None) Sketch#

Add a sketch edge to the sketch.

Parameters:
edgeSketchEdge

Edge to add.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.select(*tags: str) Sketch#

Add all objects that match provided tags to the current context.

Sketch.segment(start: ansys.geometry.core.math.point.Point2D, end: ansys.geometry.core.math.point.Point2D, tag: str | None = None) Sketch#

Add a segment sketch object to the sketch plane.

Parameters:
startPoint2D

Starting point of the line segment.

endPoint2D

Ending point of the line segment.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.segment_to_point(end: ansys.geometry.core.math.point.Point2D, tag: str | None = None) Sketch#

Add a segment to the sketch plane starting from the previous end point.

Parameters:
endPoint2D

Ending point of the line segment.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Notes

The starting point of the created edge is based upon the current context of the sketch, such as the end point of a previously added edge.

Sketch.segment_from_point_and_vector(start: ansys.geometry.core.math.point.Point2D, vector: ansys.geometry.core.math.vector.Vector2D, tag: str | None = None)#

Add a segment to the sketch starting from a given starting point.

Parameters:
startPoint2D

Starting point of the line segment.

vectorVector2D

Vector defining the line segment. Vector magnitude determines the segment endpoint. Vector magnitude is assumed to be in the same unit as the starting point.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Notes

Vector magnitude determines the segment endpoint. Vector magnitude is assumed to use the same unit as the starting point.

Sketch.segment_from_vector(vector: ansys.geometry.core.math.vector.Vector2D, tag: str | None = None)#

Add a segment to the sketch starting from the previous end point.

Parameters:
vectorVector2D

Vector defining the line segment.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Notes

The starting point of the created edge is based upon the current context of the sketch, such as the end point of a previously added edge.

Vector magnitude determines the segment endpoint. Vector magnitude is assumed to use the same unit as the starting point in the previous context.

Sketch.arc(start: ansys.geometry.core.math.point.Point2D, end: ansys.geometry.core.math.point.Point2D, center: ansys.geometry.core.math.point.Point2D, clockwise: bool = False, tag: str | None = None) Sketch#

Add an arc to the sketch plane.

Parameters:
startPoint2D

Starting point of the arc.

endPoint2D

Ending point of the arc.

centerPoint2D

Center point of the arc.

clockwisebool, default: False

Whether the arc spans the angle clockwise between the start and end points. When False `` (default), the arc spans the angle counter-clockwise. When ``True, the arc spans the angle clockwise.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.arc_to_point(end: ansys.geometry.core.math.point.Point2D, center: ansys.geometry.core.math.point.Point2D, clockwise: bool = False, tag: str | None = None) Sketch#

Add an arc to the sketch starting from the previous end point.

Parameters:
endPoint2D

Ending point of the arc.

centerPoint2D

Center point of the arc.

clockwisebool, default: False

Whether the arc spans the angle clockwise between the start and end points. When False (default), the arc spans the angle counter-clockwise. When True, the arc spans the angle clockwise.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Notes

The starting point of the created edge is based upon the current context of the sketch, such as the end point of a previously added edge.

Sketch.arc_from_three_points(start: ansys.geometry.core.math.point.Point2D, inter: ansys.geometry.core.math.point.Point2D, end: ansys.geometry.core.math.point.Point2D, tag: str | None = None) Sketch#

Add an arc to the sketch plane from three given points.

Parameters:
startPoint2D

Starting point of the arc.

interPoint2D

Intermediate point (location) of the arc.

endPoint2D

End point of the arc.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.arc_from_start_end_and_radius(start: ansys.geometry.core.math.point.Point2D, end: ansys.geometry.core.math.point.Point2D, radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, convex_arc: bool = False, clockwise: bool = False, tag: str | None = None) Sketch#

Add an arc from the start, end points and a radius.

Parameters:
startPoint2D

Starting point of the arc.

endPoint2D

Ending point of the arc.

radiusQuantity | Distance | Real

Radius of the arc.

convex_arcbool, default: False

Whether the arc is convex. The default is False. When False , the arc spans the concave version of the arc. When True, the arc spans the convex version of the arc.

clockwisebool, default: False

Whether the arc spans the angle clockwise between the start and end points. When False, the arc spans the angle counter-clockwise. When True, the arc spans the angle clockwise.

tagstr, default: None

User-defined label for identifying the edge.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.arc_from_start_center_and_angle(start: ansys.geometry.core.math.point.Point2D, center: ansys.geometry.core.math.point.Point2D, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real, clockwise: bool = False, tag: str | None = None) Sketch#

Add an arc from the start, center point, and angle.

Parameters:
startPoint2D

Starting point of the arc.

centerPoint2D

Center point of the arc.

angleQuantity | Angle | Real

Angle of the arc.

clockwisebool, default: False

Whether the arc spans the angle clockwise. The default is False. When False , the arc spans the angle counter-clockwise. When True, the arc spans the angle clockwise.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.triangle(point1: ansys.geometry.core.math.point.Point2D, point2: ansys.geometry.core.math.point.Point2D, point3: ansys.geometry.core.math.point.Point2D, tag: str | None = None) Sketch#

Add a triangle to the sketch using given vertex points.

Parameters:
point1Point2D

Point that represents a vertex of the triangle.

point2Point2D

Point that represents a vertex of the triangle.

point3Point2D

Point that represents a vertex of the triangle.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.trapezoid(base_width: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, height: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, base_angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real, base_asymmetric_angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real | None = None, center: ansys.geometry.core.math.point.Point2D = ZERO_POINT2D, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0, tag: str | None = None) Sketch#

Add a trapezoid to the sketch using given vertex points.

Parameters:
base_widthQuantity | Distance | Real

Width of the lower base of the trapezoid.

heightQuantity | Distance | Real

Height of the slot.

base_angleQuantity | Distance | Real

Angle for trapezoid generation. Represents the angle on the base of the trapezoid.

base_asymmetric_angleQuantity | Angle | Real | None, default: None

Asymmetrical angles on each side of the trapezoid. The default is None, in which case the trapezoid is symmetrical. If provided, the trapezoid is asymmetrical and the right corner angle at the base of the trapezoid is set to the provided value.

center: Point2D, default: ZERO_POINT2D

Center point of the trapezoid.

angleQuantity | Angle | Real, default: 0

Placement angle for orientation alignment.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Notes

If an asymmetric base angle is defined, the base angle is applied to the left-most angle, and the asymmetric base angle is applied to the right-most angle.

Sketch.circle(center: ansys.geometry.core.math.point.Point2D, radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, tag: str | None = None) Sketch#

Add a circle to the plane at a given center.

Parameters:
center: Point2D

Center point of the circle.

radiusQuantity | Distance | Real

Radius of the circle.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.box(center: ansys.geometry.core.math.point.Point2D, width: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, height: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0, tag: str | None = None) Sketch#

Create a box on the sketch.

Parameters:
center: Point2D

Center point of the box.

widthQuantity | Distance | Real

Width of the box.

heightQuantity | Distance | Real

Height of the box.

angleQuantity | Angle | Real, default: 0

Placement angle for orientation alignment.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.slot(center: ansys.geometry.core.math.point.Point2D, width: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, height: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0, tag: str | None = None) Sketch#

Create a slot on the sketch.

Parameters:
center: Point2D

Center point of the slot.

widthQuantity | Distance | Real

Width of the slot.

heightQuantity | Distance | Real

Height of the slot.

angleQuantity | Angle | Real, default: 0

Placement angle for orientation alignment.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.ellipse(center: ansys.geometry.core.math.point.Point2D, major_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, minor_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0, tag: str | None = None) Sketch#

Create an ellipse on the sketch.

Parameters:
center: Point2D

Center point of the ellipse.

major_radiusQuantity | Distance | Real

Semi-major axis of the ellipse.

minor_radiusQuantity | Distance | Real

Semi-minor axis of the ellipse.

angleQuantity | Angle | Real, default: 0

Placement angle for orientation alignment.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.polygon(center: ansys.geometry.core.math.point.Point2D, inner_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, sides: int, angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real = 0, tag: str | None = None) Sketch#

Create a polygon on the sketch.

Parameters:
center: Point2D

Center point of the polygon.

inner_radiusQuantity | Distance | Real

Inner radius (apothem) of the polygon.

sidesint

Number of sides of the polygon.

angleQuantity | Angle | Real, default: 0

Placement angle for orientation alignment.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.dummy_gear(origin: ansys.geometry.core.math.point.Point2D, outer_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, inner_radius: pint.Quantity | ansys.geometry.core.misc.measurements.Distance | ansys.geometry.core.typing.Real, n_teeth: int, tag: str | None = None) Sketch#

Create a dummy gear on the sketch.

Parameters:
originPoint2D

Origin of the gear.

outer_radiusQuantity | Distance | Real

Outer radius of the gear.

inner_radiusQuantity | Distance | Real

Inner radius of the gear.

n_teethint

Number of teeth of the gear.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.spur_gear(origin: ansys.geometry.core.math.point.Point2D, module: ansys.geometry.core.typing.Real, pressure_angle: pint.Quantity | ansys.geometry.core.misc.measurements.Angle | ansys.geometry.core.typing.Real, n_teeth: int, tag: str | None = None) Sketch#

Create a spur gear on the sketch.

Parameters:
originPoint2D

Origin of the spur gear.

moduleReal

Module of the spur gear. This is also the ratio between the pitch circle diameter in millimeters and the number of teeth.

pressure_angleQuantity | Angle | Real

Pressure angle of the spur gear.

n_teethint

Number of teeth of the spur gear.

tagstr, default: None

User-defined label for identifying the face.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.tag(tag: str) None#

Add a tag to the active selection of sketch objects.

Parameters:
tagstr

Tag to assign to the sketch objects.

Sketch.plot(view_2d: bool = False, screenshot: str | None = None, use_trame: bool | None = None, selected_pd_objects: list[pyvista.PolyData] = None, **plotting_options: dict | None)#

Plot all objects of the sketch to the scene.

Parameters:
view_2dbool, default: False

Whether to represent the plot in a 2D format.

screenshotstr, optional

Path for saving a screenshot of the image that is being represented.

use_tramebool, default: None

Whether to enables the use of trame. The default is None, in which case the ansys.tools.visualization_interface.USE_TRAME global setting is used.

**plotting_optionsdict, optional

Keyword arguments for plotting. For allowable keyword arguments, see the Plotter.add_mesh method.

Sketch.plot_selection(view_2d: bool = False, screenshot: str | None = None, use_trame: bool | None = None, **plotting_options: dict | None)#

Plot the current selection to the scene.

Parameters:
view_2dbool, default: False

Whether to represent the plot in a 2D format.

screenshotstr, optional

Path for saving a screenshot of the image that is being represented.

use_tramebool, default: None

Whether to enables the use of trame. The default is None, in which case the ansys.tools.visualization_interface.USE_TRAME global setting is used.

**plotting_optionsdict, optional

Keyword arguments for plotting. For allowable keyword arguments, see the Plotter.add_mesh method.

Sketch.sketch_polydata() list[pyvista.PolyData]#

Get polydata configuration for all objects of the sketch.

Returns:
list[PolyData]

List of the polydata configuration for all edges and faces in the sketch.

Sketch.sketch_polydata_faces() list[pyvista.PolyData]#

Get polydata configuration for all faces of the sketch to the scene.

Returns:
list[PolyData]

List of the polydata configuration for faces in the sketch.

Sketch.sketch_polydata_edges() list[pyvista.PolyData]#

Get polydata configuration for all edges of the sketch to the scene.

Returns:
list[PolyData]

List of the polydata configuration for edges in the sketch.