# Sketch (hwx.common)¶

Creates 2D parametric sketch geometry.

It is used to add items (points, lines, circles…) and constraints to them. Also contains sketch editing operations such as trim, fillet etc.

These APIs only work in GUI mode! Batch mode will be supported in a future release.

## Method Details¶

Adds an arc by defining three points.

param start: The start point of the arc. Union[Point, tuple[float, float]] The end point of the arc. Union[Point, tuple[float, float]] An another point of the arc. Union[Point, tuple[float, float]] The new arc. Circle

Adds an Arc defined by its center and its endpoints.

param center: The center of the arc. Union[Point, tuple[float, float]] The point of the circle. Union[Point, tuple[float, float]] The point of the circle. Union[Point, tuple[float, float]] Determines whether to use counter clockwise direction from point1 to point2 or not. bool The new arc. Circle

Adds an arc, starting tangent to a curve on a start point and ending on a defined point.

param tangentTo:
The item to be tangent to.
type tangentTo:InterfaceItem
param start:The point where the arc starts.
type start:Point
param end:The end point of the arc.
type end:tuple[float, float]
param bInvertTangent:
Determines whether to construct the arc with inverted tangent.
type bInvertTangent:
bool
returns:The new arc.
rtype:Circle
addBoundedEllipse(self, center, majorAxisPoint, minorAxisPoint, start, end, bCounterClockWise=False)

Adds an ellipse defined by center, two points that define an axis and start and end points.

param center: type center: The center of the ellipse. tuple[float, float] The start point defining the major axis. tuple[float, float] The end point defining the major axis. tuple[float, float] The start point of the ellipse. tuple[float, float] The end point of the ellipse. tuple[float, float] Determines whether to use counter clockwise direction from start to end or not. bool The new ellipse. Ellipse

Adds a circle defined by the 2 endpoints of a diameter.

param point1: The endpoint of the diameter. Union[Point, tuple[float, float]] The endpoint of the diameter. Point, tuple[float, float]float The new circle. Circle

Adds a circle defined by three points.

param point1: The point of the circle. Union[Point, tuple[float, float]] The point of the circle. Union[Point, tuple[float, float]] The point of the circle. Union[Point, tuple[float, float]] The new circle. Circle

Adds a circle defined by its center and one point.

param center: The center of the circle. Union[Point, tuple[float, float]] The point of the circle. Union[Point, tuple[float, float]] The new circle. Circle

param center: The center of the circle. Union[Point, tuple[float, float]] The radius of the circle. float The new circle. Circle

Adds a constraint for one or two items.

param constraint:
The constraint.
type constraint:
enum
param item1:The item to hold the constraint.
type item1:InterfaceItem
param item2:The item to hold the constraint.
type item2:InterfaceItem
returns:The new constraint.
rtype:Constraint

Defines constrain the dimensions of a sketch.

param dimension:
The type of dimension.
type dimension:enum
param value:The value of the dimension.
param item1:The item to hold the constraint.
type item1:InterfaceItem
param item2:The item to hold the constraint.
type item2:InterfaceItem
returns:The new dimension.
rtype:Dimension

param center: type center: The center of the ellipse. tuple[float, float] The verical axis of the ellipse. tuple[float, float] The major radius of the ellipse. float The minor radius of the ellipse. float The new ellipse. Ellipse

Adds a line with the specified direction, that goes through a point.

param point: type point: The point of the line. Union[Point, tuple[float, float]] The direction of the line. tuple[float, float] The new line. Line

Adds a line segment defined by two endpoints.

param point1: The endpoint of the line. Union[Point, tuple[float, float]] The endpoint of the line. Union[Point, tuple[float, float]] The new line segment. Line

Adds a parallelogram defined 3 vertex.

param lowerLeft:
The lower left point of of the parallelogram.
type lowerLeft:tuple[float, float]
param lowerRight:
The lower right point of of the parallelogram.
type lowerRight:
tuple[float, float]
param upperRight:
The lower right point of of the parallelogram.
type upperRight:
tuple[float, float]
returns:The points and lines of the parallelogram.
rtype:tuple[list[Points], list[Lines]]

Adds a Point to the Sketch at defined position.

param x: The x coordinate of the point. float The y coordinate of the point. float The new Point. Point

Adds a Polyline of line segments that go through the specified points.

param points (List[tuple[float, float]]:
The points of the polyline.
returns:The new created polyline.
rtype:Polyline

Adds a rectangle aligned with sketch axis defined by two vertex.

param vertex1: A vertex of the rectangle. tuple[float, float] A vertex of the rectangle. tuple[float, float] The points and lines of the rectangle. tuple[list[Points], list[Lines]]

Adds a rectangle defined by three vertex.

param lowerLeft:
The lower left point of the rectangle.
type lowerLeft:tuple[float, float]
param lowerRight:
The lower right point of the rectangle.
type lowerRight:
tuple[float, float]
param upperRight:
The upper right point of the rectangle.
type upperRight:
tuple[float, float]
returns:The points and lines of the rectangle.
rtype:tuple[list[Points], list[Lines]]

Adds a rectangle defined by center and two vertex.

param center: type center: The center of the rectangle. tuple[float, float] A vertex of the rectangle. tuple[float, float] A vertex of the rectangle. tuple[float, float] The points and lines of the rectangle. tuple[list[Points], list[Lines]]

Adds a rectangle aligned with sketch axis defined by center and one vertex.

param center: The center of the rectangle. tuple[float, float] A vertex of the rectangle. tuple[float, float] The points and lines of the rectangle. tuple[list[Points], list[Lines]]

Adds a regular polygon defined by center, one vertex and the number of sides.

param center: type center: The center of the regular polygon. tuple[float, float] A vertex of the regular polygon. tuple[float, float] The number of sides. int bool The points and lines of the rectangle. tuple[list[Points], list[Lines]]

Adds a spline based on a list of points.

param points: type points: The points of the spline. list[Point] The degree. int Determines whether it is periodic. bool Determines whether it should get interpolated. bool The new spline. Spline
deleteItem(self, item)

Removes an item from the sketch.

param item: The item to be removed. InterfaceItem True if the item has been successfully removed, False otherwise. bool
evaluate(self)

Recalculates sketch items according to constraints.

extend(self, curvePoint, limitPoint)

Extend or shorten an entity of a sketch curve.

param curvePoint:
The point of the curve to extend.
type curvePoint:
tuple[float, float]
param limitPoint:
The point of the limit curve.
type limitPoint:
tuple[float, float]
returns:True on success, False otherwise.
rtype:bool

Fillet a list of vertices with the specified radius.

param vertices: The vertices to be filleted. list[Points], The fillet radius. float True on success, False otherwise. bool
findCircle(self, uid)

Returns the Circle with the specified id.

findConstraint(self, uid)

Returns the Constraint with the specified id.

findEllipse(self, uid)

Returns the Ellipse with the specified id.

findItem(self, uid)

Returns the InterfaceItem with the specified id.

findLine(self, uid)

Returns the Line with the specified id.

findPoint(self, uid)

Returns the Point with the specified id.

findSpline(self, uid)

Returns the Spline with the specified id.

getCircleCenter(self, circle)

Returns the circle center.

getDimensionVariableName(self, dimension)

Gets the variable of a dimension.

param dimension:
The dimension.
type dimension:Constraint
returns:The name of the variable.
rtype:str
getEndPoints(self, item)

Returns the item endpoints as a PointVector.

getItemStatus(self, item)

Returns the status of item according the ITEM_STATUS enum.

getLineDirection(self, line)

Returns the line direction.

getLinePosition(self, line)

Returns the line position.

getPointPosition(self, point)

Returns the point position.

hasCircle(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

hasConstraint(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

hasEllipse(self, uid)

Returns True if sketch contains a Point with the specified id.

hasItem(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

hasLine(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

hasPoint(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

hasSpline(self, uid)

Returns True if sketch contains a Point with the specified id, False otherwise.

isBounded(self, item)

Returns True if the item is bounded, False otherwise.

mirror(self, curves, mirrorLine)

Creates symmetric copies of selected sketch curves across a selected centerline.

By default, there is a parent-child relationship between source curves and their symmetric copies.

param vertices: type vertices: The curves to be mirrored. list[InterfaceItem] The mirror line. Line True if all items have been mirrored, False otherwise. bool
offset(self, point, distance)

Creates a copy of a sketch curve at a specified distance from the source curve.

param point: tuple[float, float] float True on success, False otherwise. bool

Adds an arc from the polyline last point to the specified Point.

param polyline: type polyline: The polyline that is being constructed. Polyline The position of the endpoint of the new arc. tuple[float, float] The initial direction of the arc. enum True if the arc was successfully added to the polyline, False otherwise. bool

Adds a line segment from the polyline last point to the specified Point.

param polyline: The polyline that is being constructed. Polyline The position of the endpoint of the new line. tuple[float, float] True if the arc was successfully added to the polyline, False otherwise. bool
polylineEnd(self, polyline)

Finishs the construction of the polyline.

param polyline: The polyline that is being constructed. Polyline The points and lines of the polyline. tuple[list[Points], list[Lines]]
polylineStart(self, x, y)

Starts the creation of a polyline on a specified Point.

param x: The x coordinate of the first point. float The y coordinate of the first point. float The new created polyline. Polyline
populate(self)

Redraws the sketch if required.

setDimensionVariable(self, dimension, varName)

Sets a variable as value for a dimension.

param dimension:
The dimension.
type dimension:Constraint
param varName:The name of the variable.
type varName:str
setPointPosition(self, point, position)

Set a Point position.

param point: The point. Point The new position of the point. tuple[float, float] True if the new position was successfully set, False otherwise. bool
setWorkplane(self, name='main', origin=None, normal=None, horizontalAxis=None)

Sets the name, plane and coordinate system of the sketch.

A sketch plane can be a global plane, a user-created reference plane, or a planar face of an existing part.

param name: type name: The name of the workplane. str, optional The coordinates of the origin point of the sketch. tuple[float, float, float], optional The normal vector to the sketch plane. tuple[float, float, float], optional The direction of the x axis of the sketch. tuple[float, float, float], optional
split(self, curvePoint, breakPoint)

Split a curve in two at a defined break point.

param curvePoint:
The point of the curve to be splitted.
type curvePoint:
tuple[float, float]
param breakPoint:
The point of break.
type breakPoint:
tuple[float, float]
returns:True on success, False otherwise.
rtype:bool
update(self)

Evaluates and populates the sketch.