Sketch (hwx.common)#

class Sketch(Interface=None)#

Bases: object

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.

Attribute Table#

Name

Type

CONSTRAINT_ANGLE

int

CONSTRAINT_COINCIDENT

int

CONSTRAINT_COLLINEAR

int

CONSTRAINT_CONCENTRIC

int

CONSTRAINT_DIAMETER_ALIGNED

int

CONSTRAINT_DIAMETER_HORIZONTAL

int

CONSTRAINT_DIAMETER_VERTICAL

int

CONSTRAINT_DISTANCE_ALIGNED

int

CONSTRAINT_DISTANCE_HORIZONTAL

int

CONSTRAINT_DISTANCE_VERTICAL

int

CONSTRAINT_EQUAL

int

CONSTRAINT_FIXED

int

CONSTRAINT_HORIZONTAL

int

CONSTRAINT_HORIZONTAL_POINTS

int

CONSTRAINT_MAJOR_RADIUS

int

CONSTRAINT_MIDPOINT

int

CONSTRAINT_MINOR_RADIUS

int

CONSTRAINT_MIRROR

int

CONSTRAINT_OFFSET

int

CONSTRAINT_OFFSET_DISTANCE

int

CONSTRAINT_PARALLEL

int

CONSTRAINT_PERPENDICULAR

int

CONSTRAINT_RADIUS

int

CONSTRAINT_TANGENT

int

CONSTRAINT_VERTICAL

int

CONSTRAINT_VERTICAL_POINTS

int

DIMENSION_ANGLE

int

DIMENSION_DIAMETER_ALIGNED

int

DIMENSION_DIAMETER_HORIZONTAL

int

DIMENSION_DIAMETER_VERTICAL

int

DIMENSION_DISTANCE_ALIGNED

int

DIMENSION_DISTANCE_HORIZONTAL

int

DIMENSION_DISTANCE_VERTICAL

int

DIMENSION_MAJOR_RADIUS

int

DIMENSION_MINOR_RADIUS

int

DIMENSION_OFFSET_DISTANCE

int

DIMENSION_RADIUS

int

STATUS_FIXED

int

STATUS_FULLYDEFINED

int

STATUS_NOTCHANGED

int

STATUS_NOTCONSISTENT

int

STATUS_OVERDEFINED

int

STATUS_UNDERDEFINED

int

STATUS_UNKNOWN

int

TANGENT_INWARD

int

TANGENT_NORMAL_LEFT

int

TANGENT_NORMAL_RIGHT

int

TANGENT_OUTWARD

int

workplane

property

Method Table#

Name

Description

addArc3Points (self, start, end, third)

Adds an arc by defining three points.

addArcCenter2Points (self, center, point1, point2, ccw=True)

Adds an Arc defined by its center and its endpoints.

addArcTangentTo (self, tangentTo, start, end, bInvertTangent=False)

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

addBoundedEllipse (self, center, majorAxisPoint, minorAxisPoint, start, end, bCounterClockWise=False)

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

addCircle2Points (self, point1, point2)

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

addCircle3Points (self, point1, point2, point3)

Adds a circle defined by three points.

addCircleCenterPoint (self, center, point)

Adds a circle defined by its center and one point.

addCircleCenterRadius (self, center, radius)

Adds a circle defined by its center and radius.

addConstraint (self, constraint, item1=None, item2=None, mirrorAxis=None)

Adds a constraint for one or two items.

addDimension (self, dimension, value=None, item1=None, item2=None, x=1.7976931348623157e+308, y=1.7976931348623157e+308, pickX=1.7976931348623157e+308, pickY=1.7976931348623157e+308)

Defines constrain the dimensions of a sketch.

addEllipse (self, center, verticalAxis, majorRadius, minorRadius=None)

Adds an ellipse defined by center, vertical axis and radius, or

addLine (self, point, direction)

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

addLineSegment (self, point1, point2, type=None)

Adds a line segment defined by two endpoints.

addParallelogram (self, lowerLeft, lowerRight, upperRight)

Adds a parallelogram defined 3 vertex.

addPoint (self, x, y)

addPolyline (self, points)

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

addRectangle2Vertex (self, vertex1, vertex2)

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

addRectangle3Vertex (self, lowerLeft, lowerRight, upperRight)

Adds a rectangle defined by three vertex.

addRectangleCenter2Points (self, center, lengthPoint, widthPoint)

Adds a rectangle defined by center and two vertex.

addRectangleCenterVertex (self, center, vertex)

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

addRegularPolygon (self, center, point, numSides, beMidPoint=False)

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

addSpline (self, points, degree=3, periodic=False, interpolated=False)

Adds a spline based on a list of points.

circularPattern (self, entities, point, copy, angle, symmetry, createDimension=True, equalSpacing=False)

Pattern sketch entities around a point.

convertGlobalToLocalPoint (self, point)

deleteItem (self, item)

Removes an item from the sketch.

enableHistory (self, state=True)

Set the state of the abilty to store history

evaluate (self)

Recalculates sketch items according to constraints.

extend (self, curvePoint, limitPoint)

Extend or shorten an entity of a sketch curve.

fillet (self, vertices, radius=0)

Fillet a list of vertices with the specified radius.

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.

getActive ()

Sketch currently being edited in the gui.

getDimensionVariableName (self, dimension)

Gets the variable of a dimension.

getEndPoints (self, item)

Returns the item endpoints as a PointVector.

getItemStatus (self, item)

Returns the status of item according the ITEM_STATUS enum.

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.

isAnyOverConstrained (self)

Returns True if and items are over constrained, False otherwise.

isConstruction (self, item)

Returns True if the item is a construction item, False otherwise.

isDimensionDriven (self, item)

Returns True if the item is a dimension and is driven, False otherwise.

isFixed (self, item)

Returns True if the item is fixed, False otherwise.

linearPattern (self, entities, direction1, copy1=3, distance1=0.1, symmetry1=False, direction2=None, copy2=3, distance2=0.1, symmetry2=False)

Pattern sketch entities in a linear direction.

mirror (self, curves, mirrorLine)

Creates symmetric copies of selected sketch curves across a selected

offset (self, point, distance)

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

origin (self)

Returns the Point for the origin.

parameterManager (self)

Return the Parameter Manager for this sketch

polylineAddArcTo (self, polyline, arcTo, direction)

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

polylineAddLineTo (self, polyline, pointTo)

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

polylineEnd (self, polyline)

Finishs the construction of the polyline.

polylineStart (self, x, y)

Starts the creation of a polyline on a specified Point.

populate (self)

Redraws the sketch if required.

rotate (self, entities, center, angle, keepRelations=True)

Rotate Sketch entities.

setConstruction (self, item, state=True)

Set the items construction flag.

setDimensionIsDriven (self, item, state)

Returns True if the item is a dimension and is driven, False otherwise.

setDimensionVariable (self, dimension, varName)

Sets a variable as value for a dimension.

setFixed (self, item, state=True)

Set the items fixed state.

setParameterManager (self, pm)

Set the Parameter Manager to use for this sketch

setWorkplane (self, matrix)

Define the workplane from the passed matrix.

split (self, curvePoint, breakPoint)

Split a curve in two at a defined break point.

translate (self, entities, direction, value, keepRelations=True)

Translate Sketch entities.

trim (self, x, y)

Removes one or more geometric entities below the (x, y) coordinates of

update (self)

Evaluates and populates the sketch.

Example

Define and use Splines.#
from hwx import inspire
from hwx.common.Sketch import Sketch

model = inspire.newModel()

# instanciate sketch
s = Sketch()

# instantiate points
p1 = s.addPoint(2, 2)
p2 = s.addPoint(1, 1)

# we can also query and set the position of point p1.
position = p1.position
print(f'Position of p1: {position}')
p1.position = (0, 0)
print(f'Position of p1 after change: {p1.position}')

# instantiate line segment using points or coordinates
ls1 = s.addLineSegment(p1, p2)
ls2 = s.addLineSegment((2, 2), (4, 4))

# instantiate line using point and direction
l1 = s.addLine((3, 3), (1, -1))
# we can also query the position of line l1.
print(f'Position and direction of l1 : {l1.position}, {l1.direction}')
s.addLine(p1, (1, 0))
setWorkplane(matrix)#

Define the workplane from the passed matrix.

convertGlobalToLocalPoint(point)#

Convert a 3D global point to a 2D local point in the sketch plane.

This function transforms a given 3D point in global coordinates to its corresponding 2D point in the local sketch plane, based on the current workplane of the sketch.

Parameters:

point (tuple[float, float, float]) – The 3D point in global coordinates.

Returns:

The 2D point (x, y) in the local sketch plane.

Return type:

tuple[float, float]

Raises:

AttributeError – If the workplane is not defined for the sketch.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a solid block (cube of 0.1m x 0.1m x 0.1m)
box = model.createSolidBlock(x=0.1, y=0.1, z=0.1)

# Define a transformation: move the block to origin (1,2,3) and rotate 90° around Z-axis
position = Matrix44(origin=[1, 2, 3], angles=[0, 0, 90], degrees=True)

# Move the solid using "Free" move mode with the transformation matrix
box.move2(moveMode="Free", position=position)

# Extract the first planar feature (usually one of the block's faces)
planefeat = box.getFeatures(type='FeaturePlanar')[0]

# Get 3D coordinates of points connected to that planar face
points = [point.location for point in planefeat.connectedPoints]

# Create a new 2D sketch on the extracted planar face
# Use its center of gravity as origin and normal as sketching direction
sketch = inspire.Sketch(feature=planefeat, origin=planefeat.cg, normal=planefeat.normal)

# Convert the global 3D coordinates of the connected points into local sketch 2D coordinates
local_point = [(sketch.convertGlobalToLocalPoint(p)) for p in points]

# Access sketch origin (optional)
g1 = sketch.origin()

# Add all the converted 2D points to the sketch
for x, y in local_point:
    sketch.addPoint(x, y)

# Finalize and create the sketch in the model
sketch_part = sketch.realize()

#below example demonstrates how to create a 2D rectangle sketch on a planar feature 
#This is useful for defining sketch-based features like cutouts, extrusions, or 
#pads that are aligned precisely with reference geometry in a model.

from hwx import inspire
# Assume you already have a planar feature 
# (e.g., model.getFeatures(type='FeaturePlanar')[0])

# Create a sketch on the planar feature
sketch = inspire.Sketch(feature=feature, origin=feature.cg, normal=feature.normal)

# Convert the feature.cg point (3D) to sketch-local (2D) coordinates
local_center = sketch.convertGlobalToLocalPoint(feature.cg)
cx, cy = local_center

# Define rectangle dimensions (centered at the point)
width = .02     # total width in sketch X
height =.04    # total height in sketch Y

# Calculate corners of the rectangle
p1 = (cx - width / 2, cy - height / 2)
p2 = (cx + width / 2, cy - height / 2)
p3 = (cx + width / 2, cy + height / 2)
p4 = (cx - width / 2, cy + height / 2)

# Draw rectangle by connecting the points with lines
sketch.addLineSegment(p1, p2)
sketch.addLineSegment(p2, p3)
sketch.addLineSegment(p3, p4)
sketch.addLineSegment(p4, p1)

# Realize the sketch into the model
sketch_part = sketch.realize()

# This sketch_part can be used for further operations like extrusions or cutouts.
isConstruction(item)#

Returns True if the item is a construction item, False otherwise.

setConstruction(item, state=True)#

Set the items construction flag.

isFixed(item)#

Returns True if the item is fixed, False otherwise.

setFixed(item, state=True)#

Set the items fixed state.

isAnyOverConstrained()#

Returns True if and items are over constrained, False otherwise.

enableHistory(state=True)#

Set the state of the abilty to store history

addPoint(x, y)#

Adds a Point to the Sketch at defined position.

Parameters:
  • x (float) – The x coordinate of the point.

  • y (float) – The y coordinate of the point.

Returns:

The new Point.

Return type:

Point

Example

from hwx import inspire
from hwx.common.math import Matrix44
# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add points to the sketch
sketch.addPoint(0, 0)  # Add a point at the origin
sketch.addPoint(1, 1)  # Add a point at (1, 1)
sketch.addPoint(2, 2)  # Add a point at (2, 2)
sketch.addPoint(3, 3)  # Add a point at (3, 3)
sketch.addPoint(4, 4)  # Add a point at (4, 4)
sketch_part = sketch.realize()  # Finalize the sketch
addLine(point, direction)#

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

Parameters:
  • point (Point | tuple[float, float]) – The point of the line.

  • direction (tuple[float, float]) – The direction of the line.

Returns:

The new line.

Return type:

Line

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Y plane
sketch = inspire.Sketch(system='Global Y',feature=None, origin=None, normal=None)

# instantiate line using point and direction
l1 = s.addLine((3, 3), (1, -1))

#by default the line is set to construction mode
sketch.setConstruction(l1,state= False)

# we can also query the position of line l1.
print(f'Position and direction of l1 : {l1.position}, {l1.direction}')
s.addLine((2,2), (1, 0)) 
# Finalize the sketch
sketch_part = sketch.realize() 
addLineSegment(point1, point2, type=None)#

Adds a line segment defined by two endpoints.

Parameters:
  • point1 (Point | tuple[float, float]) – The endpoint of the line.

  • point2 (Point | tuple[float, float]) – The endpoint of the line.

  • type (str) – The type of line segment. Can be “END_POINT_LINE” or “MIDPOINT_LINE”.

Returns:

The new line segment.

Return type:

Line

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global X plane
sketch = inspire.Sketch(system='Global X',feature=None, origin=None, normal=None)
# instantiate line segment using points or coordinates
ls1 = sketch.addLineSegment((0,0), (0,1), type="END_POINT_LINE")
# Finalize the sketch
sketch_part = sketch.realize() 
addCircleCenterRadius(center, radius)#

Adds a circle defined by its center and radius.

Parameters:
  • center (Point | tuple[float, float]) – The center of the circle.

  • radius (float) – The radius of the circle.

Returns:

The new circle.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add a circle defined by its center at (o,0) and radius 1.5 meter.
c1 = sketch.addCircleCenterRadius(center=(0,0), radius=1.5)
# Finalize the sketch
sketch_part = sketch.realize() 
addCircleCenterPoint(center, point)#

Adds a circle defined by its center and one point.

Parameters:
  • center (Point | tuple[float, float]) – The center of the circle.

  • point (Point | tuple[float, float]) – The point of the circle.

Returns:

The new circle.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add a circle defined  by center point and another point
c2 = sketch.addCircleCenterPoint(center=(3, 1), point=(3, 4.5))
# Finalize the sketch
sketch_part = sketch.realize() 
addCircle2Points(point1, point2)#

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

Parameters:
  • point1 (Point | tuple[float, float]) – The endpoint of the diameter.

  • point2 (Point | tuple[float, float]) – The endpoint of the diameter.

Returns:

The new circle.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add a circle defined by two point.
c2 = sketch.addCircle2Points(point1=(3, 1), point2=(3, 4.5))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addCircle3Points(point1, point2, point3)#

Adds a circle defined by three points.

Parameters:
  • point1 (Point | tuple[float, float]) – The point of the circle.

  • point2 (Point | tuple[float, float]) – The point of the circle.

  • point3 (Point | tuple[float, float]) – The point of the circle.

Returns:

The new circle.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add a circle defined by three point.
c2 = sketch.addCircle3Points(point1=(0, 0), point2=(2, 0), point3=(-1, -1))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addArcCenter2Points(center, point1, point2, ccw=True)#

Adds an Arc defined by its center and its endpoints.

Parameters:
  • center (Point | tuple[float, float]) – The center of the arc.

  • point1 (Point | tuple[float, float]) – The point of the circle.

  • point2 (Point | tuple[float, float]) – The point of the circle.

  • ccw (bool) – Determines whether to use counter clockwise direction from point1 to point2 or not.

Returns:

The new arc.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create arc using center and two endpoints, counter-clockwise or clockwise
a1 = sketch.addArcCenter2Points(center=(0, 0), point1=(0, 3),point2= (3, 0), ccw=True)
a2 = sketch.addArcCenter2Points(center=(1, 1), point1=(1, 4), point2=(4, 1), ccw=False)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addArc3Points(start, end, third)#

Adds an arc by defining three points.

Parameters:
  • start (Point | tuple[float, float]) – The start point of the arc.

  • end (Point | tuple[float, float]) – The end point of the arc.

  • third (Point | tuple[float, float]) – An another point of the arc.

Returns:

The new arc.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create arc using 3 points, start, end and a third point
a3 = sketch.addArc3Points(start=(5, 5), end=(3, 3), third=(3, 4))  
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addArcTangentTo(tangentTo, start, end, bInvertTangent=False)#
Adds an arc, starting tangent to a curve on a start point and ending on

a defined point.

Parameters:
  • tangentTo (InterfaceItem) – The item to be tangent to.

  • start (Point | tuple[float, float]) – The point where the arc starts.

  • end (Point | tuple[float, float]) – The end point of the arc.

  • bInvertTangent (bool) – Determines whether to construct the arc with inverted tangent.

Returns:

The new arc.

Return type:

Circle

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create arc tangent to a curve and using start end points
start = sketch.addPoint(0, 3)
line = sketch.addLineSegment((0, 0), (0, 3))
# create arc tangent to a line and using start end points
# start argument should be a sketch point
# tangentTo argument should be a line segment
a4 = sketch.addArcTangentTo(tangentTo=line, start =start, end=(3, 4),
                            bInvertTangent=True)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addEllipse(center, verticalAxis, majorRadius, minorRadius=None)#
Adds an ellipse defined by center, vertical axis and radius, or

by center Point, and Line for major axis and Line for minor axis.

Parameters:
  • center (Point | tuple[float, float] | Point) – The center of the ellipse.

  • verticalAxis (Line | tuple[float, float]) – For a Line, the majorAxis, otherwise the vertical axis of the ellipse.

  • majorRadius (Line | float) – For a Line, the minor axis, otherwise the major radius of the ellipse.

  • minorRadius (float) – The minor radius of the ellipse.

Returns:

The new ellipse.

Return type:

Ellipse

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
e = sketch.addEllipse(center=(0.01, 0.01), verticalAxis=(0, 1), majorRadius=0.3,minorRadius= 0.5)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addBoundedEllipse(center, majorAxisPoint, minorAxisPoint, start, end, bCounterClockWise=False)#

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

Parameters:
  • center (Point | tuple[float, float]) – The center of the ellipse.

  • majorAxisPoint (Line | tuple[float, float]) – The start point defining the major axis.

  • minorAxisPoint (Line | tuple[float, float]) – The end point defining the major axis.

  • start (Point | tuple[float, float]) – The start point of the ellipse.

  • end (Point | tuple[float, float]) – The end point of the ellipse.

  • bCounterClockWise (bool) – Determines whether to use counter clockwise direction from start to end or not.

Returns:

The new ellipse.

Return type:

Ellipse

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
be = sketch.addBoundedEllipse(center=(0, 0), majorAxisPoint=(0, 0.3),
                  minorAxisPoint=(0.1, 0),start= (-0.1, 0), end=(0, -0.3),
                  bCounterClockWise=False)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addSpline(points, degree=3, periodic=False, interpolated=False)#

Adds a spline based on a list of points.

Parameters:
  • points (list[tuple[float, float]]| list[Point]) – The points of the spline.

  • degree (int) – The degree.

  • periodic (bool) – Determines whether it is periodic.

  • interpolated (bool) – Determines whether it should get interpolated.

Returns:

The new spline.

Return type:

Spline

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a spline with only line segments by providing the points
pl = sketch.addSpline(points=[(0, 0), (0.1, 0.3), (0.3, 0.2), (0.4, 0.4)],
                    degree=3,periodic=False, interpolated=False)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addPolyline(points)#

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

Parameters:
  • (list[tuple[float (points) – The points of the polyline.

  • float]] – The points of the polyline.

Returns:

The new created polyline.

Return type:

Polyline

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polyline with only line segments by providing the points
pl = sketch.addPolyline(points=[(0, 0), (0.1, 0.3), (0.3, 0.2), (0.4, 0.4)])
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
polylineStart(x, y)#

Starts the creation of a polyline on a specified Point.

Parameters:
  • x (float) – The x coordinate of the first point.

  • y (float) – The y coordinate of the first point.

Returns:

The new created polyline.

Return type:

Polyline

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polyline with lines and arcs
pl = sketch.polylineStart(0.1, 0.1)
result = sketch.polylineAddLineTo(pl, (0.2, 0.1))
result = sketch.polylineAddArcTo(pl, (0.3, 0.2), sketch.TANGENT_OUTWARD)
result = sketch.polylineAddLineTo(pl, (0.5, 0.3))
result = sketch.polylineAddArcTo(pl, (0.1, 0.1), sketch.TANGENT_OUTWARD)
polylineInfo = sketch.polylineEnd(pl)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
polylineAddLineTo(polyline, pointTo)#

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

Parameters:
  • polyline (Polyline) – The polyline that is being constructed.

  • pointTo (tuple[float, float]) – The position of the endpoint of the new line.

Returns:

True if the arc was successfully added to the polyline, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polyline with lines and arcs
pl = sketch.polylineStart(0.1, 0.1)
result = sketch.polylineAddLineTo(polyline=pl, pointTo=(0.2, 0.1))
result = sketch.polylineAddArcTo(polyline=pl,arcTo= (0.3, 0.2), direction=sketch.TANGENT_OUTWARD)
result = sketch.polylineAddLineTo(pl, (0.5, 0.3))
result = sketch.polylineAddArcTo(polyline=pl, arcTo=(0.1, 0.1),direction= sketch.TANGENT_OUTWARD)
polylineInfo = sketch.polylineEnd(polyline=pl)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
polylineAddArcTo(polyline, arcTo, direction)#

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

Parameters:
  • polyline (Polyline) – The polyline that is being constructed.

  • arcTo (tuple[float, float]) – The position of the endpoint of the new arc.

  • direction (enum) – The initial direction of the arc.

Returns:

True if the arc was successfully added to the polyline, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polyline with lines and arcs
pl = sketch.polylineStart(0.1, 0.1)
result = sketch.polylineAddLineTo(polyline=pl, pointTo=(0.2, 0.1))
result = sketch.polylineAddArcTo(polyline=pl,arcTo= (0.3, 0.2), direction=sketch.TANGENT_OUTWARD)
result = sketch.polylineAddLineTo(pl, (0.5, 0.3))
result = sketch.polylineAddArcTo(polyline=pl, arcTo=(0.1, 0.1),direction= sketch.TANGENT_OUTWARD)
polylineInfo = sketch.polylineEnd(polyline=pl)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
polylineEnd(polyline)#

Finishs the construction of the polyline.

Parameters:

polyline (Polyline) – The polyline that is being constructed.

Returns:

The points and lines of the polyline.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polyline with lines and arcs
pl = sketch.polylineStart(0.1, 0.1)
result = sketch.polylineAddLineTo(polyline=pl, pointTo=(0.2, 0.1))
result = sketch.polylineAddArcTo(polyline=pl,arcTo= (0.3, 0.2), direction=sketch.TANGENT_OUTWARD)
result = sketch.polylineAddLineTo(pl, (0.5, 0.3))
result = sketch.polylineAddArcTo(polyline=pl, arcTo=(0.1, 0.1),direction= sketch.TANGENT_OUTWARD)
polylineInfo = sketch.polylineEnd(polyline=pl)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addRectangleCenterVertex(center, vertex)#

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

Parameters:
  • center (tuple[float, float]) – The center of the rectangle.

  • vertex (tuple[float, float]) – A vertex of the rectangle.

Returns:

The points and lines of the rectangle.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a rectangle using center and one vertex
r1 = sketch.addRectangleCenterVertex(center=(0, 0),vertex= (0.1, 0.1))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addRectangle2Vertex(vertex1, vertex2)#

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

Parameters:
  • vertex1 (tuple[float, float]) – A vertex of the rectangle.

  • vertex2 (tuple[float, float]) – A vertex of the rectangle.

Returns:

The points and lines of the rectangle.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a rectangle using two vertex
r1 = sketch.addRectangle2Vertex(vertex1=(0, 0),vertex2= (0.1, 0.1))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addRectangle3Vertex(lowerLeft, lowerRight, upperRight)#

Adds a rectangle defined by three vertex.

Parameters:
  • lowerLeft (tuple[float, float]) – The lower left point of the rectangle.

  • lowerRight (tuple[float, float]) – The lower right point of the rectangle.

  • upperRight (tuple[float, float]) – The upper right point of the rectangle.

Returns:

The points and lines of the rectangle.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a rectangle using three vertex
r1 = sketch.addRectangle3Vertex(lowerLeft=(0, 0),lowerRight= (0, 0.1),upperRight=(0.2, 0.1))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addRectangleCenter2Points(center, lengthPoint, widthPoint)#

Adds a rectangle defined by center and two vertex.

Parameters:
  • center (tuple[float, float]) – The center of the rectangle.

  • lengthPoint (tuple[float, float]) – A vertex of the rectangle.

  • widthPoint (tuple[float, float]) – A vertex of the rectangle.

Returns:

The points and lines of the rectangle.

Return type:

tuple[list[Points], list[Lines]]

addParallelogram(lowerLeft, lowerRight, upperRight)#

Adds a parallelogram defined 3 vertex.

Parameters:
  • lowerLeft (tuple[float, float]) – The lower left point of of the parallelogram.

  • lowerRight (tuple[float, float]) – The lower right point of of the parallelogram.

  • upperRight (tuple[float, float]) – The lower right point of of the parallelogram.

Returns:

The points and lines of the parallelogram.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a Parallelogram using lower left, lower right and upper right points.
pl = sketch.addParallelogram(lowerLeft=(0, 0), lowerRight=(1, 5), upperRight=(3, 6))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addRegularPolygon(center, point, numSides, beMidPoint=False)#

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

Parameters:
  • center (tuple[float, float]) – The center of the regular polygon.

  • point (tuple[float, float]) – A vertex of the regular polygon.

  • numSides (int) – The number of sides.

  • beMidPoint (bool) –

Returns:

The points and lines of the rectangle.

Return type:

tuple[list[Points], list[Lines]]

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# create a polygon using center, one vertex and the number of sides
rp = sketch.addRegularPolygon(center=(0, 0), point=(0.3, 0), 
                                numSides=7,beMidPoint=False)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addConstraint(constraint, item1=None, item2=None, mirrorAxis=None)#

Adds a constraint for one or two items.

Parameters:
  • constraint (enum) – The constraint.

  • item1 (InterfaceItem) – The item to hold the constraint.

  • item2 (InterfaceItem) – The item to hold the constraint.

  • mirrorAxis (InterfaceItem) – The item for a mirror constraints axis.

Returns:

The new constraint.

Return type:

Constraint

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
l = sketch.addLineSegment((0, 0), (1, 1))
c = sketch.addConstraint(constraint=sketch.CONSTRAINT_VERTICAL, item1=l)
sketch.update()

l2 = sketch.addLineSegment((0, 0), (1, 2))
c = sketch.addConstraint(sketch.CONSTRAINT_PERPENDICULAR, item1=l, item2=l2,
                            mirrorAxis=None)
sketch.update()
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
addDimension(dimension, value=None, item1=None, item2=None, x=1.7976931348623157e+308, y=1.7976931348623157e+308, pickX=1.7976931348623157e+308, pickY=1.7976931348623157e+308)#

Defines constrain the dimensions of a sketch.

Parameters:
  • dimension (enum) – The type of dimension.

  • value – The value of the dimension.

  • item1 (InterfaceItem) – The item to hold the constraint.

  • item2 (InterfaceItem) – The item to hold the constraint.

Returns:

The new dimension.

Return type:

Dimension

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

# Add circles to the sketch
c1 = sketch.addCircleCenterRadius((0,0), 0.5)
c2 = sketch.addCircleCenterRadius((0,0), 0.4)

# Add dimensions to the circles
c1_dim=sketch.addDimension(sketch.CONSTRAINT_DIAMETER_ALIGNED, 1, item1=c1)
# Add a dimension to the circle
c2_dim=sketch.addDimension(sketch.CONSTRAINT_DIAMETER_ALIGNED, 0.8, item1=c2)

# create a variable for the dimension
model.variables.add('Var_D3',type=None,expression='1 m')
# create a variable for the dimension
model.variables.add('Var_D4',type=None,expression='0.8 m')

# asigning variable to dimension
sketch.setDimensionVariable(c1_dim, 'Var_R3')
sketch.setDimensionVariable(c2_dim, 'Var_R4')

  sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
isDimensionDriven(item)#

Returns True if the item is a dimension and is driven, False otherwise.

setDimensionIsDriven(item, state)#

Returns True if the item is a dimension and is driven, False otherwise.

deleteItem(item)#

Removes an item from the sketch.

Parameters:

item (InterfaceItem) – The item to be removed.

Returns:

True if the item has been successfully removed, False otherwise.

Return type:

bool

getEndPoints(item)#

Returns the item endpoints as a PointVector.

getItemStatus(item)#

Returns the status of item according the ITEM_STATUS enum.

setDimensionVariable(dimension, varName)#

Sets a variable as value for a dimension.

Parameters:
  • dimension (Constraint) – The dimension.

  • varName (str) – The name of the variable.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

# Add circles to the sketch
c1 = sketch.addCircleCenterRadius((0,0), 0.5)
c2 = sketch.addCircleCenterRadius((0,0), 0.4)

# Add dimensions to the circles
c1_dim=sketch.addDimension(sketch.CONSTRAINT_DIAMETER_ALIGNED, 1, item1=c1)
# Add a dimension to the circle
c2_dim=sketch.addDimension(sketch.CONSTRAINT_DIAMETER_ALIGNED, 0.8, item1=c2)

# create a variable for the dimension
model.variables.add('Var_D3',type=None,expression='1 m')
# create a variable for the dimension
model.variables.add('Var_D4',type=None,expression='0.8 m')

# asigning variable to dimension
sketch.setDimensionVariable(c1_dim, 'Var_R3')
sketch.setDimensionVariable(c2_dim, 'Var_R4')

  sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
getDimensionVariableName(dimension)#

Gets the variable of a dimension.

Parameters:

dimension (Constraint) – The dimension.

Returns:

The name of the variable.

Return type:

str

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# gets the origin of the sketch (x,y).
origin = sketch.origin()
#update the sketch   
sketch.update()  
# Finalize the sketch    
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
update()#

Evaluates and populates the sketch.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# gets the origin of the sketch (x,y).
origin = sketch.origin()
#update the sketch   
sketch.update()  
# Finalize the sketch    
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
populate()#

Redraws the sketch if required.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# gets the origin of the sketch (x,y).
origin = sketch.origin()
#populate the sketch   
sketch.populate()  
# Finalize the sketch    
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
evaluate()#

Recalculates sketch items according to constraints.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# gets the origin of the sketch (x,y).
origin = sketch.origin()
#evaluate the sketch   
sketch.evaluate()  
# Finalize the sketch    
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
origin()#

Returns the Point for the origin.

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# gets the origin of the sketch (x,y).
origin = sketch.origin()     
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
findPoint(uid)#

Returns the Point with the specified id.

findLine(uid)#

Returns the Line with the specified id.

findCircle(uid)#

Returns the Circle with the specified id.

findEllipse(uid)#

Returns the Ellipse with the specified id.

findSpline(uid)#

Returns the Spline with the specified id.

findConstraint(uid)#

Returns the Constraint with the specified id.

findItem(uid)#

Returns the InterfaceItem with the specified id.

hasPoint(uid)#

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

hasLine(uid)#

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

hasCircle(uid)#

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

hasEllipse(uid)#

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

hasSpline(uid)#

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

hasConstraint(uid)#

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

hasItem(uid)#

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

split(curvePoint, breakPoint)#

Split a curve in two at a defined break point.

Parameters:
  • curvePoint (tuple[float, float]) – The point of the curve to be splitted.

  • breakPoint (tuple[float, float]) – The point of break.

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
sketch.addLineSegment((0, 0), (3, 3))
result = sketch.split(curvePoint=(0, 0), breakPoint=(1, 1))

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
extend(curvePoint, limitPoint)#

Extend or shorten an entity of a sketch curve.

Parameters:
  • curvePoint (tuple[float, float]) – The point of the curve to extend.

  • limitPoint (tuple[float, float]) – The point of the limit curve.

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
sketch.addLineSegment((0, 0), (1, 1))
sketch.addLineSegment((0, 2), (8, 2))
result = sketch.extend(curvePoint=(1, 1),limitPoint= (4, 2))
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
fillet(vertices, radius=0)#

Fillet a list of vertices with the specified radius.

Parameters:
  • vertices (list[Points],) – The vertices to be filleted.

  • radius (float) – The fillet radius.

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
r = sketch.addRectangle2Vertex((0, 0), (1, 1))
vertex = r[0]
result = sketch.fillet(vertices=vertex, radius=0.2)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
mirror(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.

Parameters:
  • vertices (list[InterfaceItem]) – The curves to be mirrored.

  • mirrorLine (Line) – The mirror line.

Returns:

True if all items have been mirrored, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
ls1 = sketch.addLineSegment((0, 0), (0, 1))
a1 = sketch.addArcCenter2Points((1, 1), (0, 1), (2, 1))
ls2 = sketch.addLineSegment((2, 1), (3, 1))
mirrorLine = sketch.addLineSegment((5, -1), (5, 4))
result = sketch.mirror(curves=[ls1, a1, ls2], mirrorLine=mirrorLine)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
trim(x, y)#

Removes one or more geometric entities below the (x, y) coordinates of the sketch curve.

Parameters:
  • x (float) – The x coordinate.

  • y (float) – The y coordinate.

Returns:

True if a geometric entity was trimmed, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
sketch.addLineSegment((0, 0), (0, 10))
sketch.addLineSegment((5, 0), (5, 10))
sketch.addLineSegment((-5, 5), (15, 5))
result = sketch.trim(2.5, 5)
# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
offset(point, distance)#

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

Parameters:
  • point (tuple[float, float]) –

  • distance (float) –

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)
# Add polyline to the sketch
pl = sketch.addPolyline([(0, 0), (0.1, 0.3), (0.3, 0.2), (0.4, 0.4)])

result = sketch.offset(point=(0, 0), distance=0.1)

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
linearPattern(entities, direction1, copy1=3, distance1=0.1, symmetry1=False, direction2=None, copy2=3, distance2=0.1, symmetry2=False)#

Pattern sketch entities in a linear direction.

Parameters:
  • entities (list[SketchItem]) – Sketch curve entity to create linear pattern.

  • direction1 (Line) – Direction 1 for sketch pattern.

  • copy1 (int) – Number of copies in direction 1.

  • distance1 (float) – Distance between two copies in direction 1.

  • symmetry1 (bool) – Symmetry in Direction 1.

  • direction2 (Line) – Direction 2 for sketch pattern.

  • copy2 (int) – Number of copies in direction 2.

  • distance2 (float) – Distance between two copies in direction 2.

  • symmetry2 (bool) – Symmetry in Direction 2.

Returns:

LinearPattern Object.

Return type:

LinearPattern

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

# Point1
p = sketch.addPoint(1, 0)

# line
p1 = sketch.addPoint(0, 1)
p2 = sketch.addPoint(0, 2)
line = sketch.addLineSegment(p1, p2)

# direction
p1 = sketch.addPoint(0, 1)
p2 = sketch.addPoint(0, 2)
dir = sketch.addLineSegment(p1, p2)
# This method is used to create a linear pattern of the sketch
# Pattern allows to create multiple copies of the selected entities
# it allows to create a linear pattern in two directions
# The first direction is defined by the direction1 argument
# The second direction is defined by the direction2 argument
# The copy1 and copy2 arguments define the number of copies in each direction 
pattern = sketch.linearPattern(entities=ls1, direction1=dir, copy1=5,
                        distance1=0.1, symmetry1=False,
                        direction2=None, copy2=3, distance2=0.1, 
                        symmetry2=False)

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
circularPattern(entities, point, copy, angle, symmetry, createDimension=True, equalSpacing=False)#

Pattern sketch entities around a point.

Parameters:
  • entities (list[SketchItem]) – Sketch curve entity to create linear pattern.

  • point (Point) – Center Point for circular sketch pattern.

  • copy (int) – Number of copies.

  • angle (float) – Distance between two copies in direction 1.

  • symmetry (bool) – Symmetry in Direction 1.

  • createDimension (bool) – If True, dimension is added otherwise not.

  • equalSpacing (bool) – If True, equally space the copies otherwise not.

Returns:

CircularPattern Object.

Return type:

CircularPattern

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

# Point1
p = sketch.addPoint(1, 0)

# line
p1 = sketch.addPoint(0, 1)
p2 = sketch.addPoint(0, 2)
line = sketch.addLineSegment(p1, p2)

pattern = sketch.circularPattern(entities=line, point=p, copy=5, angle=20, 
            symmetry=False,createDimension=True, equalSpacing=False)

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
translate(entities, direction, value, keepRelations=True)#

Translate Sketch entities.

Parameters:
  • entities (list[SketchItem]) – Sketch entity to translate.

  • direction (tuple[float, float]) – Direction for sketch translation.

  • value (float) – Translate value for sketch entity.

  • keepRelations (bool) – Keep relations between sketch entities after translation.

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

p1 = sketch.addPoint(1, 0)
p2 = sketch.addPoint(2, 0)
p1.position = (0, 0)
ls1 = sketch.addLineSegment(p1, p2)

# This method is used to translate the sketch around a point
result = sketch.translate(entities=ls1, direction=(0, 1), value=50,keepRelations=True)

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
rotate(entities, center, angle, keepRelations=True)#

Rotate Sketch entities.

Parameters:
  • entities (list[SketchItem]) – Sketch entity to rotate.

  • center (Point) – Center point to rotate sketch entity.

  • angle (float) – Rotation angle for sketch entity.

  • keepRelations (bool) – Keep relations between sketch entities after rotation.

Returns:

True on success, False otherwise.

Return type:

bool

Example

from hwx import inspire
from hwx.common.math import Matrix44

# Get the currently active Inspire model
model = inspire.getActiveModel()
# Alternatively, you can create a new model
# model = inspire.newModel()

# Create a Sketch object on the Global Z plane
sketch = inspire.Sketch(system='Global Z',feature=None, origin=None, normal=None)

p1 = sketch.addPoint(1, 0)
p2 = sketch.addPoint(2, 0)
p1.position = (0, 0)
ls1 = sketch.addLineSegment(p1, p2)
p3 = sketch.addPoint(1, 0)
# This method is used to rotate the sketch around a point
result = sketch.rotate(entities=ls1, center=p3, angle=80, keepRelations=True)

# Finalize the sketch
sketch_part = sketch.realize() 
inspire.orientView(direction='Iso')
parameterManager()#

Return the Parameter Manager for this sketch

setParameterManager(pm)#

Set the Parameter Manager to use for this sketch