=================== 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. -------------- Public Methods -------------- +--------------------------------------------------------------------------------------------------------+ | addArc3Points_ (self, start, end, third) | +--------------------------------------------------------------------------------------------------------+ | addArcCenter2Points_ (self, center, point1, point2, ccw=True) | +--------------------------------------------------------------------------------------------------------+ | addArcTangentTo_ (self, tangentTo, start, end, bInvertTangent=False) | +--------------------------------------------------------------------------------------------------------+ | addBoundedEllipse_ (self, center, majorAxisPoint, minorAxisPoint, start, end, bCounterClockWise=False) | +--------------------------------------------------------------------------------------------------------+ | addCircle2Points_ (self, point1, point2) | +--------------------------------------------------------------------------------------------------------+ | addCircle3Points_ (self, point1, point2, point3) | +--------------------------------------------------------------------------------------------------------+ | addCircleCenterPoint_ (self, center, point) | +--------------------------------------------------------------------------------------------------------+ | addCircleCenterRadius_ (self, center, radius) | +--------------------------------------------------------------------------------------------------------+ | addConstraint_ (self, constraint, item1=None, item2=None) | +--------------------------------------------------------------------------------------------------------+ | addDimension_ (self, dimension, value, item1=None, item2=None) | +--------------------------------------------------------------------------------------------------------+ | addEllipse_ (self, center, verticalAxis, majorRadius, minorRadius) | +--------------------------------------------------------------------------------------------------------+ | addLine_ (self, point, direction) | +--------------------------------------------------------------------------------------------------------+ | addLineSegment_ (self, point1, point2) | +--------------------------------------------------------------------------------------------------------+ | addParallelogram_ (self, lowerLeft, lowerRight, upperRight) | +--------------------------------------------------------------------------------------------------------+ | addPoint_ (self, x, y) | +--------------------------------------------------------------------------------------------------------+ | addPolyline_ (self, points) | +--------------------------------------------------------------------------------------------------------+ | addRectangle2Vertex_ (self, vertex1, vertex2) | +--------------------------------------------------------------------------------------------------------+ | addRectangle3Vertex_ (self, lowerLeft, lowerRight, upperRight) | +--------------------------------------------------------------------------------------------------------+ | addRectangleCenter2Points_ (self, center, lengthPoint, widthPoint) | +--------------------------------------------------------------------------------------------------------+ | addRectangleCenterVertex_ (self, center, vertex) | +--------------------------------------------------------------------------------------------------------+ | addRegularPolygon_ (self, center, point, numSides, beMidPoint=False) | +--------------------------------------------------------------------------------------------------------+ | addSpline_ (self, points, degree=3, periodic=False, interpolated=False) | +--------------------------------------------------------------------------------------------------------+ | deleteItem_ (self, item) | +--------------------------------------------------------------------------------------------------------+ | evaluate_ (self) | +--------------------------------------------------------------------------------------------------------+ | extend_ (self, curvePoint, limitPoint) | +--------------------------------------------------------------------------------------------------------+ | fillet_ (self, vertices, radius=0) | +--------------------------------------------------------------------------------------------------------+ | findCircle_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findConstraint_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findEllipse_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findItem_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findLine_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findPoint_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | findSpline_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | getCircleCenter_ (self, circle) | +--------------------------------------------------------------------------------------------------------+ | getCircleRadius_ (self, circle) | +--------------------------------------------------------------------------------------------------------+ | getDimensionVariableName_ (self, dimension) | +--------------------------------------------------------------------------------------------------------+ | getEndPoints_ (self, item) | +--------------------------------------------------------------------------------------------------------+ | getItemStatus_ (self, item) | +--------------------------------------------------------------------------------------------------------+ | getLineDirection_ (self, line) | +--------------------------------------------------------------------------------------------------------+ | getLinePosition_ (self, line) | +--------------------------------------------------------------------------------------------------------+ | getPointPosition_ (self, point) | +--------------------------------------------------------------------------------------------------------+ | hasCircle_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasConstraint_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasEllipse_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasItem_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasLine_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasPoint_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | hasSpline_ (self, uid) | +--------------------------------------------------------------------------------------------------------+ | isBounded_ (self, item) | +--------------------------------------------------------------------------------------------------------+ | mirror_ (self, curves, mirrorLine) | +--------------------------------------------------------------------------------------------------------+ | offset_ (self, point, distance) | +--------------------------------------------------------------------------------------------------------+ | polylineAddArcTo_ (self, polyline, arcTo, direction) | +--------------------------------------------------------------------------------------------------------+ | polylineAddLineTo_ (self, polyline, pointTo) | +--------------------------------------------------------------------------------------------------------+ | polylineEnd_ (self, polyline) | +--------------------------------------------------------------------------------------------------------+ | polylineStart_ (self, x, y) | +--------------------------------------------------------------------------------------------------------+ | populate_ (self) | +--------------------------------------------------------------------------------------------------------+ | setDimensionVariable_ (self, dimension, varName) | +--------------------------------------------------------------------------------------------------------+ | setPointPosition_ (self, point, position) | +--------------------------------------------------------------------------------------------------------+ | setWorkplane_ (self, name='main', origin=None, normal=None, horizontalAxis=None) | +--------------------------------------------------------------------------------------------------------+ | split_ (self, curvePoint, breakPoint) | +--------------------------------------------------------------------------------------------------------+ | update_ (self) | +--------------------------------------------------------------------------------------------------------+ -------------- Method Details -------------- .. _addArc3Points: .. method:: addArc3Points(self, start, end, third) Adds an arc by defining three points. :param start: The start point of the arc. :type start: Union[Point, tuple[float, float]] :param end: The end point of the arc. :type end: Union[Point, tuple[float, float]] :param third: An another point of the arc. :type third: Union[Point, tuple[float, float]] :returns: The new arc. :rtype: Circle .. _addArcCenter2Points: .. method:: addArcCenter2Points(self, center, point1, point2, ccw=True) Adds an Arc defined by its center and its endpoints. :param center: The center of the arc. :type center: Union[Point, tuple[float, float]] :param point1: The point of the circle. :type point1: Union[Point, tuple[float, float]] :param point2: The point of the circle. :type point2: Union[Point, tuple[float, float]] :param ccw: Determines whether to use counter clockwise direction from point1 to point2 or not. :type ccw: bool :returns: The new arc. :rtype: Circle .. _addArcTangentTo: .. method:: addArcTangentTo(self, tangentTo, start, end, bInvertTangent=False) 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: .. method:: 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: The center of the ellipse. :type center: tuple[float, float] :param majorAxisPoint: The start point defining the major axis. :type majorAxisPoint: tuple[float, float] :param minorAxisPoint: The end point defining the major axis. :type minorAxisPoint: tuple[float, float] :param start: The start point of the ellipse. :type start: tuple[float, float] :param end: The end point of the ellipse. :type end: tuple[float, float] :param bCounterClockWise: Determines whether to use counter clockwise direction from start to end or not. :type bCounterClockWise: bool :returns: The new ellipse. :rtype: Ellipse .. _addCircle2Points: .. method:: addCircle2Points(self, point1, point2) Adds a circle defined by the 2 endpoints of a diameter. :param point1: The endpoint of the diameter. :type point1: Union[Point, tuple[float, float]] :param point2: The endpoint of the diameter. :type point2: Point, tuple[float, float]float :returns: The new circle. :rtype: Circle .. _addCircle3Points: .. method:: addCircle3Points(self, point1, point2, point3) Adds a circle defined by three points. :param point1: The point of the circle. :type point1: Union[Point, tuple[float, float]] :param point2: The point of the circle. :type point2: Union[Point, tuple[float, float]] :param point3: The point of the circle. :type point3: Union[Point, tuple[float, float]] :returns: The new circle. :rtype: Circle .. _addCircleCenterPoint: .. method:: addCircleCenterPoint(self, center, point) Adds a circle defined by its center and one point. :param center: The center of the circle. :type center: Union[Point, tuple[float, float]] :param point: The point of the circle. :type point: Union[Point, tuple[float, float]] :returns: The new circle. :rtype: Circle .. _addCircleCenterRadius: .. method:: addCircleCenterRadius(self, center, radius) Adds a circle defined by its center and radius. :param center: The center of the circle. :type center: Union[Point, tuple[float, float]] :param radius: The radius of the circle. :type radius: float :returns: The new circle. :rtype: Circle .. _addConstraint: .. method:: addConstraint(self, constraint, item1=None, item2=None) 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 .. _addDimension: .. method:: addDimension(self, dimension, value, item1=None, item2=None) 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 .. _addEllipse: .. method:: addEllipse(self, center, verticalAxis, majorRadius, minorRadius) Adds an ellipse defined by center, vertical axis and radius. :param center: The center of the ellipse. :type center: tuple[float, float] :param verticalAxis: The verical axis of the ellipse. :type verticalAxis: tuple[float, float] :param majorRadius: The major radius of the ellipse. :type majorRadius: float :param minorRadius: The minor radius of the ellipse. :type minorRadius: float :returns: The new ellipse. :rtype: Ellipse .. _addLine: .. method:: addLine(self, point, direction) Adds a line with the specified direction, that goes through a point. :param point: The point of the line. :type point: Union[Point, tuple[float, float]] :param direction: The direction of the line. :type direction: tuple[float, float] :returns: The new line. :rtype: Line .. _addLineSegment: .. method:: addLineSegment(self, point1, point2) Adds a line segment defined by two endpoints. :param point1: The endpoint of the line. :type point1: Union[Point, tuple[float, float]] :param point2: The endpoint of the line. :type point2: Union[Point, tuple[float, float]] :returns: The new line segment. :rtype: Line .. _addParallelogram: .. method:: addParallelogram(self, lowerLeft, lowerRight, upperRight) 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]] .. _addPoint: .. method:: addPoint(self, x, y) Adds a Point to the Sketch at defined position. :param x: The x coordinate of the point. :type x: float :param y: The y coordinate of the point. :type y: float :returns: The new Point. :rtype: Point .. _addPolyline: .. method:: addPolyline(self, points) 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 .. _addRectangle2Vertex: .. method:: addRectangle2Vertex(self, vertex1, vertex2) Adds a rectangle aligned with sketch axis defined by two vertex. :param vertex1: A vertex of the rectangle. :type vertex1: tuple[float, float] :param vertex2: A vertex of the rectangle. :type vertex2: tuple[float, float] :returns: The points and lines of the rectangle. :rtype: tuple[list[Points], list[Lines]] .. _addRectangle3Vertex: .. method:: addRectangle3Vertex(self, lowerLeft, lowerRight, upperRight) 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]] .. _addRectangleCenter2Points: .. method:: addRectangleCenter2Points(self, center, lengthPoint, widthPoint) Adds a rectangle defined by center and two vertex. :param center: The center of the rectangle. :type center: tuple[float, float] :param lengthPoint: A vertex of the rectangle. :type lengthPoint: tuple[float, float] :param widthPoint: A vertex of the rectangle. :type widthPoint: tuple[float, float] :returns: The points and lines of the rectangle. :rtype: tuple[list[Points], list[Lines]] .. _addRectangleCenterVertex: .. method:: addRectangleCenterVertex(self, center, vertex) Adds a rectangle aligned with sketch axis defined by center and one vertex. :param center: The center of the rectangle. :type center: tuple[float, float] :param vertex: A vertex of the rectangle. :type vertex: tuple[float, float] :returns: The points and lines of the rectangle. :rtype: tuple[list[Points], list[Lines]] .. _addRegularPolygon: .. method:: addRegularPolygon(self, center, point, numSides, beMidPoint=False) Adds a regular polygon defined by center, one vertex and the number of sides. :param center: The center of the regular polygon. :type center: tuple[float, float] :param point: A vertex of the regular polygon. :type point: tuple[float, float] :param numSides: The number of sides. :type numSides: int :param beMidPoint: :type beMidPoint: bool :returns: The points and lines of the rectangle. :rtype: tuple[list[Points], list[Lines]] .. _addSpline: .. method:: addSpline(self, points, degree=3, periodic=False, interpolated=False) Adds a spline based on a list of points. :param points: The points of the spline. :type points: list[Point] :param degree: The degree. :type degree: int :param periodic: Determines whether it is periodic. :type periodic: bool :param interpolated: Determines whether it should get interpolated. :type interpolated: bool :returns: The new spline. :rtype: Spline .. _deleteItem: .. method:: deleteItem(self, item) Removes an item from the sketch. :param item: The item to be removed. :type item: InterfaceItem :returns: True if the item has been successfully removed, False otherwise. :rtype: bool .. _evaluate: .. method:: evaluate(self) Recalculates sketch items according to constraints. .. _extend: .. method:: 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: .. method:: fillet(self, vertices, radius=0) Fillet a list of vertices with the specified radius. :param vertices: The vertices to be filleted. :type vertices: list[Points], :param radius: The fillet radius. :type radius: float :returns: True on success, False otherwise. :rtype: bool .. _findCircle: .. method:: findCircle(self, uid) Returns the Circle with the specified id. .. _findConstraint: .. method:: findConstraint(self, uid) Returns the Constraint with the specified id. .. _findEllipse: .. method:: findEllipse(self, uid) Returns the Ellipse with the specified id. .. _findItem: .. method:: findItem(self, uid) Returns the InterfaceItem with the specified id. .. _findLine: .. method:: findLine(self, uid) Returns the Line with the specified id. .. _findPoint: .. method:: findPoint(self, uid) Returns the Point with the specified id. .. _findSpline: .. method:: findSpline(self, uid) Returns the Spline with the specified id. .. _getCircleCenter: .. method:: getCircleCenter(self, circle) Returns the circle center. .. _getCircleRadius: .. method:: getCircleRadius(self, circle) Returns the circle radius. .. _getDimensionVariableName: .. method:: 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: .. method:: getEndPoints(self, item) Returns the item endpoints as a PointVector. .. _getItemStatus: .. method:: getItemStatus(self, item) Returns the status of item according the ITEM_STATUS enum. .. _getLineDirection: .. method:: getLineDirection(self, line) Returns the line direction. .. _getLinePosition: .. method:: getLinePosition(self, line) Returns the line position. .. _getPointPosition: .. method:: getPointPosition(self, point) Returns the point position. .. _hasCircle: .. method:: hasCircle(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _hasConstraint: .. method:: hasConstraint(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _hasEllipse: .. method:: hasEllipse(self, uid) Returns True if sketch contains a Point with the specified id. .. _hasItem: .. method:: hasItem(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _hasLine: .. method:: hasLine(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _hasPoint: .. method:: hasPoint(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _hasSpline: .. method:: hasSpline(self, uid) Returns True if sketch contains a Point with the specified id, False otherwise. .. _isBounded: .. method:: isBounded(self, item) Returns True if the item is bounded, False otherwise. .. _mirror: .. method:: 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: The curves to be mirrored. :type vertices: list[InterfaceItem] :param mirrorLine: The mirror line. :type mirrorLine: Line :returns: True if all items have been mirrored, False otherwise. :rtype: bool .. _offset: .. method:: offset(self, point, distance) Creates a copy of a sketch curve at a specified distance from the source curve. :param point: :type point: tuple[float, float] :param distance: :type distance: float :returns: True on success, False otherwise. :rtype: bool .. _polylineAddArcTo: .. method:: polylineAddArcTo(self, polyline, arcTo, direction) Adds an arc from the polyline last point to the specified Point. :param polyline: The polyline that is being constructed. :type polyline: Polyline :param arcTo: The position of the endpoint of the new arc. :type arcTo: tuple[float, float] :param direction: The initial direction of the arc. :type direction: enum :returns: True if the arc was successfully added to the polyline, False otherwise. :rtype: bool .. _polylineAddLineTo: .. method:: polylineAddLineTo(self, polyline, pointTo) Adds a line segment from the polyline last point to the specified Point. :param polyline: The polyline that is being constructed. :type polyline: Polyline :param pointTo: The position of the endpoint of the new line. :type pointTo: tuple[float, float] :returns: True if the arc was successfully added to the polyline, False otherwise. :rtype: bool .. _polylineEnd: .. method:: polylineEnd(self, polyline) Finishs the construction of the polyline. :param polyline: The polyline that is being constructed. :type polyline: Polyline :returns: The points and lines of the polyline. :rtype: tuple[list[Points], list[Lines]] .. _polylineStart: .. method:: polylineStart(self, x, y) Starts the creation of a polyline on a specified Point. :param x: The x coordinate of the first point. :type x: float :param y: The y coordinate of the first point. :type y: float :returns: The new created polyline. :rtype: Polyline .. _populate: .. method:: populate(self) Redraws the sketch if required. .. _setDimensionVariable: .. method:: 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: .. method:: setPointPosition(self, point, position) Set a Point position. :param point: The point. :type point: Point :param position: The new position of the point. :type position: tuple[float, float] :returns: True if the new position was successfully set, False otherwise. :rtype: bool .. _setWorkplane: .. method:: 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: The name of the workplane. :type name: str, optional :param origin: The coordinates of the origin point of the sketch. :type origin: tuple[float, float, float], optional :param normal: The normal vector to the sketch plane. :type normal: tuple[float, float, float], optional :param horizontalAxis: The direction of the x axis of the sketch. :type horizontalAxis: tuple[float, float, float], optional .. _split: .. method:: 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: .. method:: update(self) Evaluates and populates the sketch.