Sketch#

class ansys.geometry.core.sketch.sketch.Sketch(plane: beartype.typing.Optional[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 edge 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 end point of the previous edge.

arc

Add an arc to the sketch plane.

arc_to_point

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

arc_from_three_points

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

triangle

Add a triangle to the sketch using given vertex points.

trapezoid

Add a triangle 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 to the scene.

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: beartype.typing.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: beartype.typing.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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance] = Quantity(0, DEFAULT_UNITS.LENGTH), y: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance] = Quantity(0, DEFAULT_UNITS.LENGTH), z: beartype.typing.Union[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:
xUnion[Quantity, Distance], default: Quantity(0, DEFAULT_UNITS.LENGTH)

Amount to translate the origin of the x-direction.

yUnion[Quantity, Distance], default: Quantity(0, DEFAULT_UNITS.LENGTH)

Amount to translate the origin of the y-direction.

zUnion[Quantity, 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: beartype.typing.Union[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.

distanceUnion[Quantity, Distance]

Distance to translate the origin.

Returns:
Sketch

Revised sketch state ready for further sketch actions.

Sketch.get(tag: str) beartype.typing.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: beartype.typing.Optional[str] = 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: beartype.typing.Optional[str] = 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: beartype.typing.Optional[str] = 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: beartype.typing.Optional[str] = None) Sketch#

Add a segment to the sketch plane starting from the previous edge 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: beartype.typing.Optional[str] = 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: beartype.typing.Optional[str] = None)#

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

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: beartype.typing.Optional[bool] = False, tag: beartype.typing.Optional[str] = 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: beartype.typing.Optional[bool] = False, tag: beartype.typing.Optional[str] = None) Sketch#

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

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: beartype.typing.Optional[str] = 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.triangle(point1: ansys.geometry.core.math.point.Point2D, point2: ansys.geometry.core.math.point.Point2D, point3: ansys.geometry.core.math.point.Point2D, tag: beartype.typing.Optional[str] = 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(width: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], height: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], slant_angle: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real], nonsymmetrical_slant_angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = None, center: beartype.typing.Optional[ansys.geometry.core.math.point.Point2D] = ZERO_POINT2D, angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = 0, tag: beartype.typing.Optional[str] = None) Sketch#

Add a triangle to the sketch using given vertex points.

Parameters:
widthUnion[Quantity, Distance, Real]

Width of the slot main body.

heightUnion[Quantity, Distance, Real]

Height of the slot.

slant_angleUnion[Quantity, Angle, Real]

Angle for trapezoid generation.

nonsymmetrical_slant_angleUnion[Quantity, Angle, Real], default: None

Asymmetrical slant angles on each side of the trapezoid. The default is None, in which case the trapezoid is symmetrical.

centerPoint2D, default: (0, 0)

Center point of the trapezoid.

angleOptional[Union[Quantity, 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.circle(center: ansys.geometry.core.math.point.Point2D, radius: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], tag: beartype.typing.Optional[str] = None) Sketch#

Add a circle to the plane at a given center.

Parameters:
center: Point2D

Center point of the circle.

radiusUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], height: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = 0, tag: beartype.typing.Optional[str] = None) Sketch#

Create a box on the sketch.

Parameters:
center: Point2D

Center point of the box.

widthUnion[Quantity, Distance, Real]

Width of the box.

heightUnion[Quantity, Distance, Real]

Height of the box.

angleUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], height: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = 0, tag: beartype.typing.Optional[str] = None) Sketch#

Create a slot on the sketch.

Parameters:
center: Point2D

Center point of the slot.

widthUnion[Quantity, Distance, Real]

Width of the slot.

heightUnion[Quantity, Distance, Real]

Height of the slot.

angleUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], minor_radius: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = 0, tag: beartype.typing.Optional[str] = None) Sketch#

Create an ellipse on the sketch.

Parameters:
center: Point2D

Center point of the ellipse.

major_radiusUnion[Quantity, Distance, Real]

Semi-major axis of the ellipse.

minor_radiusUnion[Quantity, Distance, Real]

Semi-minor axis of the ellipse.

angleUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], sides: int, angle: beartype.typing.Optional[beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real]] = 0, tag: beartype.typing.Optional[str] = None) Sketch#

Create a polygon on the sketch.

Parameters:
center: Point2D

Center point of the polygon.

inner_radiusUnion[Quantity, Distance, Real]

Inner radius (apothem) of the polygon.

sidesint

Number of sides of the polygon.

angleUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], inner_radius: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Distance, ansys.geometry.core.typing.Real], n_teeth: int, tag: beartype.typing.Optional[str] = None) Sketch#

Create a dummy gear on the sketch.

Parameters:
originPoint2D

Origin of the gear.

outer_radiusUnion[Quantity, Distance, Real]

Outer radius of the gear.

inner_radiusUnion[Quantity, 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: beartype.typing.Union[pint.Quantity, ansys.geometry.core.misc.measurements.Angle, ansys.geometry.core.typing.Real], n_teeth: int, tag: beartype.typing.Optional[str] = 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_angleUnion[Quantity, 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: beartype.typing.Optional[bool] = False, screenshot: beartype.typing.Optional[str] = None, use_trame: beartype.typing.Optional[bool] = None, selected_pd_objects: beartype.typing.List[pyvista.PolyData] = None, **plotting_options: beartype.typing.Optional[dict])#

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 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: beartype.typing.Optional[bool] = False, screenshot: beartype.typing.Optional[str] = None, use_trame: beartype.typing.Optional[bool] = None, **plotting_options: beartype.typing.Optional[dict])#

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 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() beartype.typing.List[pyvista.PolyData]#

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

Returns:
List[PolyData]

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

Sketch.sketch_polydata_faces() beartype.typing.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() beartype.typing.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.