Operations#

pushPull#

pushPull(feature, depth, newPart=False, resultType=None)#

Pushes or pulls a face or an edge to a specified distance.

Parameters:
  • feature (Feature) – Feature to push or pull.

  • depth (float | str) – The precise distance. A positive value extends, whereas a negative value contracts.

  • newPart (bool) – If True, creates a new Part as a result of pushPull operation.

  • resultType (str) – Result type of pushPull operation. This option is valid only for pushPull a sketch on face. - NEW_PART - ADD - REMOVE - REPLACE

Returns:

If New Part created, otherwise return None.

Return type:

Part

Example

# This script demonstrates the usage of pushPull function.

from hwx import inspire

model = inspire.getModel()
#Alternatively, you can use newModel() to clearing the existing Model.
# Create a new model
#model = inspire.newModel()

# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(name= 'Block 1',x=0.1,y=0.1,z=0.02)

#Get a feature of type FeaturePlanar from the block Part
featPlanar1 = block.getFeatures(type='FeaturePlanar')[0]

# Usage of pushPull to push or Pull a feature.

# When you pass a positive value to the depth argument, the feature will
# be pulled along the normal direction of the feature.

# When you pass a negative value to the depth argument, the feature will
# be pushed against the normal direction of the feature.
inspire.geometry.pushPull(feature=featPlanar1, depth='10 mm',newPart=False)

inspire.fitView()
print(f"{block.name} is pushed to 10 mm.")
inspire.orientView(direction="isometric")

# Usage of variable to pushPull a feature.

# The usage of model variable in pushPull make the pushPull operation parametric.
# The pushPull operation will be updated whenever the variable 'depth' is changed.

# Create a variable 'depth' of type length with value 8 cm
model.variables.add(name="depth", type="length", expression='8cm')

featPlanar2 = block.getFeatures(type='FeaturePlanar')[3]

# Usage of pushPull with variable.
Part1 =inspire.geometry.pushPull(feature=featPlanar2, depth='depth',newPart=True)

inspire.fitView()
print(f"{block.name} is pulled by {model.variables['depth'].value } using 'depth' variable.")
inspire.orientView(direction="isometric")

# Usage of resultType in pushPull
# resultType argument works only with sketch features that are created on a part face.

# get a feature of type FeaturePlanar from the Part1 Part
featPlanar3 = Part1.getFeatures(type='FeaturePlanar')[3]

# Create a sketch on the face of the part.
# Sketch module supports only 2D and the sketch plane is defined by the face normal
# and the 3D origin point of the face.

s = inspire.Sketch(feature=featPlanar3, origin=featPlanar3.cg, normal=featPlanar3.normal)

#get the local points from a global 3D point.
x,y = s.convertGlobalToLocalPoint(featPlanar3.cg)

# Add a circle defined by its center and radius to the sketch object.
c1 = s.addCircleCenterRadius((x,y), 0.01)

# Adding a dimension to the circle to control the diameter of the circle.
d = s.addDimension(s.DIMENSION_DIAMETER_ALIGNED, 0.02, item1=c1)

# Create a variable 'circle_diameter' of type length with value 0.02
model.variables.add(name="circle_diameter", type="length", expression='0.02')

# Set the variable name 'circle_diameter' to the circle dimension object.
s.setDimensionVariable(d,'circle_diameter')

# Sketch needs to be realized to get the sketch part.
sketchPart = s.realize()

# Get the sketch face from the sketch part.
sketchface = sketchPart.getFeatures(type='FeatureArea')[0]

# Usage of pushPull to pushPull a sketch.
# negative depth value will push the sketch face against the normal direction of the sketch face.
# resultType='REMOVE' will remove and make a hole in the part.

sketchface.pushPull(depth= -0.02,resultType='REMOVE')
print(f"{sketchface.name} is pushed to 0.02 mm using 'circle_diameter' variable.")


# Example to edit pushPull operation.

# Get the last pushPull CF from the model.
pushPullCF = model.construction[-1]

# Alternatively, you can get the CF by its name from the model
#pushPullCF = model.construction.getCF(name= 'PushPull 3')

# Edit the push-pull CF: change depth to 0.03 with a variable and
# change the resultType from REMOVE to ADD

with pushPullCF.edit():

    # Create a variable 'height' of type length with value 0.03
    model.variables.add(name="height", type="length", expression='0.03')

    # Set the depth to the variable 'height'
    pushPullCF.depth = "height"

    # Set the resultType to ADD
    pushPullCF.resultType = 'ADD'

    print(f"The depth and resultType of {pushPullCF.name} CF are changed.")
inspire.fitView()

extract#

extract(features, maintainReference=True)#

Extracts geometry features and transfer them into a new part.

This is useful when you want to create a new part from existing features

Parameters:
  • features (list[ FeaturePoint, FeatureArea, FeatureCurve]) – Feature to be extracted. All features in the list must be of the same type (e.g., FeaturePoint, or FeatureArea, or FeatureCurve).

  • maintainReference (bool) – If true, set reference associativity otherwise not.

Returns:

New part created.

Return type:

Part

Example

# This script demonstrates the usage of extract function.

from hwx import inspire

# You can use newModel() to clearing the existing Model.
#model = inspire.newModel()

# Alternatively, you can use getModel() to open an existing model.
model = inspire.getModel()

#Open a tutorial file
model = inspire.openTutorialFile("Structures/base.x_t")
#Get the first part of the model
part = model.parts[0]

#Get the list of FeaturePlanar feature from the part
featPlanar=part.getFeatures(type='FeaturePoint')

#maintainReference enables the reference between the original part and the extracted part.
part1 = inspire.geometry.extract(featPlanar,maintainReference =True)

print(f"Extracted all the points form {part.name} part into a  {part1.name} part.")
inspire.orientView(direction="isometric")

extractCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
#extractCF = model.construction.getCF(name= 'Extract 1')

# Edit the Extract 1 CF:
with extractCF.edit():
    # Get the first FeatureArea feature from the part
    featArea = part.getFeatures(type='FeatureArea')[0]
    extractCF.features = featArea
    print(f"{extractCF.name} CF is modified.")

inspire.fitView()

mirror#

mirror(entity, planeOrigin=None, planeNormal=None, keep=True)#

Mirrors part across a symmetry plane.

If entity is a Part, the planeOrigin and planeNormal need to be passed

Parameters:
  • entity (Part | FeaturePlanar) – Part from which a mirror part needs to be created or a Planar feature which needs to be mirrored across the plane

  • planeOrigin (math.Point) – The origin of the symmetry plane.

  • planeNormal (math.Vector) – The normal of the symmetry plane.

  • keep (bool) – If True it keeps the original part, if False it removes it.

Returns:

New mirrored part created.

Return type:

Part

Example

# This script demonstrates the usage of mirror function.

# There are two ways, user can create a mirrored part. One by calling
# mirror method on the part, or else on a planar feature on which
# the mirrored part will be created
from hwx import inspire

model = inspire.getModel()
#Alternatively, you can use newModel() to clearing the existing Model.
# Create a new model
#model = inspire.newModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box = model.model.createSolidBlock(x=0.1,y=0.1,z=0.02)

# First using the part
mirrorpart1 = box.mirror(planeOrigin=(0, 0, 1), planeNormal=(0, 0, 1))
#Alternatively, you can use below method to mirror the part.
#inspire.geometry.mirror(entity=box, planeOrigin=(0, 0, 1), planeNormal=(0, 0, 1))
print(f"A new part {mirrorpart1.name} has been mirrored")

featurePlanar = box.getFeatures(type='FeaturePlanar')[1]
# Then using the planar feature
mirrorpart2 = featurePlanar.mirror()
print(f"New part {mirrorpart2.name} has been mirrored from the planar feature")
inspire.orientView(direction="isometric")

mirrorCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
#mirrorCF = model.construction.getCF(name= 'Mirror 2')

# Edit the Mirror 2 CF:
with mirrorCF.edit():
    mirrorCF.entity = [box]
    #keeps one the mirrored part and removes the original part used for mirroring.
    mirrorCF.keep = False
    # Get the bottom face from the part and query its center of gravity and normal
    featurePlanar = box.getFeatures(type='FeaturePlanar')[4]
    planeOrigin = featurePlanar.cg
    planeNormal = featurePlanar.normal
    # Set the plane origin and normal to the mirror CF
    mirrorCF.mirrorAboutPlane = [planeOrigin, planeNormal]
    #Alternatively, you can set the plane origin and normal by using the points
    #mirrorCF.mirrorAboutPlane = [(0,0,0), (0,0,1)]
    print(f"{mirrorCF.name} CF is modified.")

inspire.fitView()

rotate#

rotate(part, axis, angle, degrees=True)#

Rotates a part around the specified axis.

This is a body rotation.

Parameters:
  • part (Part) – The part to rotate.

  • axis (Vector | str) – The rotation axis. If axis a string, valid choices are “x”, “y”, “z”.

  • angle (float) – The rotation angle.

  • degrees (bool) – If True, angle is considered in degrees, if False in radians.

Example

# This script demonstrates the usage of rotate function.
from hwx import inspire

#Clears the existing Model and creates a new modeling session.
model = inspire.newModel()

#Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

model.variables.add(name="radius", type="length", expression='1')
model.variables.add(name="height", type="length", expression='6')

# Create a parametric solid cylinder with radius and height as variables
cylinder1 = model.createSolidCylinder(
    radius="radius",
    height="height",
    color='blue'
)
cylinder2 = model.createSolidCylinder(
    radius="radius",
    height="height",
    color='red'
)
cylinder2.rotate('x', 45, degrees=True)
#Alternatively, you can use below method to rotate the part.
#inspire.geometry.rotate(part=cylinder2,axis= 'x',angle = 45, degrees=True)
inspire.fitView()

moveCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
#moveCF = model.construction.getCF(name= 'Move 1')

# Edit the Move 1 CF:
with moveCF.edit():
    from hwx.common.math import Matrix44, Vector
    mtx = moveCF.entities[0].position
    #Vector represents the axis of rotation
    mtx = mtx.rotate(axis=Vector(0, 1, 0),angle=45,degrees=True)
    moveCF.position = mtx

translate#

translate(part, x=0, y=None, z=None)#

Translates by the specified distance.

If y is None, x is assumed to be a list of 3 floats.

Parameters:
  • part (Part) – The part to translate.

  • x (float) – The distance to translate the ‘x’ vector.

  • y (float) – The distance to translate the ‘y’ vector.

  • z (float) – The distance to translate the ‘z’ vector.

Example

# This script demonstrates the usage of translate function.
from hwx import inspire

# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()

# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Create a model variables radius and height.
model.variables.add(name="radius", type="length", expression='1')
model.variables.add(name="height", type="length", expression='6')

# Create a parametric solid cylinder with radius and height as variables
cylinder1 = model.createSolidCylinder(
    radius="radius",
    height="height",
    color='blue'
)
cylinder2 = model.createSolidCylinder(
    radius="radius",
    height="height",
    color='red'
)
# Translate the cylinder2 by 10 units in x direction
# This allows to move a part to a new location.
cylinder2.translate(x=(10, 0, 0))
# Argument x is mandatory and y,z are optional.
# Alternatively, you can use below method to translate the part.
# inspire.geometry.translate(part=cylinder2, x=(10,0,0))

inspire.fitView()

moveCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# moveCF = model.construction.getCF(name= 'Move 1')

# Edit the Move 1 CF:
with moveCF.edit():
    from hwx.common.math import Matrix44, Vector
    # Get the first part'a matrix from the CF
    mtx = moveCF.entities[0].position
    # Move the part by 5 m in x direction 10 m in y direction and 10 m in z direction
    mtx = mtx.translate(x=(5, 10, 10))
    moveCF.position = mtx
    print(f"{moveCF.name} CF is modified.")

inspire.orientView(direction="isometric")

move#

move(part, position)#

Translates and/or rotates a part.

Parameters:
  • part (Part) – The part to move.

  • position (math.Matrix44) – The position to move the part at.

Deprecated since version 2025: This will be removed in 2026. Use the move2 function instead

Example

# This script demonstrates the usage of move function.

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

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

cylinder1 = model.createSolidCylinder(
radius=1,
height=6,
color='blue'
)
cylinder2 = model.createSolidCylinder(
radius=1,
height=6,
color='red'
)
mat = Matrix44(origin=[1, 2, 3], angles=[30, 0, 0], degrees=True)
# With move tool, We can translate and rotate the part.

cylinder2.move(position = mat)
# Alternatively, you can use below method to move the part.
# inspire.geometry.move(part=cylinder2, position=mat)
inspire.fitView()

deleteFaces2#

deleteFaces2(features)#

New delete faces which deletes the specified faces from the part.

Parameters:

features (list[Feature]) – Features to be removed.

Example

# This script demonstrates the usage of deleteFaces2 function.

# Delete faces from solid or sheet parts.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block
box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
featPlanar = box.getFeatures(type='FeaturePlanar')[2]
inspire.geometry.deleteFaces2(features  = [featPlanar])
print(f"Deleted a planar face from the part ")
inspire.orientView(direction="isometric")
# Get the last deleteFaces2 CF from the model.
deleteFaces2CF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# deleteFaces2CF = model.construction.getCF(name= 'Delete Faces 1')

# Edit the deleteFaces2 CF:
with deleteFaces2CF.edit():
    deleteFaces2CF.features = box.getFeatures(type='FeaturePlanar')[:2]
    print(f"{deleteFaces2CF.name} CF is modified.")

inspire.orientView(direction="isometric")

scale#

scale(parts, value=1.1)#

Resizes the part to the specified scale value.

This is useful when working with an imported model that is associated with a different default unit system.

Parameters:
  • parts (list[Part]) – Parts that need to be scaled.

  • value (float | str) – The scale factor. If value is a string it can be a Model Variable or a value with units.

Example

# This script demonstrates the usage of scale function.

from hwx import inspire
# Open a tutorial file plate.x_t from the Inspire installation directory
model=inspire.openTutorialFile("Structures/plate.x_t")
# Get a part of the model.
part=model.getChild(type='Part')
# Add a model variable 'scale' of type unitless with value 5.0.

model.variables.add("scale", type="unitless", expression=5.0)
# Resizes the part to the specified scale value.
# usage of model variable in scale function makes the scale operation Parametric.
part.scale(value="scale")
# Alternatively, you can use below method to scale the part.
# inspire.geometry.scale(parts=[part], value=2.0)
print("Part is scaled by factor 2")

# update the scale variable value to 3.0, update the corresponding scale CF.
model.variables.update(name="scale", expression=3.0)
inspire.fitView()

# Get the last scale CF from the model.
scaleCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# scaleCF = model.construction.getCF(name= 'Scale 1')
# Edit the scale CF:
with scaleCF.edit():
    # Get all the part from the model
    part = model.getChildren(type='Part')
    # Set the part to the scale CF
    scaleCF.parts = part
    # Set the scale value to 4.0
    scaleCF.value = 4.0
    print(f"{scaleCF.name} CF is modified.")

inspire.orientView(direction="isometric")

booleanCombine#

booleanCombine(target, tools=None)#

Combines the specified parts.

Parameters:
  • target (Part) – Part to be combined with tools.

  • tools (list[Part]) – Parts to be combined with target. Destroyed after combine.

Returns:

The combined part.

Return type:

Part

Example

# This script demonstrates the usage of booleanCombine function.

# To combine two or more geometric parts, you can use the booleanCombine function.
# The booleanCombine function should not be used to combine part's features.
# This function should not be used to combine implicit parts; Use combine function instead.

from hwx import inspire
#clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(name= 'Block 1',x=0.1,y=0.1,z=0.02)
box = model.createSolidBlock(name= 'Block 2', x=0.1, y=0.1, z=0.02,location=(0,0,0.04))
# Creating a solid sphere of radius 0.05.
sphere = model.createSolidSphere(name= 'Sphere 1',radius=0.05, location=(0,0,0))
# Combine the block and sphere using booleanCombine function.
block.booleanCombine(tools=sphere)
# Alternatively, you can use below method to combine the part.
# inspire.geometry.booleanCombine(target=block, tools=[sphere])
print(f"Block is combined with sphere using booleanCombine function.")
inspire.orientView(direction="isometric")

# Get the last booleanCombine CF from the model.
booleanCombineCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# booleanCombineCF = model.construction.getCF(name= 'Combine 1')

## Edit the booleanCombine CF:
with booleanCombineCF.edit():
    # Get the Part named 'Block 1' from the model
    block = model.getChild(type='Part', name='Block 1')
    # Set the target to the booleanCombine CF
    booleanCombineCF.target = block
    # Get the Part named 'Block 2' from the model
    box =model.getChild(type='Part', name='Block 2')
    #Get the Part named 'Sphere 1' from the model
    sphere = model.getChild(type='Part',name='Sphere 1')
    # Set the tools to the booleanCombine CF
    booleanCombineCF.tools = [sphere,box]
    print(f"{booleanCombineCF.name} CF is modified.")

inspire.orientView(direction="isometric")

booleanSubtract#

booleanSubtract(targets, tools, keepTools=False)#

Carves out one set of solid objects from another set of solid objects.

Parameters:
  • targets (list[Part]) – The parts being carved.

  • tools (list[Part]) – The parts doing the carving.

  • keepTools (bool) – If True, preserves the tools after the operation.

Returns:

The remaining part.

Return type:

Part

Example

# This script demonstrates the usage of booleanSubtract function.

# To Subtract two or more geometric parts, you can use the booleanSubtract function.
# The booleanSubtract function should not be used to subtract part's features.
# This function should not be used to Subtract implicit parts; Use subtract function instead.

from hwx import inspire
#clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(name= 'Block 1',x=0.1,y=0.1,z=0.02)
box = model.createSolidBlock(name= 'Block 2', x=0.1, y=0.1, z=0.02,location=(0,0,0.03))
# Creating a solid sphere of radius 0.05.
sphere = model.createSolidSphere(name= 'Sphere 1',radius=0.05, location=(0,0,0))
# Subtract the block and sphere using booleanSubtract function.
# keepTools is set to False to remove the tools after the operation.
# From targets part, the tools are subtracted.
block.booleanSubtract(tools=sphere, keepTools=False)
# Alternatively, you can use below method to Subtract the part.
# inspire.geometry.booleanSubtract(targets=block, tools=[sphere], keepTools=False)
print(f"Sphere is subtracted from Block using booleanSubtract function.")
inspire.orientView(direction="isometric")

# Get the last booleanSubtract CF from the model.
booleanSubtractCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# booleanSubtractCF = model.construction.getCF(name= 'Subtract 1')

## Edit the booleanSubtract CF:
with booleanSubtractCF.edit():
    # Get the Part named 'Block 1' from the model
    block = model.getChild(type='Part', name='Block 1')
    # Get the Part named 'Block 2' from the model
    box =model.getChild(type='Part', name='Block 2')
    # Set the target to the booleanSubtract CF
    booleanSubtractCF.targets = [block,box ]
    #Get the Part named 'Sphere 1' from the model
    sphere = model.getChild(type='Part',name='Sphere 1')
    # Set the tools to the booleanSubtract CF
    booleanSubtractCF.tools = [sphere]
    print(f"{booleanSubtractCF.name} CF is modified.")
    # Set the keepTools to True to keep the tools after the operation.
    booleanSubtractCF.keepTools = True

inspire.orientView(direction="isometric")

booleanIntersect#

booleanIntersect(targets, tools, keepTargets=False, keepTools=False)#

Retains only the intersecting portions of two sets of solid objects.

Parameters:
  • targets (list[Part]) – The first set of parts.

  • tools (list[Part]) – A list of parts for boolean intersect operation.

  • keepTargets (bool) – If True, preserves the target parts after the operation.

  • keepTools (bool) – If True, preserves the tools parts after the operation.

Returns:

The intersected part.

Return type:

Part

Example

# This script demonstrates the usage of booleanIntersect function.
# To Intersect two or more geometric parts, you can use the booleanIntersect function.
# The booleanIntersect function should not be used to Intersect part's features eg. FeatureArea, FeatureCurve.
# This function should not be used to Intersect implicit parts; Use intersect function instead.

from hwx import inspire
#clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(name= 'Block 1',x=0.1,y=0.1,z=0.02)
box = model.createSolidBlock(name= 'Block 2', x=0.1, y=0.1, z=0.02,location=(0,0,0.04))
box1 = model.createSolidBlock(name= 'Block 3', x=0.1, y=0.1, z=0.02,location=(0,0,-0.04))
# Creating a solid sphere of radius 0.05.
sphere = model.createSolidSphere(name= 'Sphere 1',radius=0.05, location=(0,0,0))
# Intersect the block and sphere using booleanIntersect function.
# keepTools is set to False to remove the tools after the operation.
# Retains only the intersecting portions of two sets of solid objects.
block.booleanIntersect(tools=sphere, keepTargets=False, keepTools=False)
# Alternatively, you can use below method to Intersect the part.
# inspire.geometry.booleanIntersect(targets=block, tools=[sphere] ,keepTargets=False, keepTools=False)
print(f"Block is Intersected with sphere using booleanIntersect function.")
inspire.orientView(direction="isometric")
# Get the last booleanIntersect CF from the model.
booleanIntersectCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# booleanIntersectCF = model.construction.getCF(name= 'Intersect 1')

# Edit the booleanIntersect CF:
with booleanIntersectCF.edit():
    # Get the Part named 'Block 1' from the model
    block = model.getChild(type='Part', name='Block 1')
    # Get the Part named 'Block 2' from the model
    box =model.getChild(type='Part', name='Block 2')
    # Get the Part named 'Block 2' from the model
    box1 =model.getChild(type='Part', name='Block 3')
    # Set the target to the booleanIntersect CF
    booleanIntersectCF.targets = [block, box, box1 ]
    #Get the Part named 'Sphere 1' from the model
    sphere = model.getChild(type='Part',name='Sphere 1')
    # Set the tools to the booleanIntersect CF
    booleanIntersectCF.tools = [sphere]
    print(f"{booleanIntersectCF.name} CF is modified.")
    # Set the keepTargets and keepTools to False to remove the targets and tools after the operation.
    booleanIntersectCF.keepTargets = False
    booleanIntersectCF.keepTools = False
inspire.orientView(direction="isometric")

slice#

slice(targets, cutOrigin=None, cutNormal=None, surfaceFeature=None, extendSurface=True, cuttingSheetPart=None)#

Slices a set of solid objects with a cutting plane or cutting surface.

You must provide cutOrigin and cutNormal or surfaceFeature.

Parameters:
  • targets (list[Part]) – The parts to slice across the cutting plane.

  • cutOrigin (math.Point) – The origin of the cutting plane.

  • cutNormal (math.Vector) – The normal of the cutting plane.

  • surfaceFeature (FeatureArea) – The surface to slice the enity accross.

  • extendSurface (bool) – Set Automatic extension On/Off for tool Surface.

  • cuttingSheetPart (Part) – The cuting sheet part to slice the enity accross.

Returns:

The new sliced part created.

Return type:

Part

Example

# This script demonstrates the usage of slice function.
# The slice function is used to slice or cut a part into two parts.

# There are three ways, user can create a slice part.
# One by calling slice method on the part with cutNormal & cutOrigion
# Two by calling slice method with surfaceFeature to slice out on surface mode.
# Three by calling slice method with cuttingSheetPart to slice out.
# cuttingSheetPart is a sheet part that is used to slice the target part.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 2, width 1 and height 1.
part = model.createSolidBlock(x=2, y=1, z=1, location=(0, 0, 0))
history = model.history

# First using the Plane Slice
part.slice(cutOrigin=(0,0,0), cutNormal=(1,0,0))
# Alternatively, you can use below method to slice the part.
# inspire.geometry.slice(targets=part, cutOrigin=(0,0,0), cutNormal=(1,0,0)
                        # surfaceFeature=feature, extendSurface=True, cuttingSheetPart=None)
print("A new part has been sliced out from the existing part on Plane Mode "
      "with both cutNormal and cutOrigin")

# Second using the Surface Slice
box = model.createSolidBlock(x=1, y=1, z=1, location=(-1, 0.5, 0))
feature = box.getFeatures(type ='FeaturePlanar')[1]
part.slice(surfaceFeature=feature, extendSurface=True)
# Alternatively, you can use below method to slice the part.
# inspire.geometry.slice(targets=part, cutOrigin=None, cutNormal=None,
                        # surfaceFeature=feature, extendSurface=True, cuttingSheetPart=None)

# Third using the cuttingSheetPart
sheetPart = model.createSheetRectangle( x=.06,  y=.08, location=[1.5, 0, .5])
sheetPart = model.createSheetRectangle(x=.06, y=.08, location=[1.5, 0, .5])
print(f"{sheetPart.name} is having dimension of {sheetPart.dimensions}.")
# The cuttingSheetPart is used to slice the target part.
part.slice(cuttingSheetPart=sheetPart)
# Alternatively, you can use below method to slice the part.
# inspire.geometry.slice(targets=part, cutOrigin=None, cutNormal=None,
                        # surfaceFeature=None,
                        # extendSurface=True,
                        # cuttingSheetPart=sheetPart)
#Create a history note for the slice operation for undo/redo.
history.noteState()
inspire.orientView(direction="isometric")

# Get the last slice CF from the model.
sliceCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# sliceCF = model.construction.getCF(name= 'Slice 3')
# Edit the slice CF:
with sliceCF.edit():
    # Changing the slice target parts
    sliceCF.targets = [part,box]

inspire.orientView(direction="isometric")

simplifyImprints#

simplifyImprints(entity)#

Finds and removes imprints from a part.

An imprint is an edge or a point that appears on a surface that can be removed without changing the underlying integrity of the surface, such as scratches or trimmed points.

Parameters:

entity (Part | Assembly | FeatureLinear) – Part/Assembly from which you want to remove the imprints from or FeatureLinear imprint to be removed.

Example

# This script demonstrates the usage of simplifyImprints function.

# There are two ways, user can remove an imprint from model. One by calling
# simplifyImprints on the imprint feature or choose the part/model from which you
# want to remove the imprints from.
from hwx import inspire
from hwx.inspire.demo import openDemoFile

# Open a demo file
model = openDemoFile("Imprints.x_t")
#Gets all the FeatureLinear parts form model.
linearFeatures = model.getFeatures(type='FeatureLinear')
# Removing Imprint feature
linearFeatures[0].simplifyImprints()
# Alternatively, you can use below method to remove the imprint.
# inspire.geometry.simplifyImprints(entity=linearFeatures[0])

# Alternatively, you can use below method to all imprints form the entire model.
# inspire.geometry.simplifyImprints(entity=model)
print("A line imprint has been removed from the part")

part = model.getChild(type='Part', name = 'Block 1')
# Removing Imprints from a part
part.simplifyImprints()
# Alternatively, you can use below method to remove the imprint.
# inspire.geometry.simplifyImprints(entity=part)
print(f"All the imprint has been removed from the part {part.name}")
inspire.orientView(direction="isometric")

simplifyRounds#

simplifyRounds(entity, roundType='ALL', minSize=0, maxSize=None)#

Finds and removes both round (convex) and fillet (concave) surfaces.

Parameters:
  • entity (Part | Assembly | Feature) – Part/Assembly from which you want to remove the fillets, chamfers from or a Feature to be removed.

  • roundType (str) – Valid values are: ROUNDS, FILLETS, CHAMFERS and ALL.

  • minSize (float) – Minimum size of round.

  • maxSize (float) – Maximum size of round.

Example

# This script demonstrates the usage of simplifyRounds function.
# The simplifyRounds function is used to remove the fillet features from the part.

# There are two ways, user can remove a round or fillets from model. One by calling
# simplifyRounds on the feature or choose the part from which you
# want to remove the rounds from.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock()
feats = box.getFeatures(type='FeatureLinear')[:4]

# Adding fillets with 60 mm radius to the part
inspire.geometry.edgeFillet(feature=feats, radius='60mm')

# Adding fillets with 50 mm radius to the part
feats1 = box.getFeatures(type='FeatureLinear')[8]
inspire.geometry.edgeFillet(feature=feats1, radius='50mm')

# Adding fillets with 50 mm radius to the part
feats2 = box.getFeatures(type='FeatureLinear')[10]
inspire.geometry.edgeFillet(feature=feats2, radius='90mm')

# Create holes on the box part.
# Create a solid cylinder with radius 0.1 and height 1.3 and location (0.2, 0.2, 0)
cylinder1 = model.createSolidCylinder(radius=0.1,  height=1.3, location=(.2, .2, 0)  )
cylinder2 = model.createSolidCylinder(radius=0.04,  height=1.3, location=(-0.2, -.2, 0)  )
cylinder3 = model.createSolidCylinder(radius=0.05,  height=1.3, location=(-0.2, 0.2, 0)  )
cylinder4 = model.createSolidCylinder(radius=0.06,  height=1.3, location=(0.2, -.2, 0)  )
cylinder5 = model.createSolidCylinder(radius=0.08,  height=1.3, location=(0, 0, 0)  )

# Subtract the cylinders from the box using booleanSubtract function to  create holes.
inspire.geometry.booleanSubtract(targets=[box],
                                 tools=[cylinder1,cylinder2,cylinder3,cylinder4,cylinder5,],
                                 keepTools=False)
#Removes the rounds from the part that are greater than 0.0 m and smaller than or equal to 0.060 m.
inspire.geometry.simplifyRounds(entity=box , roundType='ROUNDS', minSize=0.0, maxSize=0.055)

#Removes the rounds from the part that are greater than 0.05 m and smaller than or equal to 0.08 m.
inspire.geometry.simplifyRounds(entity=box , roundType='ROUNDS', minSize=0.05, maxSize=0.08)


featCylindrical = model.parts[0].getFeatures(type='FeatureCylindrical')[3]
# Removing the fillet feature
featCylindrical.simplifyRounds()
print("A Fillet has been removed from the part.")

# Removing all the fillet features from the part
model.parts[0].simplifyRounds()
print("All the fillets has been removed from the part.")
inspire.orientView(direction="isometric")

# Removing all fillet by passing Model.
model = inspire.newModel()
box2 = model.createSolidBlock()
feats2 = box2.getFeatures(type='FeatureLinear')[:4]
inspire.geometry.edgeFillet(feats2, radius='60mm')

model.simplifyRounds()
print("All the fillets has been removed from the model.")
inspire.orientView(direction="isometric")

simplifyHoles#

simplifyHoles(entity, minSize=0, maxSize=None)#

Finds and removes holes and pockets, and find raised areas such as lettering.

Parameters:
  • entity (Part | Assembly | Feature) – Part/Assembly from which you want to remove the holes from or FeatureCircular which needs to be removed.

  • minSize (float) – Minimum size of hole.

  • maxSize (float) – Maximum size of hole.

Example

# This script demonstrates the usage of simplifyHoles function.
from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
feats = box.getFeatures(type='FeatureLinear')[:4]

# Adding fillets with 20 mm radius to the part
inspire.geometry.edgeFillet(feature=feats, radius='60mm')
# Create holes on the box part.
# Create a solid cylinder with radius 0.1 and height 1.3 and location (0.2, 0.2, 0)
cylinder1 = model.createSolidCylinder(radius=0.08,  height=1.3, location=(0.2, 0.2, 0)  )
cylinder2 = model.createSolidCylinder(radius=0.04,  height=1.3, location=(-0.2, -0.2, 0)  )
cylinder3 = model.createSolidCylinder(radius=0.05,  height=1.3, location=(-0.2, 0.2, 0)  )
cylinder4 = model.createSolidCylinder(radius=0.06,  height=1.3, location=(0.2, -0.2, 0)  )
cylinder5 = model.createSolidCylinder(radius=0.1,  height=1.3, location=(0, 0, 0)  )

# Subtract the cylinders from the box using booleanSubtract function to create holes.
inspire.geometry.booleanSubtract(targets=[box],
                                 tools=[cylinder1,cylinder2,cylinder3,cylinder4,cylinder5,],
                                 keepTools=False)
#Removes the holes from the part that are greater than 0.0 m and smaller than or equal to 0.08 m.
#minSize and maxSize are the diameter size of the holes in meters.
inspire.geometry.simplifyHoles(entity=box , minSize=0.0, maxSize=0.08)
#Removes the holes from the part that are greater than 0.05 m and smaller than or equal to 0.12 m.
inspire.geometry.simplifyHoles(entity=box , minSize=0.05, maxSize=0.12)
#Removes the holes from the part that are greater than 0.00 m and smaller than or equal to 0.16 m.
# # To compensate for the tolerances, always pass the maxSize value by 1 mm larger than the hole size.
inspire.geometry.simplifyHoles(entity=box , minSize=0.0, maxSize=0.1601)
#Removes the holes from the part that are greater than 0.0 m and smaller than or equal to 2.0 m.
inspire.geometry.simplifyHoles(entity=box ,  minSize=0.0, maxSize=0.201)

simplifyPlugs#

simplifyPlugs(entity, minSize=0, maxSize=None)#

Finds holes and pockets, and plug them by filling the area with a new part

Parameters:
  • entity (Part | Assembly | Feature) – Part/Assembly from which you want to plug the holes or a Circular feature that needs to be plugged.

  • minSize (float) – Minimum size of plug.

  • maxSize (float) – Maximum size of plug.

Example

# This script demonstrates the usage of simplifyPlugs function.

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
# Create a solid cylinder with radius 0.1 and height 1.3 and location (0.2, 0.2, 0)
cylinder1 = model.createSolidCylinder(radius=0.08,  height=1, location=(0.2, 0.2, 0)  )
cylinder2 = model.createSolidCylinder(radius=0.04,  height=1, location=(-0.2, -0.2, 0)  )
cylinder3 = model.createSolidCylinder(radius=0.05,  height=1, location=(-0.2, 0.2, 0)  )
cylinder4 = model.createSolidCylinder(radius=0.06,  height=1, location=(0.2, -0.2, 0)  )
cylinder5 = model.createSolidCylinder(radius=0.1,  height=1, location=(0, 0, 0)  )
box = model.createSolidBlock(x=.1,y=0.15,z=.2, location=(0.4, 0.4, 0), name= 'Box 1',)

# Subtract the cylinders and box from the block using booleanSubtract function to create holes.
inspire.geometry.booleanSubtract(targets=[block],
                                 tools=[cylinder1,cylinder2,cylinder3,cylinder4,cylinder5,box],
                                 keepTools=False)
# Finds the plugs in the part and removes by creating new parts.
#Removes the holes from the part that are greater than 0.0 m and smaller than or equal to 0.201 m.
#minSize and maxSize are the diameter size of the holes in meters for cylindrical holes.

inspire.geometry.simplifyPlugs(entity=block , minSize=0.0, maxSize=0.201)
#Alternatively, you can use below method to remove the plugs.
# Remove all the plugs from entire model.
# inspire.geometry.simplifyPlugs(entity=model, minSize=0.0, maxSize=0.201)

partition#

partition(entity, thickness='1 mm', reverseDirection=False, minSize=0, maxSize=1)#

Divides a solid part into design and non-design regions by selecting a hole, pocket, or face to offset.

Parameters:
  • entity (Part | Assembly | [[Feature]]) – Part/Assembly from which you want to plug the holes or a feature to be partitioned. If it is a feature then it should be list of feature list, where the features in internal feature list are related to each other.

  • thickness (float) – The partition thickness consider in mm.

  • reverseDirection (bool) – Switch the direction of the offset for the partition.

  • minSize (float) – Minimum size of partition to find features.

  • maxSize (float) – Maximum size of partition to find features.

Returns:

New part created.

Return type:

Part

Example

# This script demonstrates the usage of partition function.

from hwx import inspire

model = inspire.openTutorialFile("Structures/bracket.x_t")
featCircular = model.parts[0].getFeatures(type='FeatureCylindrical')[2]
inspire.geometry.partition (entity=featCircular, thickness='3 mm',
                            reverseDirection=False, minSize=0, maxSize=1)
print("Partition part is created with thickness of 3 mm.")

# Updating Partition.
partitionCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# partitionCF = model.construction.getCF(name= 'Partition 1')

# Edit the partition CF:
with partitionCF.edit():
  # featurePartitionOption list[[Feature], float, bool]: Feature, thickness and reverseDirection.
  feature =  [model.parts[0].getFeatures(type='FeatureCylindrical')[1]]
  partitionCF.entity = [feature]
  partitionCF.featurePartitionOption = [feature, 0.009, True]
  # partitionOptions list[float, bool]: thickness and reverseDirection
print("Partition part is updated with thickness of 9 mm.")
inspire.orientView(direction="isometric")

midSurface#

midSurface(part, surfaceOptions='Mid')#

Extracts a midsurface or side faces from thin solids, and determine where surfaces are represented.

Replacing parts with midsurfaces yields better results while increasing speed when running an analysis or optimization.

Parameters:
  • part (Part) – The part which needs midsurface extraction.

  • surfaceOptions (str) – This options allows you to extract the Mid, Left or Right surface of the part.

Example

# This script demonstrates the usage of midSurface function.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
part = model.createSolidBlock(x=1,y=1,z=1)
inspire.geometry.midSurface (part=part, surfaceOptions='Mid')
# other surfaceOptions are 'Right' and 'Left'
inspire.orientView(direction="isometric")

# Updating midSurface.
midSurfaceCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# midSurfaceCF = model.construction.getCF(name= 'MidSurface 1')
with midSurfaceCF.edit():
    midSurfaceCF.surfaceOptions = 'Left'
    #Similarly, you can set the surfaceOptions to 'Right' or 'Mid'
print("Mid surface is updated with Left surface.")
inspire.orientView(direction="isometric")

chamferByAngle#

chamferByAngle(feature, angle=45, dist=0.003, swapChamferSides=False, tangentPropagation=False)#

Creates chamfer on a Linear/Planar feature.

Parameters:
  • feature (Feature) – Feature that needs to be chamfer.

  • angle (float) – Chamfer angle from the edge.

  • dist (float) – Chamfer distance from the edge.

  • swapChamferSides (bool) – If True, Swap chamfer sides of the edge otherwise not.

  • tangentPropagation (bool) – If True, Clicking an edge will also select all its tangent edges otherwise not.

Example

# This script demonstrates the usage of chamferByAngle function.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
featPlane1, featPlane2 = box.getFeatures(type='FeaturePlanar')[0:2]
# Chamfer by distance
model.variables.add(name='chamferdist', type='length', expression='10 mm')
model.variables.add(name='chamferAngle', type='angle', expression='45 deg')
# usage of model variable in chamfer function makes the chamfer operation parametric.
inspire.geometry.chamferByAngle (feature=featPlane2, angle=0.06,
                                    dist=0.06, swapChamferSides=False,
                                    tangentPropagation=False)

# get the last chamfer CF from the model.
chamferCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# chamferCF = model.construction.getCF(name= 'Chamfer 1')
# Edit the chamfer CF:
with chamferCF.edit():
    # usage of model variable in chamfer function makes the chamfer operation parametric.
    model.variables.update(name='chamferdist', expression='20 mm')
    chamferCF.angleAndDistance =['chamferAngle','chamferdist']
    chamferCF.swapChamferSides = True
    chamferCF.tangentPropagation =True
print(f"{chamferCF.name} CF is modified.")

print("New chamfer is created.")
inspire.orientView(direction="isometric")

chamferByDistance#

chamferByDistance(feature, dist1=0.003, dist2=0.003, swapChamferSides=False, tangentPropagation=False)#

Creates chamfer on a linear or planar feature.

Parameters:
  • feature (Feature) – Feature that needs to be chamfer.

  • dist1 (float | str) – Chamfer distance from the edge.

  • dist2 (float | str) – Chamfer distance from the edge.

  • swapChamferSides (bool) – If True, Swap chamfer sides of the edge otherwise not.

  • tangentPropagation (bool) – If True, Clicking an edge will also select all its tangent edges otherwise not.

Example

# This script demonstrates the usage of chamferByDistance function.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
featPlane1, featPlane2 = box.getFeatures(type='FeaturePlanar')[0:2]
# Chamfer by distance
model.variables.add(name='chamferdist', type='length', expression='10 mm')
# usage of model variable in chamfer function makes the chamfer operation parametric.
inspire.geometry.chamferByDistance (feature=featPlane2, dist1=0.06,
                                    dist2=0.06, swapChamferSides=False,
                                    tangentPropagation=False)

# get the last chamfer CF from the model.
chamferCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# chamferCF = model.construction.getCF(name= 'Chamfer 1')
# Edit the chamfer CF:
with chamferCF.edit():
    # usage of model variable in chamfer function makes the chamfer operation parametric.
    model.variables.update(name='chamferdist', expression='20 mm')
    chamferCF.distances =['chamferdist','chamferdist']
    chamferCF.swapChamferSides = True
    chamferCF.tangentPropagation =True
print(f"{chamferCF.name} CF is modified.")

print("New chamfer is created.")
inspire.orientView(direction="isometric")

shell#

shell(feature, thickness='1 mm')#

Removes material and create thin walls to generate a shelled part.

Parameters:
  • feature (FeatureArea) – Feature to create a shelled part from.

  • thickness (float | str) – Shell thickness.

Example

# This script demonstrates the usage of shell function.

# Removes a face from a Solid and create thin walls to generate a shelled part.
# A shell is a hollow version of a solid part with a uniform wall thickness.
# It’s created by removing one or more faces from a solid and offsetting the remaining
# surfaces inward/ outward to a specified thickness.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
block = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
# Create a solid cylinder with radius 0.1 and height 1.3 and location (0.2, 0.2, 0)
cylinder1 = model.createSolidCylinder(radius=0.6,  height=1, location=(0.8, 1.2, 0)  )

feature = block.getFeatures(type='FeatureArea')[0]
feature1 = cylinder1.getFeatures(type='FeaturePlanar')[0]

model.variables.add(name='shellThickness1',type='length', expression='10 mm')
model.variables.add(name='shellThickness2',type='length', expression='20 mm')
# Usage of variable in shell function makes the shell operation parametric.
inspire.geometry.shell(feature =[feature ], thickness='shellThickness1')
inspire.orientView(direction="isometric")

# Get the last shell CF from the model.
shellCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# shellCF = model.construction.getCF(name= 'Shell 1')

# Edit the shell CF:
with shellCF.edit():
    shellCF.feature = [feature, feature1 ]
    shellCF.thickness = '-20 mm' # negative value flips the direction of the shell
# shell on Spherical feature is not supported.
inspire.orientView(direction="isometric")

extrude#

extrude(features, direction, resultType, parts=None, extrudeAsSolid=True, reference=None, extrudeTo1=1, extrudeTo2=1, angle1=0, angle2=0, extrusionEndCaps=None, extrudeSurface=None, extrudeOffset=None, extrudeReverseOffset=False, mergeWithAllParts=True, mergeParts=None, reverseDirection=False, target=False, targetPart=None)#

Extrude sketch profile.

Parameters:
  • features (list[Feature]) – The features of the sketch to extrude.

  • direction (str) – Valid directions to extrude are: SINGLE, BOTH and SYMMETRY.

  • resultType (str) – Valid choices are: COMBINE, SUBTRACT, INTERSECT and NEW_PART.

  • parts (list[Part]) – Parts you would like to merge the extruded shape with. Defaults to None. That means the extruded shape will be merged with all parts that touch it.

  • extrudeAsSolid (bool) – If True extrude as Solid, otherwise extrude as Sheet.

  • reference (math.Vector | FeatureLinear | System) – Direction vector of extrusion. Defaults to the feature normal.

  • extrudeTo1 (float | FeaturePlanar | FeaturePoint | Part | str | bool) – If extrudeTo1 is a float then its the extrusion length in direction 1 in meters. If extrudeTo1 is a FeaturePoint or a FeaturePlanar then its used to determine the extrusion length in direction 1. It can be part also. If value is a string it can be a Model Variable or a value with units. If the value is True then it extents through all in gui.

  • extrudeTo2 (float | FeaturePlanar | FeaturePoint | Part | str | bool) – If value is a float then it’s the extrusion length in direction 2 in meters. If value is a FeaturePoint or a FeaturePlanar then it’s used to determine the extrusion length in direction 2. It can be part also. If value is a string it can be a Model Variable or a value with units. If the value is True then it extents through all in gui.

  • angle1 (float | str) – The draft angle in direction 1 in degree. If value is a string it can be a Model Variable or a value with units.

  • angle2 (float | str) – The draft angle in direction 2 in degree. If value is a string it can be a Model Variable or a value with units.

  • extrusionEndCaps (str) – Valid choices are: NONE, BOTH, START and END.

  • extrudeSurface (FeatureArea | Plane) – If True, extrude the surface. If this option is set then extrude from is considered as Surface/Plane.

  • extrudeOffset (float | str) – The offset distance for extrude. If this option is set then extrude from is considered as Offset. If value is a string it can be a Model Variable or a value with units.

  • extrudeReverseOffset (bool) – If True, reverse the offset direction.

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeParts.

  • reverseDirection (bool) – If True, reverse the extrusion direction.

  • target (bool) – If True, Set the target part used for boolean combine.

  • targetPart (Part) – The target part used for boolean combine.

Returns:

New part created.

Return type:

Part

Example

# This script demonstrates the usage of extrude function.

from hwx import inspire

# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.

model = inspire.getModel()

#box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
cyl = model.createSolidCylinder(radius=0.15,height=0.5 )

uptoFeature = cyl.getFeatures(type='FeaturePlanar')[0]

# Extrude As Solid
s = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
s.addRectangle2Vertex((0, 0), (2, 2))
sketch_part =s.realize()
model.variables.add(name='extrudeTo1', type='length', expression='10 mm')
# usage of model variable in extrude function makes the extrude operation parametric.
featArea = sketch_part.getFeatures(type=inspire.FeatureArea)
inspire.geometry.extrude (features=featArea, direction ="SINGLE", resultType='NEW_PART', parts=None,
                          extrudeAsSolid=True, reference=None, extrudeTo1='extrudeTo1',
                          extrudeTo2=1, angle1=0,angle2=0, extrusionEndCaps=None,
                          extrudeSurface=None, extrudeOffset=None,
                          extrudeReverseOffset=False, mergeWithAllParts=True, mergeParts=None,
                          reverseDirection=False),

# Example of Extrude As Solid with Upto feature and Subtract
# Creating Sketch object
s = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# Adding circle with center at (1, 1) and radius of 0.3
s.addCircleCenterRadius((1, 1), 0.3)
# realize the sketch
sketch_part =s.realize()

faces = sketch_part.getFeatures(type=inspire.FeatureArea)
inspire.geometry.extrude(features=faces,direction= "SINGLE", resultType="SUBTRACT", extrudeTo1=uptoFeature)


# Extrude As Sheet
# Creating Sketch object
s = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# Adding circle with center at (1, 1) and radius of 0.3
s.addRectangle2Vertex((0, 0), (2, 2))
# realize the sketch
sketch_part = s.realize()
inspire.geometry.extrude(features=sketch_part.getFeatures(type=inspire.FeatureArea),
                         direction="SYMMETRY", resultType="NEW_PART", extrudeTo1=-0.5, angle1=45, extrudeAsSolid=False,
                         reference=(0, 0, 1), extrusionEndCaps="BOTH")

inspire.orientView(direction="isometric")

offset#

offset(input, value, newPart=False)#

Offset surfaces or parts.

Parameters:
  • input (list[Part] | list[Feature]) –

  • value (float | str) – Desired offset distance. Negative value means inward direction. If value is a string it can be a Model Variable or a value with units.

  • newPart (bool) – If True, creates a new part.

Returns:

New part created if newPart was True.

Return type:

Part|None

Example

# Offset surfaces or parts, thicken surface parts
# and convert them to solids, or thicken and hollow solid parts.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box = model.createSolidBlock(x=0.1, y= 0.1, z= 0.02, name= 'Block 1')

featFace = box.getFeatures(type="FeaturePlanar")

inspire.geometry.offset(input=featFace, value=3.0, newPart=False)
inspire.geometry.offset(box, value=0.2,  newPart=False)

print("Offset has been applied to feature and part")
inspire.orientView(direction="isometric")

thicken#

thicken(parts, value, symmetric=True)#

Thicken surface parts and convert them to solids, or thicken and hollow solid parts.

When used on a solid part, the Thicken tool yields a hollow solid. When used on a surface part, the Thicken tool yields a solid part.

Parameters:
  • parts (list[Part]) – Parts to be thickened.

  • value (float) – Desired offset distance. Negative value means inward direction.

  • symmetric (bool) – If True, offsets symmetrically on both sides of the part surface.

Example

# Thicken surface parts and convert them to solids, or thicken and hollow solid parts.
# When used on a solid part, the Thicken tool yields a hollow solid

from hwx import inspire

# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()

# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock(x=0.1, y= 0.1, z= 0.02, name= 'Block 1')
model.variables.add(name='thickenValue', type='length', expression='10 mm')
inspire.geometry.thicken(parts=box, value='thickenValue', symmetric=True)

print("Thicken has been applied to a part")
inspire.orientView(direction="isometric")

# Get the last thicken CF from the model.
thickenCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# thickenCF = model.construction.getCF(name= 'Offset 1')

# Edit the thicken CF:
with thickenCF.edit():
  thickenCF.value = '0.2 m'

inspire.orientView(direction="isometric")

linearPattern#

linearPattern(input, direction1, direction2=(0, 0, 0), bothDirection=False, spacing1=0.0, count1=3, spacing2=0.0, count2=3, instances=False, symmetry1=False, symmetry2=False, reverseDir1=False, reverseDir2=False, result='NEW_PART', mergeWithAllParts=True, mergeParts=None, copiesToSkip=None, seedOnly=False)#

Linear Pattern parts or faces along a direction.

Parameters:
  • input (list[Part] | list[FeatureArea]) – Parts or Features to create linear pattern.

  • direction1 (math.Vector | FeatureCurve | Axis) – Direction can be a reference line, edge, or axis to which the pattern will be parallel.

  • direction2 (math.Vector | FeatureCurve | Axis) – Direction can be a reference line, edge, or axis to which the pattern will be parallel.

  • bothDirection (bool) – If True, sets in both direction otherwise single direction.

  • spacing1 (float) – Distance between two copies.

  • count1 (int) – Number of copies.

  • spacing2 (float) – Distance between two copies.

  • count2 (int) – Number of copies.

  • instances (bool) – If True, any changes to part or face will apply to all instances.

  • symmetry1 (bool) – Symmetry in Direction 1.

  • symmetry2 (bool) – Symmetry in Direction 2.

  • reverseDir1 (bool) – Reverse the pattern direction in Direction 1.

  • reverseDir2 (bool) – Reverse the pattern direction in Direction 2.

  • result (str) – Result type of linear pattern. - COMBINE - SUBTRACT - INTERSECT - NEW_PART

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeParts.

  • mergeParts (list[Part]) – Parts to be merged with linear pattern.

  • (dict{Part (copiesToSkip) – list[tuple(x,y)]}): Set copies to skip. Here x and y are the indices in 2D space of copy , which needs to be skipped.

  • seedOnly (bool) – If True, pattern the entities only along the first row and first column.

Returns: list[Part]: List of parts created.

Example

# This script demonstrates the usage of linearPattern function.

# Pattern parts or faces in a linear direction.

from hwx import inspire

# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock(x=1, y= 1, z= 1, name= 'Block 1')

# Creating a linear pattern of box.
box.linearPattern(direction1=box.getFeatures(type="FeatureCurve")[0],
                 spacing1=2, count1=5, symmetry1=True)

print("Linear pattern has been created for Box")
inspire.orientView(direction="isometric")

createPipe#

createPipe(path, section='CIRCLE', size=0.01, width=0.01, thickness=0.0, angle=None, ignoredFeatures=None, propagate=False, resultType='COMBINE')#

Create Pipe for FeatureCurve.

Parameters:
  • path (list[FeatureCurve]) –

  • section (str) – The Pipe profile type. Valid choices are: CIRCLE, SQUARE, TRIANGLE and RECTANGLE.

  • size (float | str) – Length of the pipe. If value is a string it can be a Model Variable or a value with units.

  • width (float) – Width of the pipe, only applicable for Rectangular profile.

  • thickness (float | str) – Pipe thickness. If not set or set to zero, it will be solid pipe. If value is a string it can be a Model Variable or a value with units.

  • angle (float) – Angle in radians. Only for xy alignment.

  • ignoredFeatures – Ignored Features. Not mandatory. In propagated cases, if we need to ignore certain curves.

  • propagate (bool) – if True enables propagate option, otherwise disabled.

  • resultType (str) – Valid values are: COMBINE, SUBTRACT, INTERSECT and NEW_PART.

Returns:

New part created.

Return type:

Part

Example

# This script demonstrates the usage of createPipe function.

# Create a pipe along one or more edges/lines. The pipe has a uniform cross section that can be circular,
# square, rectangular, or triangular.

from hwx import inspire

# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a sketch of line segment.
s = inspire.core.Sketch(system="Global Z", feature=None, origin=None, normal=None)
point1 = s.addPoint(0, 0)
start = s.addPoint(0, 5)
s.addLineSegment(point1, start)
sketch_part = s.realize()
features = sketch_part.getFeatures(type=inspire.FeatureLinear)
# Creating a circular pipe / hollow cylinder.
#Size is the diameter of the pipe. and thickness is the thickness of the pipe.
# Hollow cylinder  with inner dia 3 m and outer dia 5 m.
# To make a solid cylinder, set the thickness to 0.0.
inspire.geometry.createPipe(path=features, section='CIRCLE', size=5, width=0.01, thickness=1,
                            angle=None, ignoredFeatures=None, propagate=False, resultType='NEW_PART')

# with SQUARE section size is the side length of the square and thickness is the thickness of the pipe.
#inspire.geometry.createPipe(path=features, section='SQUARE', size=5, width=0.01, thickness=0.1,
#                            angle=None, ignoredFeatures=None, propagate=False, resultType='NEW_PART')

# with RECTANGLE section length is size and height is width of the rectangle.
#inspire.geometry.createPipe(path=features, section='RECTANGLE', size=5, width=1, thickness=1,
#                            angle=None, ignoredFeatures=None, propagate=False, resultType='NEW_PART')

# with RECTANGLE section length is size of the triangular section.
#inspire.geometry.createPipe(path=features, section='TRIANGLE', size=5, width=1, thickness=1,
#                           angle=None, ignoredFeatures=None, propagate=False, resultType='NEW_PART')

# Get the last pipeCF CF from the model.
pipeCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# pipeCF = model.construction.getCF(name= 'Pipe 1')
# Edit the pipe CF:
with pipeCF.edit():
    # by making thickness 0.0, we can make a solid cylinder.
    pipeCF.thickness = 0.0
    pipeCF.section = 'CIRCLE'
    # similarly, other parameters can be modified.

inspire.orientView(direction="isometric")

moveFaces#

moveFaces(features, position, duplicate=False)#

Translate, rotate, copy, or extend features.

Parameters:
  • features (list[FeatureArea]) – The features to move.

  • position (math.Matrix44) – The position to move the features at.

  • duplicate (bool) – If True, copy the features at given position.

Example

# This script demonstrates the usage of moveFaces function.

# Translate, rotate, copy, or extend features.

#The Move Faces tool works the same way as the Move tool, but can be used only for holes, pockets,
# and surface features. It does not work on edges.

from hwx import inspire

# Creating a solid block with a hole in it.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
cyl = model.createSolidCylinder(radius=0.15,height=1 )
part = box.booleanSubtract(cyl)

feature = model.getFeatures(type="FeatureCylindrical")[0]
location1 = inspire.math.Matrix44(origin=[0.31, 0.30, 1])

# Moving hole to other location.
location1 = inspire.math.Matrix44(origin=[-0.31,-0.31,1])
inspire.geometry.moveFaces(features=feature, position=location1, duplicate=False)

print("Hole is moved from origin to location1 in solid box")
inspire.orientView(direction="isometric")

# Get the last featureMoveCF CF from the model.
featureMoveCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# featureMoveCF = model.construction.getCF(name= 'Feature Move 1')

# Edit the featureMoveCF CF:
with featureMoveCF.edit():
    location2 = inspire.math.Matrix44(origin=[0.31,0.31,1])
    featureMoveCF.position = location2
    # Similarly, other parameters can be modified.

    print(f"{featureMoveCF.name} CF is modified.")

inspire.orientView(direction="isometric")

intersect#

intersect(parts, createSolids=False, keepSourceParts=False)#

Intersect tool that deletes excess faces, edges and vertices.

Parameters:
  • parts (list[Part]) – Parts to intersect.

  • createSolids (bool) – If True, faces of solid volumes automatically selected.

  • keepSourceParts (bool) – Determines whether to keep source parts or not. When original parts are not kept, they are deleted from the model at the end of a successful operation.

Returns:

New part if created otherwise none.

Return type:

Part/None

Example

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Creating a model to show intersect tool.
part1 = model.createSheetPolygon(radius=3)
part2 = model.createSheetRectangle(x=4, y=2)
part3 = model.createSolidCylinder()

# Intersecting all part from model
inspire.geometry.intersect([part1, part2, part3], createSolids=True)

print("All parts in a model are intersected and a new part is created")
inspire.orientView(direction="isometric")

convertToMass#

convertToMass(parts, parent=None)#

Replace Parts to concentrated mass.

Parameters:
  • parts (list[Part]) – Parts to be replaced with concentrated mass.

  • parent (Part) – Parent for the mass created.

Example

# This script demonstrates the usage of convertToMass function.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box = model.createSolidBlock(x=1, y= 1, z= 1, name= 'Block 1')
# Creating a solid cylinder of radius 0.05 and height 0.1.
cyl = model.createSolidCylinder(radius=0.05, height=0.1)
# Creating a solid sphere of radius 0.05.
sph = model.createSolidSphere(radius=0.05)

# Replace multiple parts with ConcentratedMass
cm1 = inspire.geometry.convertToMass(parts =[box,cyl, sph],parent=model)

print("Parts have been replaced with concentrated mass : ",  cm1)
inspire.orientView(direction="isometric")

# Convert to Mass CF does not support CF edit.

replaceFromFile#

replaceFromFile(part, filePath, orient=False)#

Replace part with the contents of a file.

Parameters:
  • part (Part) – The part to be replaced.

  • filePath (str) – The path to the file whose contents will replace the part.

Example

# This script demonstrates the usage of replaceFromFile function.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock(x=1,y=1,z=1)
filePath = str(inspire.demo.getDemoFilePath('M01_FourBar.x_b'))
# replace the part with the file.
part = inspire.geometry.replaceFromFile(part=box, filePath=filePath,orient=False)

print("Box is replaced with the file: M01_FourBar.x_b")
inspire.orientView(direction="isometric")

# Replace CF does not support CF edit.

replaceFromPart#

replaceFromPart(part, toolPart, keepToolPart=False)#

Replace part with tool part.

Parameters:
  • part (Part) – The part to be replaced.

  • toolPart (Part) – The part to replace with.

  • keepToolPart (bool) – Determines whether to keep the toolPart or not after replace.

Example

# This script demonstrates the usage of replaceFromPart function.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
box = model.createSolidBlock(x=2, y=2, z=0.5)
cyl = model.createSolidCylinder()
inspire.geometry.replaceFromPart(part=box, toolPart=cyl, keepToolPart=False )

print("Box is replaced with Cylinder")
inspire.orientView(direction="isometric")

# Replace CF does not support CF edit.

circularPattern#

circularPattern(input, axis, angle=60, count=3, equalSpacing=False, instances=False, symmetry=False, axisReverse=False, result='NEW_PART', mergeWithAllParts=True, mergeParts=None, copiesToSkip=None)#

Circular Pattern parts or faces around an axis.

Parameters:
  • input (list[Part] | list[FeatureArea]) – Parts or Features to create circular pattern.

  • axis (math.Vector | FeatureCurve | Axis) – Axis is a reference line, edge, or axis to which the pattern will be parallel.

  • angle (float) – Angle within which the copies are equally spaced.

  • count (int) – Number of copies.

  • equalSpacing (bool) – If True, equally space the copies within a specified Angle.

  • instances (bool) – If True, any changes to part or face will apply to all instances.

  • symmetry (bool) – Symmetry in Direction 1.

  • axisReverse (bool) – Reverse the axis in Direction 1.

  • result (str) – Result type of circular pattern. - COMBINE - SUBTRACT - INTERSECT - NEW_PART

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeParts.

  • mergeParts (list[Part]) – Parts to be merged with circular pattern.

  • (dict{Part (copiesToSkip) – list[indicesToSkip]}): Set copies to skip. It’s basically a dictionary which contains Part as a key and list of indices to skip as values.

Returns: list[Part]: List of parts created.

Example

# This script demonstrates the usage of circularPattern function.

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

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid sphere
sphere = model.createSolidSphere(radius=0.1)

position = Matrix44(origin=[1, 1, 0])
sphere.move2(moveMode="Free", position=position)
#feature = model.getFeatures(type="FeatureLinear")[0]
X = model.getAllChildren(type="Axis")[0]
Y = model.getAllChildren(type="Axis")[1]
Z = model.getAllChildren(type="Axis")[2]

# Creating a circular pattern of box.
inspire.geometry.circularPattern(input=sphere, axis=X, angle=45, count=8,  symmetry=True,
                                 equalSpacing=False, instances=False,axisReverse=False,
                                 result='NEW_PART',mergeWithAllParts=True, mergeParts=None,
                                 copiesToSkip=None)

print("Circular pattern has been created for Box")
inspire.orientView(direction="isometric")

# Get the last circularPattern CF from the model.
circularPatternCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# circularPatternCF = model.construction.getCF(name= 'Circular Pattern 1')
# Edit the circularPattern CF:
with circularPatternCF.edit():
    circularPatternCF.symmetry = False
    # Similarly, other parameters can be modified.

inspire.orientView(direction="isometric")

draft#

draft(features=None, direction='SINGLE', neutralPlane=None, angle1=3.0, angle2=3.0, flipDrawDirection1=False, flipDrawDirection2=False, draftType='NEUTRAL_PLANE', pullDirection=None, partingLines=None, otherFace=False)#
Add draft to one or more faces of a part when designing a product that is

manufactured using injection molding.

Parameters:
  • features (list[FeatureArea]) – Faces to Draft.

  • direction (str) – The Draft direction. Valid values are: SINGLE, BOTH and SYMMETRIC.

  • neutralPlane (FeaturePlanar, Plane) – A reference plane or an existing face in the model. neutralPlane can not be same as draft feature.

  • angle1 (float) – The angle1 of draft.

  • angle2 (float) – The angle2 of draft. This is applicable for BOTH or SYMMETRY value for direction.

  • flipDrawDirection1 (bool) – If True, flips the draw direction of draft in single direction.

  • flipDrawDirection2 (bool) – If True, flips the draw direction of draft. Applicable for BOTH direction.

  • draftType (str) – The Draft type. Valid values are: NEUTRAL_PLANE, PARTING_LINE.

  • pullDirection (FeatureLinear | FeaturePlanar) – The draft will occur in this direction.

  • partingLines (FeatureLinear) – Lines where the draft would start.

  • otherFace (bool) – If True, draft the other face along the parting line otherwise not.

Example

# This script demonstrates the usage of draft function.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
model.createSolidBlock(x=0.01, y=0.01, z=0.05)
feature = model.getFeatures(type="FeaturePlanar")[1]
neutralPlane = model.getFeatures(type="FeaturePlanar")[0]

inspire.geometry.draft(features=feature, direction='SINGLE', neutralPlane=neutralPlane,
                       angle1=45, angle2=3.0, flipDrawDirection1=False,
                       flipDrawDirection2=False, draftType='NEUTRAL_PLANE',
                       pullDirection=None, partingLines=None, otherFace=False)

print("Draft has been created in single direction with 20 degree angle")

# Draft edit.
draftCF = model.construction[-1]

# Creating named tuple to pass the in options.
import typing

class DraftOpt(typing.NamedTuple):
  neutralPlane: inspire.Feature = model.getFeatures(type="FeaturePlanar")[0]
  direction: str                = 'SINGLE'
  flipDirection1: bool          = True
  flipDirection2: bool          = False
  otherFace: bool               = False
  draftType: str                = 'NEUTRAL_PLANE'

draftCF.edit(options=DraftOpt())
inspire.orientView(direction="isometric")

convertBodiesToParts#

convertBodiesToParts(parts)#

Convert disconnected bodies to parts.

Parameters:

parts (list[Part]) – The parts to be converted.

Returns:

Newly created parts.

Return type:

list[Part]

Example

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

model.createSolidBlock(x=1,y=1,z=1)
features = model.getFeatures(type="FeaturePlanar")
m1 = inspire.math.Matrix44(origin=[3, 0, 0])
inspire.geometry.moveFaces(features, m1, duplicate=True)
parts = inspire.geometry.convertBodiesToParts(model.parts[0])

print(" Converted Parts: ", parts)
inspire.orientView(direction="isometric")

# convertBodiesToParts does not support CF edit.

breakInstance#

breakInstance(parts)#

Break the instances of a part.

Parameters:

parts (list[Part]) – Parts for breaking instances.

Example

# This script demonstrates the usage of breakInstance function.

from hwx import inspire
from hwx.inspire.demo import openDemoFile
# Open a demo file
model = openDemoFile("BreakInstance.stmod")
# Break Instance is used to break the instance of the part into two parts.
inspire.geometry.breakInstance(parts =[model.parts[0], model.parts[1]])
#Alternatively, you can use below method to break all the instance from the model.
# inspire.geometry.breakInstance(parts=model.parts)
print("Break Instance has been applied to both parts.")
inspire.orientView(direction="isometric")

# breakInstance does not support CF edit.

trimAndSplit#

trimAndSplit(targets, tools, direction, trim=True, keepType='EXTERIOR', vectorDirection=None, extendProjection=True, trimExtents='THROUGH_ALL', extractProjection=False, surfaceNormal=None, resultAsSurface=False)#

Formerly known as projectAndSplit. It removes part of a surface or solid by projecting a profile curve on to it. OR use a set of tool surfaces to split a set of target surfaces.

Parameters:
  • targets (list[Part] | list[Feature]) – List of Parts or features on which feature projection to be.

  • tools (list[Feature]) – Feature that needs to be projected on Part.

  • direction (str) – Valid values are: TOOL_NORMAL, X, Y, Z, VECTOR and CLOSEST_POINT, SURFACE_NORMAL.

  • trim (bool) – If True, operation type is trim otherwise split.

  • keepType (str) – Output to keep. Only valid for split. - EXTERIOR - INTERIOR - BOTH

  • vectorDirection (FeatureLinear | System) – Vector direction, only applicable when direction is ‘VECTOR’.

  • extendProjection (bool) – If True, extends the projection.

  • trimExtents (str) – Trim extents, Only valid for Trim operation. - THROUGH_ALL - DIRECTION_1 - DIRECTION_2

  • extractProjection (bool) – If True, extract projection without split. Valid only for split operation

  • surfaceNormal (FeaturePlanar) – Planar surface along whose normal you want to project the tools.

  • resultAsSurface (bool) – If True, Force output result being a sheet by removing faces on the solid target obtained by cut. Valid only for trim operation.

Returns: list[Part]: List of parts created.

Example

# This script demonstrates the usage of trimAndSplit function.

from hwx import inspire
# Clears the existing Model and creates a new modeling session.
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

part = model.createSolidBlock(x=2, y=1, z=1, location=(0, 0, 0))
box = model.createSolidBlock(location=(-1, 0.5, 0))
feature = box.features[21]
part.slice(surfaceFeature=feature, extendSurface=False)
part.slice(surfaceFeature=feature, extendSurface=True)
tool = model.getFeatures(type="FeatureLinear")[31]
target = model.parts[1]

inspire.geometry.trimAndSplit(target, tool, "Y", trim=False)
print("A linear feature has been projected on part and also divided it "
     "into two parts")
inspire.orientView(direction="isometric")

revolve2#

revolve2(profiles, axis, direction='SINGLE', resultType='NEW_PART', mergeTargets=None, flipAxis=False, angle1=0, angle2=0, snapToPoint1=None, snapToPoint2=None, mergeWithAllParts=True, target=False, targetPart=None)#

New Revolve - Revolve a face, sketch, line, or 2D edge about an axis.

Parameters:
  • profiles (FeatureArea | FeatureCurve) – A face, line, or 2D edge.

  • axis (FeatureLinear | FeatureCircular | Axis) – An edge, line, cylindrical

  • Axis. (hole or an) – Selecting an edge on another part projects the axis of revolution to the planar face that will be rotated.

  • direction (str) – Valid values are: SINGLE, BOTH and SYMMETRY.

  • resultType (str) – Valid values are: COMBINE, SUBTRACT, INTERSECT and NEW_PART.

  • mergeTargets (list[Feature]) – Explict merge targets for Result Type.

  • flipAxis (bool) – If True, axis will be flipped.

  • angle1 (float) – The angle of revolution.

  • angle2 (float) – The angle of revolution when direction is Both.

  • snapToPoint1 (FeaturePoint) – Point to snap to when direction is SINGLE or SYMMETRY.

  • snapToPoint2 (FeaturePoint) – Point to snap to when direction is BOTH.

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeTargets.

  • target (bool) – If True, Set the target part used for boolean combine.

  • targetPart (Part) – The target part used for boolean combine.

Returns:

New part created if resultType is NEW_PART.

Return type:

Part|None

Example

#Revolve one or more faces, sketches, lines, or 2D edges about an axis.

# this function is useful for creating
# -Cones  - Revolve a right-angled triangle or slanted line.
# -hollow Cylinders  - Revolve a  rectangle.
# -Spheres - Revolve a simi circle.
# -Torus (Donut Shape) - Revolve a circle offset from the axis.
# -Bottle-like Shapes - Revolve complex spline profiles.

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
rectangle = model.createSheetRectangle()
feat = rectangle.getFeatures(inspire.FeaturePlanar)[0]
feat2 = rectangle.getFeatures(inspire.FeatureLinear)[2]

# Get the global Axis from the model.
X = model.getAllChildren(type="Axis")[0]
Y = model.getAllChildren(type="Axis")[1]
Z = model.getAllChildren(type="Axis")[2]

inspire.geometry.revolve2(profiles=feat, axis=feat2, direction='SINGLE',
                        resultType='NEW_PART', mergeTargets=None, flipAxis=False,
                        angle1=200, angle2=0, snapToPoint1=None,
                        snapToPoint2=None, mergeWithAllParts=True)

print("Rectangular sheet has been revolved on linear axis for 200 degree")
inspire.fitView()

# Example 2
#Creating a Sphere using semi-circle and revolve.

from hwx import inspire
model = inspire.newModel()
# Creating a Sketch object
s = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# Adding a semi-circle with center at (0, 0.05) and radius of 0.1
ls1 = s.addLineSegment((0,0),(0,0.1), type="END_POINT_LINE")
# create arc using center and two endpoints, counter-clockwise or clockwise
a1 = s.addArcCenter2Points((0, .05), (0, 0), (0, .1), ccw=True)

# Use of model variable to make the sketch parametric.
d1 = s.addDimension(s.DIMENSION_DISTANCE_ALIGNED, 0.1, item1=ls1)
model.variables.add(name="dia", type="length", expression='0.01')
s.setDimensionVariable(d1,'dia')
# realize the sketch
sketch_part = s.realize()
# Get the semi- circle area
area = sketch_part.getFeatures(type=inspire.FeatureArea)[0]
inspire.geometry.revolve2(profiles=area, axis=Y, direction='SINGLE',
                        resultType='NEW_PART', mergeTargets=None, flipAxis=False,
                        angle1=360, angle2=0, snapToPoint1=None,
                        snapToPoint2=None, mergeWithAllParts=True)

inspire.orientView(direction="top")

edgeFillet#

edgeFillet(feature, radius='3 mm', continuity='TANGENT', tangentPropagation=True)#

Creates fillet on a Linear feature.

Parameters:
  • feature (Feature) – feature that needs to fillet.

  • radius (float | str) – Radius of the fillet.

  • continuity (str) – Valid values are: TANGENT and CURVATURE.

  • tangentPropagation (bool) – If True, selecting an edge will also select all of its tangent edges.

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
box = model.createSolidBlock(x=1,y=1,z=1)
edge = box.getFeatures(type='FeatureLinear')[0]
inspire.geometry.edgeFillet(feature=edge, radius='60mm', continuity='TANGENT', tangentPropagation=True)
print('Fillet is created on a edge with radius "60mm"')
inspire.orientView(direction="isometric")

sweep#

sweep(profiles, path, solidProfile=None, sweepAsSolid=True, profileOrientation=True, propagate=True, pathIgnoredFeatures=None, guideCurves=None, pathDirection='DIRECTION_1', twistType='NO_TWIST', twistAngle=0, twistTurns=0, twistAngleDir2=0, twistTurnsDir2=0, resultType='NEW_PART', mergeWithAllParts=True, mergeParts=None, twist1Reverse=False, twist2Reverse=False, guideScale='UNIFORM', toolSweepMode=False, enableLockDirection=False, lockDirection=None, target=False, targetPart=None)#

Sweep a profile along a path to create a solid or 3D surface.

Parameters:
  • profiles (FeatureArea | FeatureCurve) – A face or a closed sketch. For Tool sweep mode pass profiles as None.

  • path (list[FeatureCurve]) – Path for the sweep.

  • solidProfile (Part) – Sweep profile as solid. Only applicable for solid cylinder.

  • sweepAsSolid (bool) – If true, sweep as solids otherwise sweep as surfaces.

  • profileOrientation (bool) – If true, sweep orientation will be normal to the path otherwise parallel.

  • propagate (bool) – If true, all the tangent edges of the input path is also selected.

  • pathIgnoredFeatures (list[FeatureCurve]) – Edge to be ignored when propagate is True.

  • guideCurves (list[FeatureCurve]) – Guide curves for the sweep. No guide curves are set by default.

  • pathDirection (str) – Sweep direction. - DIRECTION_1 - DIRECTION_2 - BOTH

  • twistType (str) – Twist type. - NO_TWIST - ANGLE_TWIST - NO_OF_TURNS

  • twistAngle (float) – Twist angle in DIRECTION_1.

  • twistTurns (float) – Number of twist turns in DIRECTION_1.

  • twistAngleDir2 (float) – Twist angle in DIRECTION_2. Applicable only when pathDirection is “BOTH”.

  • twistTurnsDir2 (float) – Number of twist turns in DIRECTION_2. Applicable only when pathDirection is “BOTH”.

  • resultType (str) – Result type of sweep operation. - COMBINE - SUBTRACT - INTERSECT - NEW_PART

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeTargets.

  • mergeParts (Part) – Parts to be merged with sweep operation.

  • twist1Reverse (bool) – If True, Reverse the twist in DIRECTION_1 or DIRECTION_2.

  • twist2Reverse (bool) – If True, Reverse the twist in DIRECTION_2. Applicable only when pathDirection is “BOTH”.

  • guideScale (str) – Guide scale option. Applicable only when guideCurves is provided. - UNIFORM - LATERAL

  • toolSweepMode (bool) – If True, enable tool sweep mode.

  • enableLockDirection (bool) – If True, enable lock direction. Only applicable when toolSweepMode is True.

  • lockDirection (FeatureLinear) – Lock direction for sweep. Only applicable when toolSweepMode and enableLockDirection is True.

  • target (bool) – If True, Set the target part used for boolean combine.

  • targetPart (Part) – The target part used for boolean combine.

Returns:

New part created if resultType is NEW_PART.

Return type:

Part|None

Example

# This script demonstrates the usage of sweep function.

# Sweep a profile along a path to create a solid or surface.
# This tool is useful to create complex paths with constant cross-sections.
# The sweep function can be used to create a solid or surface by sweeping a profile along a path.

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Create a Sketch object on Global Z plane
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
#add a polygon with 4 side to the sketch
sketch1.addRegularPolygon((0, 0), (1, 0), 4)
# realize the sketch
sketch_part1 = sketch1.realize()
# Create a Sketch object on Global Y plane
sketch2 = inspire.Sketch("Global Y")
# add a line segment to the sketch
sketch2.addLineSegment((0, -10), (0, 10))
# realize the sketch
sketch_part2 = sketch2.realize()
# Get the path and profile from the sketches
path = sketch_part2.getFeatures(inspire.core.FeatureCurve)
profile = sketch_part1.getFeatures(inspire.core.FeatureArea)

#Sweep the profile along the path to create a solid or surface.
inspire.geometry.sweep(profiles=profile, path=path, solidProfile=None, sweepAsSolid=True,
                       profileOrientation=True, propagate=True,pathIgnoredFeatures=None,
                       guideCurves=None, pathDirection='BOTH',twistType='NO_OF_TURNS',
                       twistAngle=0, twistTurns=1, twistAngleDir2=0,twistTurnsDir2=0,
                       resultType='NEW_PART', mergeWithAllParts=True,mergeParts=None,
                       twist1Reverse=False, twist2Reverse=False, guideScale='UNIFORM',
                       toolSweepMode=False, enableLockDirection=False, lockDirection=None)

print("Sweep has been created in both direction of profile.")
inspire.orientView(direction="isometric")

# Get the last sweep CF from the model.
sweepCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# sweepCF = model.construction.getCF(name= 'Sweep 1')
# Edit the sweep CF:
with sweepCF.edit():
    sweepCF.twistTurnsDir2 =2
    sweepCF.twistTurns = 2
    #similarly, other parameters can be modified.
inspire.orientView(direction="isometric")

nurbsCurve#

nurbsCurve(controlPoints, nurbsCurveType='CURVE_OPEN', nurbsCurveDegree='DEGREE_3', controlPointWeight=None)#

Create a NURBS curve, which is a free-form curve.

Parameters:
  • controlPoints (list[FeaturePoints | math.Point]) – List of control points to draw NURBS curve.

  • nurbsCurveType (str) – NURBS curve type. - CURVE_OPEN - CURVE_CLOSED - CURVE_PERIODIC - CURVE_NUM_TYPES

  • nurbsCurveDegree (str) – NURBS curve degree. - DEGREE_2 - DEGREE_3 - DEGREE_4 - DEGREE_5 - DEGREE_6 - DEGREE_7

  • controlPointWeight (list(int, float)) – Index and weight for control point in NURBS curve.

Returns:

New NURBS created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
model.createSolidBlock(x=1,y=1,z=1)
point1 = model.getFeatures(type="FeaturePoint")[0]
point2 = model.getFeatures(type="FeaturePoint")[1]
point3 = model.getFeatures(type="FeaturePoint")[3]
inspire.geometry.nurbsCurve([point1, point2, point3])

print("NURBS Curve has been created with given control points.")
inspire.orientView(direction="isometric")

patternAlongPath#

patternAlongPath(input, path, count=3, equalSpacing=False, spacing=0.01, instances=False, method='TRANSFORM', orientation='MAINTAIN_SEED_ORIENTATION', pathReverse=False, result='NEW_PART', mergeWithAllParts=True, mergeParts=None, copiesToSkip=None)#

Pattern parts or faces along curve.

Args:
input (list[Part] | list[FeatureArea]): Parts or Features to create pattern

along the curve.

path (list[FeatureCurve]): Path for pattern. count (int): Number of copies. equalSpacing (bool): If True, equally space the copies. spacing (float): Distance between two copies. instances (bool): If True, any changes to part or face will apply to all instances. method (str): Pattern method.

  • TRANSFORM

  • OFFSET

orientation (str): Pattern Orientation.
  • TANGENT_TO_CURVE

  • MAINTAIN_SEED_ORIENTATION

pathReverse (bool): Reverse the path of pattern. result (str): Result type of pattern along path.

  • COMBINE

  • SUBTRACT

  • INTERSECT

  • NEW_PART

mergeWithAllParts (bool): If True, merge with All parts otherwise merge with

parts supplied in mergeParts.

mergeParts (list[Part]): Parts to be merged with pattern along path. copiesToSkip (dict{Part: list[indicesToSkip]}): Set copies to skip. It’s

basically a dictionary which contains Part as a key and list of indices to skip as values.

Returns: list[Part | Feature]: List of parts/features created.

Example

from hwx import inspire

model = inspire.newModel()
box = model.createSolidBlock(x=1,y=1,z=1)
path = box.getFeatures(type=inspire.FeatureCurve)[0]

# Creating a box pattern along the path.
inspire.geometry.patternAlongPath (input=box, path=path, count=3, equalSpacing=False,
                                    spacing=1.5, instances=False, method='TRANSFORM',
                                    orientation='MAINTAIN_SEED_ORIENTATION', pathReverse=False,
                                    result='NEW_PART', mergeWithAllParts=True,
                                    mergeParts=None, copiesToSkip=None)

print("Pattern along the path has been created for Box")
inspire.orientView(direction="isometric")

multiSweep#

multiSweep(profiles, path, sweepAsSolid=True, arcLengthProfiles=False, arcLengthGuides=False, orientation='PERPENDICULAR', normalToSurface=None, resultType='NEW_PART', mergeWithAllParts=True, mergeParts=None, profileContinuity=None, profileMagnitude=None, target=False, targetPart=None)#

Sweep multiple profiles along a path to create a solid or surface.

Parameters:
  • profiles (list[FeatureArea | FeatureCurve]) – Faces or closed sketches.

  • path (list[FeatureCurve]) – Path for the multiSweep.

  • sweepAsSolid (bool) – If true, sweep as solids otherwise sweep as surfaces.

  • arcLengthProfiles (bool) – If True, Set Arc Length Parametrization on profiles.

  • arcLengthGuides (bool) – If True, Set Arc Length Parametrization on path.

  • orientation (str) – Orientation for multiSweep. - PERPENDICULAR - PARALLEL - NORMAL_TO_SURFACE

  • normalToSurface (list[FeatureArea]) – Face to which sweep orientation will be normal.

  • resultType (str) – Result type of multiSweep operation. - COMBINE - SUBTRACT - INTERSECT - NEW_PART

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeTargets.

  • mergeParts (Part) – Parts to be merged with sweep operation.

  • profileContinuity (tuple(Feature, str)) –

    Tuple of 2 values. First value will be the feature on which continuity will be applied and the second value is continuity type mentioned below.

    • NONE

    • SURFACE

    • MAGNITUDE

  • profileMagnitude (tuple(Feature, float | str)) – Tuple of 2 values. First value will be the feature on which continuity will be applied and the second value is magnitude.

  • target (bool) – If True, Set the target part used for boolean combine.

  • targetPart (Part) – The target part used for boolean combine.

Returns:

New part created if resultType is NEW_PART.

Return type:

Part|None

Example

# This script demonstrates the usage of multiSweep function.
# Sweep multiple profiles along a path to create a solid or surface
# This tool is useful to create complex paths with variable cross-sections.

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Create a solid block of length 1, width 1 and height 2.
part = model.createSolidBlock(x=1,y=1, z=2)

feature = model.getFeatures(type=inspire.FeaturePlanar)[0]
# Create a plane with offset of 0.05 m from the feature.
planes = inspire.geometry.Plane(feature, "OFFSET", offset=1, noOfPlanes=2)# returns list of planes`
user_plane1 = planes[0]
user_plane2 = planes[1]

# Create a sketch object on global Z plane
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# adding a regular polygon to the sketch
sketch1.addCircleCenterRadius((0, 0),0.5)
# realize the sketch
sketch_part1= sketch1.realize()

# Create a sketch object on global Y plane
sketch2 = inspire.Sketch("Global Y")
# adding a line segment to the sketch
sketch2.addLineSegment((0, 0), (0, -10))
# realize the sketch
sketch_part2 =sketch2.realize()

# Create a sketch object on user_plane
sketch3 = inspire.Sketch(user_plane1)
# adding a regular polygon to the sketch
sketch3.addCircleCenterRadius((0, 0),1)
# realize the sketch
sketch_part3 =sketch3.realize()

# Create a sketch object on user_plane
sketch4 = inspire.Sketch(user_plane2)
# adding a regular polygon to the sketch
sketch4.addCircleCenterRadius((0, 0),1.3)
# realize the sketch
sketch_part4 =sketch4.realize()

path = sketch_part2.getFeatures('FeatureCurve')
profile1 = sketch_part1.getFeatures('FeatureArea')[0]
profile2 = sketch_part3.getFeatures('FeatureArea')[0]
profile3 = sketch_part4.getFeatures('FeatureArea')[0]

inspire.geometry.multiSweep(profiles=[profile1, profile2,profile3], path=path,
                            sweepAsSolid=True, arcLengthProfiles=False, arcLengthGuides=False,
                            orientation='PERPENDICULAR', normalToSurface=None,
                            resultType='NEW_PART', mergeWithAllParts=True, mergeParts=None,
                            profileContinuity=None, profileMagnitude=None)

print("multi Sweep has been created with profile1 and profile2.")
inspire.orientView(direction="isometric")

# Get the last multi Sweep CF from the model.
multiSweepCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# multiSweepCF = model.construction.getCF(name= 'Multi Sweep 1')
# Edit the multiSweepCF CF:
with multiSweepCF.edit():
    # Ctrate a Sheet / 2D sweep
    multiSweepCF.sweepAsSolid = False
    # Smiliarly, other parameters can be modified.

inspire.orientView(direction="isometric")
# Delete the solid block part
part.destroy()
inspire.orientView(direction="isometric")

loft#

loft(profiles, loftAsSolid=True, guideCurves=None, arcLengthProfiles=False, arcLengthGuides=False, swapSurface=False, closed=False, resultType='NEW_PART', mergeWithAllParts=True, mergeParts=None, profileChain=False, guideCurvesTangent=False, target=False, targetPart=None)#

Create a solid loft or a lofted surface from profiles and guide curves.

Parameters:
  • profiles (list[FeatureArea | FeatureCurve]) – Faces, closed sketches or curves.

  • loftAsSolid (bool) – If true, sweep as solids otherwise sweep as surfaces.

  • guideCurves (list[FeatureCurve]) – Guide curves for the loft.

  • arcLengthProfiles (bool) – If True, Set Arc Length Parametrization on profiles.

  • arcLengthGuides (bool) – If True, Set Arc Length Parametrization on guides.

  • swapSurface (bool) – If True, interchange the profiles and rails to get preferred shape.

  • closed (bool) – If True, close the loft.

  • resultType (str) – Result type of loft operation. - COMBINE - SUBTRACT - INTERSECT - NEW_PART

  • mergeWithAllParts (bool) – If True, merge with All parts otherwise merge with parts supplied in mergeTargets.

  • mergeParts (Part) – Parts to be merged with loft operation.

  • profileChain (bool) – True, Allows to select profile’s connected edges.

  • guideCurvesTangent (bool) – True, Allows to select guideCurve’s connected edges.

  • target (bool) – If True, Set the target part used for boolean combine.

  • targetPart (Part) – The target part used for boolean combine.

Returns:

New part created if resultType is NEW_PART.

Return type:

Part|None

Example

# This script demonstrates the usage of loft function.

#Create a solid loft or a lofted surface from profiles and guide curves.
#Lofting creates a solid or surface by blending between two or more profiles

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

# Create a solid block of length 1, width 1 and height 2.
part = model.createSolidBlock(x=1,y=1, z=2)

feature = model.getFeatures(type=inspire.FeaturePlanar)[0]
# Create a plane with offset of 0.05 m from the feature.
planes = inspire.geometry.Plane(feature, "OFFSET", offset=1, noOfPlanes=2)# returns list of planes`
user_plane1 = planes[0]
user_plane2 = planes[1]
#Alternatively, you can use below method to get a plane.


# Create a sketch object on global Z plane
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# adding a regular polygon to the sketch
sketch1.addRegularPolygon((0, 0), (1, 0), 7)
# realize the sketch
sketch_part1= sketch1.realize()

# Create a sketch object on user_plane
sketch3 = inspire.Sketch(user_plane1)
# adding a regular polygon to the sketch
sketch3.addRegularPolygon((0, 0), (1, 1), 7)
# realize the sketch
sketch_part3 =sketch3.realize()

# Create a sketch object on user_plane
sketch4 = inspire.Sketch(user_plane2)
# adding a regular polygon to the sketch
sketch4.addRegularPolygon((0, 0), (1, 1), 7)
# realize the sketch
sketch_part4 =sketch4.realize()

profile1 = sketch_part1.getFeatures('FeatureArea')[0]
profile2 = sketch_part3.getFeatures('FeatureArea')[0]
profile3 = sketch_part4.getFeatures('FeatureArea')[0]

inspire.geometry.loft(profiles =[profile1, profile2,profile3], loftAsSolid=False, guideCurves=None, arcLengthProfiles=False,
                      arcLengthGuides=False,swapSurface=False, closed=False, resultType='NEW_PART',
                      mergeWithAllParts=True, mergeParts=None, profileChain=False, guideCurvesTangent=False)

print("Loft has been created with profile1 and profile2.")
inspire.orientView(direction="isometric")

# Get the last loft CF from the model.
loftCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# loftCF = model.construction.getCF(name= 'Loft 1')
# Edit the loft CF:
with loftCF.edit():
    # Ctrate a 3D Solid loft
    loftCF.loftAsSolid = True
    # Smiliarly, other parameters can be modified.

part.destroy()
inspire.orientView(direction="isometric")

helixCurve#

helixCurve(profile, type='TURNS_AND_HEIGHT', numTurns=2, pitch=0.003, height=0.01, startAngle=0, curveHand='RIGHT', heightReverse=False, lockDiameterRatio=True, topDiameter=0)#

Create a solid loft or a lofted surface from profiles and guide curves.

Parameters:
  • profile (FeatureCircular) – Circular sketch profile.

  • type (str) – Helix Curve Type. - TURNS_AND_HEIGHT - TURNS_AND_PITCH - HEIGHT_AND_PITCH

  • numTurns (float) – Number of turns in helix curve.

  • pitch (float) – Pitch distance of helix curve.

  • height (float) – Height of helix curve.

  • startAngle (float) – Start angle of helix curve.

  • curveHand (str) – Helix curve sweep direction. - LEFT - RIGHT

  • heightReverse (bool) – If True, Reverse the height in other direction of helix curve.

  • lockDiameterRatio (bool) – If True, Set lock diameter ratio of helix curve.

  • topDiameter (float) – Top Diameter of helix curve.

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addCircleCenterRadius((0, 0), 7)
sketch_part = sketch1.realize()
model.variables.add(name="topDiameter", type="length", expression= '7m')
model.variables.add(name="numTurns", type=None, expression= 10)
model.variables.add(name="startAngle", type=None, expression= '45 deg')
profile = sketch_part.getFeatures(inspire.FeatureCircular)[0]
# use of model variable to make the helix curve parametric.
inspire.geometry.helixCurve(profile=profile,  startAngle='startAngle',
                            numTurns ='numTurns', height = 5,
                             lockDiameterRatio =False, topDiameter ='topDiameter')
inspire.fitView()

print("Helix Curve has been created with profile.")
inspire.orientView(direction="isometric")

divideCurve#

divideCurve(curve, divisionPoints, uniformDivision=False)#

Divide a curve by inserting points along the curve.

Parameters:
  • curve (FeatureCurve) – Curve to divide.

  • divisionPoints (list(list[float | str], bool)) – List of divisionPoints (length ratio or length along the curve) and the bool value depicts position ratio. If True, Divide the curve on length ratio otherwise division occurs at length along the curve.

  • uniformDivision (bool) – If True, Curve is uniformly divided.

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addCircleCenterRadius((0, 0), 7)
sketch_part = sketch1.realize()
profile = sketch_part.getFeatures(inspire.core.FeatureCircular)[0]
curve = inspire.geometry.helixCurve(profile, startAngle=10, numTurns=10)
inspire.geometry.divideCurve(curve.features[-1], [[0.2, 0.6]])
inspire.fitView()

print("Curve has been divided in to 3 parts.")
inspire.orientView(direction="isometric")

extendCurve#

extendCurve(curve, extensionTypeAndDistance, shape='LINEAR', extendEnds='START', extendAsNewPart=False)#

Extend a curve and modify the shape of the extension.

Parameters:
  • curve (FeatureCurve) – Extracted Curve to extend.

  • extensionTypeAndDistance (list[str, float] | list[str, Feature | Plane]) –

    Extension type as string and Distance as float to extend. For UP_TO_FEATURE extension type second argument should be either a Feature or System Plane. Valid extension types are:

    • EXTENSION_DISTANCE

    • INCREMENT_FACTOR

    • TOTAL_LENGTH

    • UP_TO_FEATURE

  • shape (str) – Shape of extend curve. - LINEAR - SOFT - REFLECTIVE - NATURAL - ARC

  • extendEnds (str) – To reverse the curve extension direction. - START - END

  • extendAsNewPart (bool) – Create a new part if True, otherwise merge in original part.

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addLineSegment((0, 0), (0, 1))
sketch_part = sketch1.realize()
curve = sketch_part.getFeatures(inspire.core.FeatureLinear)[0]
inspire.geometry.extract(curve)
curve = model.parts[0].getFeatures(inspire.core.FeatureLinear)[0]
inspire.geometry.extendCurve(curve, ["EXTENSION_DISTANCE", 1],
                             extendAsNewPart=True)
inspire.fitView()

print("Part 1 has been extended to Part 2.")
inspire.orientView(direction="isometric")

blendCurve#

blendCurve(points, degree='CUBIC')#

Create a free-form curve that blends into one or more existing curves, surfaces, or edges.

Parameters:
  • points (list(list(FeaturePoint, Feature, Feature) –

    list(FeaturePoint, Feature) | list(math.Point) | list(FeaturePoint))): Blend Curve points is a list of lists in which inner list is either of length one, two or three. Below are the explanation for each length list:

    Length 1: In this case the only value of list is math.Point or

    FeaturePoint, it will be considered as a point in free space.

    Length 2: In this case the values are FeaturePoint, Feature. Here the

    second feature is main feature. Use this only when the point is really depending on a main geometrical feature.

    Length 3: In this case the values are FeaturePoint, Feature, Feature.

    Here the second and third feature is main and optional feature respectively. Use this only when the point is really depending on a main geometrical feature and optional feature.

  • degree (str) – Degree for blend curve. - CUBIC - QUINTIC

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
from hwx.inspire import math
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
points = [[math.Point(1, 1, 0)], [math.Point(1, 2, 0)]]
inspire.geometry.blendCurve(points)
inspire.fitView()

print("Blend curve has been created between two given points.")
inspire.orientView(direction="isometric")

faceCurve#

faceCurve(face, method='POINT', uRatio=True, vRatio=True, ignoreHoles=True, uCurvesCount=5, vCurvesCount=5, uParmRatioForPointMode=0, vParmRatioForPointMode=0, vertexFeature=None, vertexPoint=None)#

Extract curves from a face in the U or V direction. This is useful for creating trim curves that run along a face.

Parameters:
  • face (FeatureArea) – Face on which extract curves.

  • method (str) – Method for face curve. - POINT - VERTEX - MESH

  • uRatio (bool) – If True, create U curves.

  • vRatio (bool) – If True, create V curves.

  • ignoreHoles (bool) – If True, ignore the holes in face curve.

  • uCurvesCount (Int) – Set U curves count to create for method type MESH.

  • vCurvesCount (Int) – Set V curves count to create for method type MESH.

  • uParmRatioForPointMode (Float) – Set U Param for method type POINT, param should be between 0 and 1.

  • vParmRatioForPointMode (Float) – Set V Param for method type POINT, param should be between 0 and 1.

  • vertexFeature (FeaturePoint) – Feature point to extract iso-param curve for method type VERTEX.

  • vertexPoint (math.Point) – Point to create face curves for method type POINT. Point must lie on the face.

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
box = model.createSolidBlock(x=1,y=1,z=1)
face = model.getFeatures(type=inspire.FeaturePlanar)[0]
vertex = model.getFeatures(type=inspire.FeaturePoint)[0]
inspire.geometry.faceCurve(face, vertexFeature=vertex)
inspire.fitView()

print("Face curves has been extracted from the face of solid block as Part 1"
     " and Part 2.")
inspire.orientView(direction="isometric")

offsetCurves#

offsetCurves(curve, offsetDistance=0.01, extensionType='NATURAL', symmetry=False, endOptions='OPEN', elevationType='NONE', elevationDistance=0.0, customElevationType='FREE', entityReferenceDirection=None, entityReferenceAxis=None, freeDirection=None)#

Create a copy of one or more curves at a specifies distance from the source curves This tool can be used on both 2D and 3D curves.

Parameters:
  • curve (FeatureCurve) – Curve to create offset curve.

  • offsetDistance (float) – Offset distance form actual curve.

  • extensionType (str) – Extension Type for offset curve. - NATURAL - ROUND - LINEAR

  • symmetry (bool) – If True, offset curves are created in both direction.

  • endOptions (str) – End Options. - OPEN - CLOSED_AND_STRAIGHT_ENDS - CLOSED_AND_ROUNDED

  • elevationType (str) – Elevation Type. - NONE - NORMAL - CUSTOM

  • elevationDistance (float) – Elevation distance for the offset curve.

  • customElevationType (str) – Custom Elevation Type. - ENTITY_REFERENCE - FREE

  • entityReferenceDirection (FeatureLinear) – Entity reference direction for offset curve.

  • entityReferenceAxis (Axis) – Entity reference Axis for offset curve.

  • freeDirection (math.Vector) – User defined direction for offset curve.

Returns:

New part created.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addLineSegment((0, 0), (0, 0.5))
sketch_part = sketch1.realize()
curve = sketch_part.getFeatures(inspire.core.FeatureLinear)[0]
inspire.geometry.extract(curve)
curve = model.parts[0].getFeatures(inspire.core.FeatureLinear)[0]
inspire.geometry.offsetCurves(curve, 0.02,  extensionType="LINEAR",
                             endOptions='CLOSED_AND_ROUNDED',
                             symmetry=True)
inspire.fitView()

print("Offset Curves has been created for given line.")
inspire.orientView(direction="isometric")

extendSurface#

extendSurface(edgesToExtend=None, allEdgesToExtend=False, extensionType='LINEAR', extent='EXTENSION_LENGTH', distance=0.01, extendUptoSurface=None, extendUptoPlane=None, createNewPart=False)#

Extend a surface along one or more edges.

Parameters:
  • edgesToExtend (list[FeatureCurve]) – Edges of the surface to extend. Valid only if allEdgesToExtend is False.

  • allEdgesToExtend (float) – If True, it will consider all the edges of the surface and ignore edgesToExtend values.

  • extensionType (str) – Extension Type. - LINEAR - SOFT - REFLECTIVE

  • extent (str) – Extent of surface. - EXTENSION_LENGTH - UP_TO_PLANE - UP_TO_SURFACE

  • distance (float) – Extension distance of surface.

  • extendUptoSurface (Part) – System Plane up to which surface is extended. Only valid for UP_TO_SURFACE extent.

  • extendUptoPlane (Plane) – Plane up to which surface is extended. Only valid for UP_TO_PLANE extent.

  • createNewPart (bool) – If True, new part is created as a extended surface otherwise not.

Returns:

New part created if createNewPart is True.

Return type:

Part|None

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
rectangleSheet = model.createSheetRectangle()
inspire.geometry.extendSurface(
rectangleSheet.getFeatures(inspire.core.FeatureLinear), distance=0.3,
createNewPart=True)
inspire.fitView()

print("Extend Surface has been created as a new part around the rectangular"
     "sheet.")
inspire.orientView(direction="isometric")

intersectCurve#

intersectCurve(targets, tools, combineCurves=False)#

Split intersecting curves or wire bodies into several curves.

Parameters:
  • targets (list[Part]) – Parts to be intersected with tools.

  • tools (list[Part]) – Parts used to intersect the targets.

  • combineCurves (bool) – If True, combine result curves.

Returns:

The intersect part.

Return type:

Part

Example

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch2 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addLineSegment((0, -1), (0, 1))
sketch2.addLineSegment((-1, 0), (1, 0))
sketch_part1= sketch1.realize()
sketch_part2 = sketch2.realize()
inspire.geometry.extract(sketch_part1.getFeatures(inspire.FeatureLinear)[0])
inspire.geometry.extract(sketch_part2.getFeatures(inspire.FeatureLinear)[0])
part1 = model.parts[0]
part2 = model.parts[1]
inspire.geometry.intersectCurve(part1, part2)
inspire.fitView()

print("Curves are intersected using intersectCurve tool and a new curve "
     "as a part has been created.")
inspire.orientView(direction="isometric")

rib#

rib(sketch, targetPart, ribThickness=0.01, flipMaterialDirection=False, offsetDirection='MID', ribDirection='NORMAL', draftAngle=0, reverseDraftDirection=False, extensionType='LINEAR', manufacturingType='NONE', baseRadius=0.001, topRadius=0.001)#

Extrude rib geometry from a sketch to stiffen your model.

Parameters:
  • sketch (Part) – Sketch profile for rib tool.

  • targetPart (Part) – Target part on which rib tool will be created.

  • ribThickness (bool) – Rib thickness.

  • flipMaterialDirection (bool) – If True, flip the material direction of rib tool otherwise not.

  • offsetDirection (str) – Offset direction type. - LEFT - MID - RIGHT

  • ribDirection (str) – Rib direction type. - NORMAL - PARALLEL

  • draftAngle (float) – Draft angle for rib creation in degree.

  • reverseDraftDirection (bool) – If True, reverse the draftAngle direction otherwise not.

  • extensionType (str) – Rib extension type. - LINEAR - NATURAL

  • manufacturingType (str) – Manufacturing type. - NONE - THERMOSET - THERMOPLASTIC - CASTING - CUSTOM

  • baseRadius (float | str) – Base radius for rib creation.

  • topRadius (float | str) – Top radius for rib creation.

Example

# This script demonstrates the usage of rib function.

#Extrude rib geometry from a sketch to stiffen your model.
# You can pass an arc, curve, straight line, or curved surface.

from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock(x=1,y=1,z=1)
featPlane = box.getFeatures(type="FeaturePlanar")[0]
featPlane.shell(thickness=0.01)
s = inspire.Sketch("Global Y")
s.addLineSegment((0.2, -0.5), (0, -0.5))
sketch_part = s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]
profile = sketch_part
inspire.geometry.rib(sketch=profile, targetPart=box, ribThickness=0.01,
                     flipMaterialDirection=False, offsetDirection='MID',
                     ribDirection='NORMAL',draftAngle=30, reverseDraftDirection=False,
                     extensionType='NATURAL', manufacturingType='NONE', baseRadius=0.001,
                     topRadius=0.001)
inspire.fitView()
print("Rib has been created in the shell.")
inspire.orientView(direction="isometric")

# Get the last rib CF from the model.
ribCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# ribCF = model.construction.getCF(name= 'Rib 1')
# Edit the rib CF:
with ribCF.edit():
    ribCF.offsetDirection = 'RIGHT'
    ribCF.flipMaterialDirection = True
    ribCF.ribDirection = 'PARALLEL'

inspire.orientView(direction="isometric")

patch2#

patch2(features, internalCurves=[], globalContinuity='POSITION', mergeResult=True)#

New Patch tool - Creates patches to fill in specified missing surfaces.

Parameters:
  • features (list[Feature]) – Features to be patched.

  • internalCurves (list[Feature]) – Internal curves for patch.

  • globalContinuity (str) – Global continuity for patch. - POSITION - TANGENT - CURVATURE

  • mergeResult (bool) – If True, merge the results otherwise not.

Returns:

New parts created.

Return type:

list[Part]

Example

# This script demonstrates the usage of patch2 function.

from hwx import inspire
#
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# creating a Sketch object
s = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
# Adding a rectangle to the sketch
s.addRectangle2Vertex((0, 0), (2, 2))
# realize the sketch
sketch_part = s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]
inspire.geometry.extrude(features=sketch_part.getFeatures(type=inspire.FeatureArea),
                 direction="SINGLE", resultType="COMBINE", extrudeTo1=0.5, extrudeAsSolid=False)
# Get the FeatureCurve from the extruded part
f1 = model.parts[0].features[9]
f2 = model.parts[0].features[12]
f3 = model.parts[0].features[15]
f4 = model.parts[0].features[19]

inspire.geometry.patch2(features=[f1, f2, f3, f4],
                        internalCurves=[],
                        globalContinuity="TANGENT",
                        mergeResult=False)
print("Patch2 is created on a rectangular edges ")
inspire.orientView(direction="isometric")

# Get the last patch2 CF from the model.
patch2CF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# patch2CF = model.construction.getCF(name= 'Patch 1')

# Edit the patch2 CF:
with patch2CF.edit():
    patch2CF.globalContinuity ='CURVATURE'
    patch2CF.mergeResult =True

deleteFaces2#

deleteFaces2(features)#

New delete faces which deletes the specified faces from the part.

Parameters:

features (list[Feature]) – Features to be removed.

Example

# This script demonstrates the usage of deleteFaces2 function.

# Delete faces from solid or sheet parts.

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block
box = model.createSolidBlock(x=1,y=1,z=1, name= 'Block 1')
featPlanar = box.getFeatures(type='FeaturePlanar')[2]
inspire.geometry.deleteFaces2(features  = [featPlanar])
print(f"Deleted a planar face from the part ")
inspire.orientView(direction="isometric")
# Get the last deleteFaces2 CF from the model.
deleteFaces2CF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# deleteFaces2CF = model.construction.getCF(name= 'Delete Faces 1')

# Edit the deleteFaces2 CF:
with deleteFaces2CF.edit():
    deleteFaces2CF.features = box.getFeatures(type='FeaturePlanar')[:2]
    print(f"{deleteFaces2CF.name} CF is modified.")

inspire.orientView(direction="isometric")

deform#

deform(parts, deformType='TWIST', deformAxis='Z', twistType='ANGLE', twistAngle=360, twistTurns=1, twistSmoothing=0, bendType='RADIUS', bendRadius=1.273, bendAngle=45, taperFactor=1, shearAngle=45, stretchCurve=None, stretchAngle=0, stretchCurveOffset=0, stretchAlongCurve=False, stretchMoveToCurve=True, stretchReverseCurve=False, reapplyFillets=False, accuracy=0.8, eulerAngles=None, origin=None, trimPlane1Offset=-0.5, trimPlane2Offset=0.5, drapeTargetSurface=None, drapeMethod='UV_MAPPING', drapeUParameter=0.0, drapeVParameter=0.0, elevation=0, drapeAngle=0, drapeUScale=0, drapeVScale=0, drapeReverseSurface=False, anchorAxis=None, reverseAnchorAxis=False)#

Deform parts within a specified region.

Parameters:
  • parts (list[Part]) – Parts to be deformed.

  • deformType (str) – Deform Type. - TWIST - BEND - TAPER - SHEAR - STRETCH - DRAPE

  • deformAxis (str) – Deform Axis. - X - Y - Z

  • twistType (str) – Twist Type. - ANGLE - TURNS

  • twistAngle (float | str) – Twist angle to deform parts.

  • twistTurns (float | str) – Number of Twist turns to deform parts.

  • twistSmoothing (float) – Twist smoothing factor. Value from 0 to 1 is valid.

  • bendType (str) – Blend Type. - RADIUS - ANGLE

  • bendRadius (float | str) – Blend radius to deform parts.

  • bendAngle (float | str) – Blend angle to deform parts.

  • taperFactor (float | str) – Taper factor to deform parts.

  • shearAngle (float | str) – Shear angle to deform parts.

  • stretchCurve (Part) – Stretch curve to deform parts.

  • stretchAngle (float) – Stretch angle to deform parts.

  • stretchCurveOffset (float | str) – Stretch curve offset to deform parts.

  • stretchAlongCurve (bool) – If True, Stretch along curve to deform parts otherwise not.

  • stretchMoveToCurve (bool) – If True, Stretch move to curve to deform parts otherwise not.

  • stretchReverseCurve (bool) – If True, Stretch reverse the curve to deform parts otherwise not.

  • reapplyFillets (bool) – If True, Reapply fillets to deform parts.

  • accuracy (float | str) – Accuracy factor to deform parts. Value from 0 to 1 is valid.

  • eulerAngles (list[roll, pitch, yaw]) – Euler angles in x,y,z direction to deform parts.

  • origin (mat.Points) – Origin values in x,y,z direction to deform parts.

  • trimPlane1Offset (float | str) – TrimPlane1 offset to deform parts.

  • trimPlane2Offset (float | str) – TrimPlane2 offset to deform parts.

  • drapeTargetSurface (list[Feature]) – Drape target surface to deform parts.

  • drapeMethod (str) – Drape method. - UV_MAPPING - MINIMIZE_STRETCH

  • drapeUParameter (float | str) – Drape U parameter to deform parts.

  • drapeVParameter (float | str) – Drape V parameter to deform parts.

  • elevation (float | str) – Elevation to deform parts.

  • drapeAngle (float | str) – Drape angle to deform parts.

  • drapeUScale (float | str) – Drape U scale to deform parts.

  • drapeVScale (float | str) – Drape V scale to deform parts.

  • drapeReverseSurface (bool) – If True, Drape reverse surface to deform parts otherwise not.

  • anchorAxis (list[FeatureLinear]) – Anchor axis to deform parts.

  • reverseAnchorAxis (bool) – If True, reverse anchor axis to deform parts otherwise not.

Returns:

New parts created.

Return type:

list[Part]

Example

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

model = inspire.newModel()
block = model.createSolidBlock(x=1,y=1,z=1)
inspire.geometry.deform(block, twistAngle=300, twistSmoothing=0.9)

print("Deform is created.")
inspire.orientView(direction="isometric")

simplifyCurves#

simplifyCurves(curves, method='FIT_BY_TOLERANCE', tolerance=1e-05, numberOfPoints=10, degree=3, joinCurves=True)#

Simplify one or more curves by changing the number of control points and inverting their sequence, joining multiple curves, or by applying an arc length parametrization.

Parameters:
  • curves (list[Part]) – Curves used in simplify curves operation.

  • method (str) – Simplify Curves method. - FIT_BY_TOLERANCE - FIT_BY_NUMBER_OF_POINTS - REDUCE_POINTS - ARC_LENGTH_PARAMETERIZATION

  • tolerance (float | str) – Tolerance factor for simplify curves.

  • numberOfPoints (float | str) – Number of points to simplify curves.

  • degree (int | str) – Degree to simplify curves. Value from 1 to 5 is valid.

  • joinCurves (bool) – If True, join curves otherwise not.

Returns:

New parts created.

Return type:

list[Part]

Example

from hwx import inspire
from hwx.common import math

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
sketch1 = inspire.Sketch(system="Global Z", feature=None, origin=None, normal=None)
sketch1.addLineSegment((0, 0), (0, 0.5))
sketch_part = sketch1.realize()
curve = sketch_part.getFeatures(inspire.core.FeatureLinear)[0]
inspire.geometry.extract(curve)
curve = model.parts[0].getFeatures(inspire.core.FeatureLinear)[0]
curve1 = inspire.geometry.offsetCurves(curve, 0.02,
                                      extensionType="LINEAR",
                                      elevationType="CUSTOM",
                                      customElevationType="FREE",
                                      freeDirection=math.Vector(
                                      1, 1, 0))
inspire.geometry.simplifyCurves(curve1, tolerance=0.0006)

print("Simplify Curves is created.")
inspire.orientView(direction="isometric")

surfaceIntersection#

surfaceIntersection(surface1, surface2, combineCurves=True)#

Creates curves from two intersecting surfaces.

Parameters:
  • surface1 (list[Part]) – Set Surface1(target) parts.

  • surface2 (list[Part]) – Set Surface2(tool) parts.

  • combineCurves (bool) – If True, combine curves otherwise not.

Returns:

New parts created.

Return type:

list[Part]

Example

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
block1 = model.createSolidBlock(x=1,y=1,z=1)
block2 = model.createSolidBlock(z=0.2)
inspire.geometry.surfaceIntersection(block1, block2,False)
print("Surface Intersection is created.")
inspire.orientView(direction="isometric")

createTag#

createTag(input, name='', value='')#

Creates tag for any geometry part or feature.

Parameters:
  • input (list[Part | Feature]) – Entities to create a tag.

  • name (str) – Name of the tag.

  • value (str) – Value of the tag.

Deprecated since version 2025.1: This will be removed in 2026.1. Use the tag manager to created tag.

Example

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
block1 = model.createSolidBlock(x=1,y=1,z=1)
block2 = model.createSolidBlock(x=1,y=1,z=1)
features = block1.getFeatures(inspire.core.FeatureLinear)[0:2]
inspire.geometry.createTag([block1, block2], "Blocks",
                          "B12")
inspire.geometry.createTag(features, "Features", "F12")
inspire.geometry.createTag(block1, "Block1", "B1")

print("Tags are created.")
inspire.orientView(direction="isometric")

Tag#

Tag(*args, **kwargs)#

Tag class to create tags for any geometry part or feature.

Example

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
block1 = model.createSolidBlock(x=1,y=1,z=1)
tm = inspire.geometry.TagManager()
tm.createTag(block1, "Block","B1")

print("Tag is created using tag manager.")
inspire.orientView(direction="isometric")

TagManager#

TagManager(*args)#

TagManager class to manage tags for any geometry part or feature.

Example

# Assign or query tags (metadata) that can be associated with one or more entities in a model.
# A tag is metadata that can be assigned to one or more entities (faces, edges, vertices, or parts).
# It has a name and a value. For example, the name could be color and the value could be blue.
# For a given entity, each tag can only have one value to avoid conflicts.
# For example, if an entity had a tag named color with a value of blue, you could not create another
# tag named color with a value of red for that entity.
# An entity can have multiple tags, and the same tag can be applied to multiple entities.
# A model can also have no tags at all.
# When Import tags and Export tags are enabled in Preferences > Inspire > Geometry, tags are included
# when you import or export Parasolid files.


# This script demonstrates the usage of Tag and TagManager function.

from hwx.common import settings

tagImportPref = "Inspire/Geometry/Geometry/Import from CAD File/Parasolid/Import tags"
tagExportPref = "Inspire/Geometry/Geometry/Save to CAD Format/Parasolid/Export tags"

# Check if the tag import and export preferences are enabled
tagImportEnabled = settings.getSetting(tagImportPref)
print(f"Import Tag is enabled: {tagImportEnabled}")

tagExportEnabled = settings.getSetting(tagExportPref)
print(f"Export Tag is enabled: {tagExportEnabled}")

# How to set Export tag preference
settings.setSetting(tagExportPref, True)
# How to set import tag preference
settings.setSetting(tagImportPref, True)

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid block
block1 = model.createSolidBlock(x=1,y=1,z=1)
# get the Tag manager from the model
tmgr = inspire.geometry.TagManager()

tag1 = tmgr.createTag(input=block1, name="Tag 1",value="Part")
print(f"Tag name {tag1.getName()} is created with tag color {tag1.getColor()} , "
      f"tag value {tag1.getValue()} and tag features {tag1.getFeatures()} ")

featpoints = model.getFeatures(type='FeaturePoint')
tag2 = tmgr.createTag(input=featpoints, name="Tag 2",value="All_Points")
print(f"Tag name {tag2.getName()} is created with tag color {tag2.getColor()} , "
      f"tag value {tag2.getValue()} and tag features {tag2.getFeatures()} ")
# How to get number of features from the tag
print(f"{tag2.getName()} have {len(tag2.getFeatures())} features")

# How to Add feature to a tag
featCurves = model.getFeatures(type='FeatureCurve')
tag3 = tmgr.createTag(input=featCurves[0], name="Tag 3",value="Curves")
tag3.addFeature(feature = featCurves[1])

# How to get all tags from the model

tags = tmgr.getAllTags()
print(f"Total number of tags in the model: {len(tags)}")

#How to get the tag by name
tag = tmgr.getTagsByName(name="Tag 1")# returns list of tags with  name "Tag 1".
if tag:
  print(f"Tag name {tag[0].getName()} is created with tag color {tag[0].getColor()} ")

# How to get the tag by feature
tag = tmgr.getTagsByFeature(feature=featpoints[0])# returns list of tags with  name "Tag 1".
if tag:
    print(f"Tag name {tag[0].getName()} is created with tag color {tag[0].getColor()} ")

# How to get tag by part
tags = tmgr.getTagsByPart(part= block1)
if tags:
    for tag in tags:
      print(f"Tag name {tag.getName()} is created with tag color {tag.getColor()} ")

# How to delete a tag by name
tag = tmgr.getTagsByName(name="Tag 1")# returns list of tags with  name "Tag 1".
for tag in tags:
  tmgr.deleteTag(tag = tag)

# How to delete all a tag
tag = tmgr.deleteAllTags()
print(f"All the tags are deleted from the model.")

inspire.orientView(direction="isometric")

move2#

move2(entities, moveMode='FREE', position=None, translateX=0, translateY=0, translateZ=0, alongLineMagnitude=0, rotateAngle=0, moveAxis=None)#

New move tool to Translates and/or rotates a part.

Parameters:
  • entities (List[Part]) – Entities to move.

  • moveMode (str) – Move tool mode. Valid values are - FREE - TRANSLATE_GLOBAL - TRANSLATE_ALONG_LINE - ROTATE_ABOUT_AXIS

  • position (math.Matrix44) – The position to move the parts at.

  • translateX (float | str) – Value to translate in X direction. Only valid for TRANSLATE_GLOBAL move mode.

  • translateY (float | str) – Value to translate in Y direction. Only valid for TRANSLATE_GLOBAL move mode.

  • translateZ (float | str) – Value to translate in Z direction. Only valid for TRANSLATE_GLOBAL move mode.

  • alongLineMagnitude (float | None) – Along line magnitude. Only valid for TRANSLATE_ALONG_LINE move mode.

  • rotateAngle (float | str) – Rotate angle. Only valid for ROTATE_ABOUT_AXIS move mode.

  • moveAxis (Feature | System) – Feature curve that is linear, or feature area that is cylindrical or Reference Axis or Plane.

Example

# This script demonstrates the usage of move2 function.

# New move tool to Translates and/or rotates a part.
# move2 is the preferred method to move or translate or rotate a part.

# Four ways we can perform Move operation.
# moveMode. FREE, TRANSLATE_GLOBAL, TRANSLATE_ALONG_LINE, ROTATE_ABOUT_AXIS

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

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid cylinder of radius 1 and height 6
cylinder1 = model.createSolidCylinder(
    radius=1,
    height=6,
    color='blue'
)
# Creating a solid cylinder of radius 1 and height 6
cylinder2 = model.createSolidCylinder(
    radius=1,
    height=6,
    color='red'
)
# Creating a solid block of length 1, width 1 and height 1.
box = model.createSolidBlock(x=1, y=1, z=1, color='green')

# Free Mode usage.
position = Matrix44(origin=[1, 2, 3], angles=[0, 45, 0], degrees=True)
# moveMode is set to Free and set position to the matrix.
cylinder2.move2(moveMode="FREE", position=position)

# moveMode is set to TRANSLATE_GLOBAL and x,y,z distance to move the part.
cylinder2.move2(moveMode="TRANSLATE_GLOBAL", translateX =2,translateY =5,translateZ =2.5)

# Get the global Axis from the model.
x = model.getAllChildren(type="Axis")[0]
y = model.getAllChildren(type="Axis")[1]
z = model.getAllChildren(type="Axis")[2]

inspire.geometry.move2(box, moveMode="TRANSLATE_ALONG_LINE", moveAxis=x, alongLineMagnitude  =1.5)

# moveMode is set to ROTATE_ABOUT_AXIS and set axis and rotation angle.
inspire.geometry.move2(box, moveMode="ROTATE_ABOUT_AXIS", moveAxis=x, rotateAngle=45)

# Alternatively, you can use below method to move the part.

inspire.fitView()

seamWeld#

seamWeld(mode='AUTO', parts=None, sectionSize=0.003, minimumLength=0.012, weldPath=None, adjustEnd1=0, adjustEnd2=0, tangential=False)#

Connect parts along a continious edge or line. :param mode: Seam weld mode. Valid values are

  • AUT0

  • MANUAL

Parameters:
  • parts (list[Part]) – Set the parts across which Weld parts needs to be created for AUTO mode only.

  • sectionSize (float | str) – Radius of the seam weld cross section.

  • minimumLength (float | str) – Minimum length of the seam weld.

  • weldPath (list[FeatureLinear]) – Set the edges across which Weld parts needs to be created for MANUAL mode only.

  • adjustEnd1 (float | str) – Set Where to start in the - overlapping edge-region. For MANUAL mode only.

  • adjustEnd2 (float | str) – Set Where to stop in the - overlapping edge-region. For MANUAL mode only.

  • tangential (bool) – Set Tangential Edges option - MANUAL mode only.

Example

# This script demonstrates the usage of seamWeld function.
# Connect parts along a continuous edge or line. Seam welds work with solids for SimSolid
# and OptiStruct analysis and optimizations.
# When parts are seam welded together, the contacts between the surfaces are
# automatically converted from Bonded to No Contact.
# Seam welds can be applied to solids only.

# seamWeld function supports weld creation in two modes 1. AUTO, 2. MANUAL.

from hwx import inspire
from hwx.inspire.demo import openDemoFile

# Open a demo file
model = openDemoFile("Imprints.x_t")
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# slice the part using the slice function.
inspire.geometry.slice(targets=model.parts, cutOrigin=(0,0,0), cutNormal=(1,0,0))

# Create a seam weld between the two blocks using AUTO mode
inspire.geometry.seamWeld(mode ='AUTO', parts=model.parts, sectionSize=0.03,
                          minimumLength=0.12, weldPath=None, adjustEnd1=0,
                          adjustEnd2=0, tangential=False)
seamWeldCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# seamWeldCF = model.construction.getCF(name= 'Seam Weld 1')
# Edit the seamWeld CF:
with seamWeldCF.edit():
    model.variables.add(name = 'weld_size',type='LENGTH', expression=0.05)
    model.variables.add(name = 'weld_min_length',type='LENGTH', expression=0.08)
    # adding variable to seam weld sectionSize and minimumLength.
    seamWeldCF.sectionSize = 'weld_size'
    seamWeldCF.minimumLength = 'weld_min_length'
    # Ski is applicable only for AUTO mode.
    seamWeldCF.skip = ['Seam Weld 1', 'Seam Weld 4']

# Mode MANUAL, Seam Weld is created between the two blocks using the weldPath.
feature = model.getFeatures(type='FeatureLinear')[0]
inspire.geometry.seamWeld(mode="MANUAL",parts=model.parts, weldPath=feature)
print("Seam Weld is created.")
seamWeldCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# seamWeldCF = model.construction.getCF(name= 'Seam Weld 2')
# Edit the seamWeld CF:
with seamWeldCF.edit():
    # adding variable to seam weld sectionSize and minimumLength.
    seamWeldCF.sectionSize = 'weld_size'
    seamWeldCF.minimumLength = 'weld_min_length'
    # Creating two model variables adjustEnd1 and adjustEnd2 of type LENGTH
    model.variables.add(name = 'adjustEnd1',type='LENGTH', expression=0.1)
    model.variables.add(name = 'adjustEnd2',type='LENGTH', expression=0.2)
    # Set the adjustEnd1 and adjustEnd2 to the seamWeld CF
    seamWeldCF.adjustEnd1 ='adjustEnd1'
    seamWeldCF.adjustEnd2 = 'adjustEnd2'

inspire.orientView(direction="isometric")

patternAlongSurface#

patternAlongSurface(input, surface, copiesAlongU=3, copiesAlongV=3, orientation='PATH_DIRECTION', alignment='PATH_NORMAL', retainSource=True, firstCopy='RETAIN_POSITION', origin=None, startU=0, endU=1, startV=0, endV=1, result='NEW_PART', mergeWithAllParts=True, mergeParts=None, copiesToSkip=None)#

Pattern part along surface.

Args:

input (Part): Part to create pattern along the surface. surface (list[FeatureArea]): Surface for pattern. copiesAlongU (int | str): Number of copies along U direction. copiesAlongV (int | str): Number of copies along V direction. orientation (str): Orientation of pattern along surface.

  • PATH_DIRECTION

  • KEEP_ORIGINAL

alignment (str): Alignment of pattern along surface.
  • PATH_NORMAL

  • FIXED

retainSource (bool): If True, retain source otherwise not. firstCopy (str): First copy of pattern along surface.

  • RETAIN_POSITION

  • MOVE_ORIGIN

  • ADJUST

origin (FeaturePoint): Origin of pattern along surface. startU (float | str): Start U value of pattern along surface. Valid values

range - 0 to 1, strictly + ive values only.

endU (float | str): End U value of pattern along surface. Valid values

range - 0 to 1, strictly + ive values only.

startV (float | str): Start V value of pattern along surface. Valid values

range - 0 to 1, strictly + ive values only.

endV (float | str): End V value of pattern along surface. Valid values

range - 0 to 1, strictly + ive values only.

result (str): Result type of pattern along path.
  • COMBINE

  • SUBTRACT

  • INTERSECT

  • NEW_PART

mergeWithAllParts (bool): If True, merge with All parts otherwise merge with

parts supplied in mergeParts.

mergeParts (list[Part]): Parts to be merged with pattern along path. copiesToSkip (dict{Part: list[indicesToSkip]}): Set copies to skip. It’s

basically a dictionary which contains Part as a key and list of indices to skip as values.

Returns: list[Part]: List of parts created.

Example

# This script demonstrates the usage of patternAlongSurface function.
# Pattern parts or faces along a surface

from hwx import inspire

model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()
# Creating a solid cylinder of radius 1 and height 1.2.
cylinder = model.createSolidCylinder(radius=1, height=1.2, location=(0, 0, 0))
# Creating a solid block of length 0.1, width 0.1 and height 0.02.
box2 = model.createSolidBlock(x=0.5, y=0.5, z=0.5, location=(3, 3, 0))
# Get the first FeatureCylindrical feature from cylinder part.
cyl_face = cylinder.getFeatures(type="FeatureCylindrical")[0]
# Creating a pattern along a surface using box2 as a part and cyl_face as a surface.
inspire.geometry.patternAlongSurface (input=box2, surface=cyl_face, copiesAlongU=3,
                     copiesAlongV=3, orientation='PATH_DIRECTION',
                     alignment='PATH_NORMAL', retainSource=False,
                     firstCopy='RETAIN_POSITION', origin=None,
                     startU=0, endU=1, startV=0, endV=1, result='NEW_PART',
                     mergeWithAllParts=True, mergeParts=box2, copiesToSkip={box2: [1]})

print("Pattern along a surface is created.")
inspire.orientView(direction="isometric")

# Get the last patternAlongSurface CF from the model.
patternAlongSurfaceCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# patternAlongSurfaceCF = model.construction.getCF(name= 'Pattern Along Surface 1')
# Edit the patternAlongSurface CF:
with patternAlongSurfaceCF.edit():
    patternAlongSurfaceCF.copiesToSkip = {box2: [0,1,2]}
    # set the firstCopy to ADJUST, So that the copied parts will adjut to the surface.
    patternAlongSurfaceCF.firstCopy ='ADJUST'
    print(f"{patternAlongSurfaceCF.name} CF is modified.")

referenceSystem#

referenceSystem(creationMethod='AT_VERTEX', origin=None, type=True, firstAxis='X', firstAxisValue=None, flipFirstAxis=False, secondPlane='XZ', secondPlaneValue=None, flipSecondPlane=False, ratio=-1, uRatio=0, vRatio=0, plane=None, system=None, eulerAngleX=0, eulerAngleY=0, eulerAngleZ=0, orthoLock=False, absoluteOrigin=None, systemCoordinateType='RECTANGULAR')#

Create a Referece System. :param creationMethod: Creation method of reference system.

  • AT_VERTEX

  • ON_CYLINDER

  • ON_EDGE

  • THREE_PLANES

  • ON_FACE

  • ON_SYSTEM

  • ABSOLUTE

Parameters:
  • origin (FeaturePoint) – Origin of reference system.

  • type (bool) – Type of reference system if True it is referenced otherwise rotation angles. Valid for THREE_PLANES, ON_EDGE and AT_VERTEX creation method.

  • firstAxis (str) – First axis of reference system. Valid for all expect ON_SYSTEM and ABSOLUTE. create method. - X - Y - Z

  • firstAxisValue (math.Vector) – First axis value of reference system. Valid for all expect ON_SYSTEM and ABSOLUTE. create method.

  • flipFirstAxis (bool) – Flip first axis of reference system. Valid for all expect ON_SYSTEM and ABSOLUTE. create method.

  • secondPlane (str) – Second plane of reference system. Valid for THREE_PLANES, ON_EDGE and AT_VERTEX creation method. - XY - YZ - XZ

  • secondPlaneValue (math.Vector) – Second plane value of reference system. Valid for THREE_PLANES, ON_EDGE and AT_VERTEX creation method.

  • flipSecondPlane (bool) – Flip second plane of reference system. Valid for THREE_PLANES, ON_EDGE and AT_VERTEX creation method.

  • ratio (float | str) – Ratio of reference system. Valid for ON_EDGE creation method.

  • uRatio (float | str) – U ratio of reference system. Valid for ON_FACE creation method.

  • vRatio (float | str) – V ratio of reference system. Valid for ON_FACE creation method.

  • plane (List[Plane]) – Plane of reference system. Valid for THREE_PLANES creation method.

  • system (ReferenceSystem) – Reference system of reference system. Valid for ON_SYSTEM creation method.

  • eulerAngleX (float | str) – Euler angle X of reference system. Valid for ABSOLUTE and AT_VERTEX creation method.

  • eulerAngleY (float | str) – Euler angle Y of reference system. Valid for ABSOLUTE and AT_VERTEX creation method.

  • eulerAngleZ (float | str) – Euler angle Z of reference system. Valid for ABSOLUTE and AT_VERTEX creation method.

  • orthoLock (bool) – Ortho lock of reference system. Valid for THREE_PLANES, ON_EDGE and AT_VERTEX creation method.

  • absoluteOrigin (math.Point) – Absolute origin of reference system. Valid for ABSOLUTE creation method.

  • systemCoordinateType (str) – System coordinate type of reference system. - RECTANGULAR - CYLINDRICAL

Example

# This script demonstrates the usage of referenceSystem function.
# Use the Systems tool to create and apply user-defined coordinate systems.
# This is useful for aligning loads to a local coordinate system rather than the global coordinate system.

from hwx import inspire
model = inspire.newModel()
# Alternatively, you can use getModel() which gets the existing Model.
model = inspire.getModel()

box = model.createSolidBlock(x=0.1,y=0.1,z=0.02,name= 'Block 1')
# get the first FeaturePoint (vertex), FeatureLinear(axis) and FeaturePlanar (plane) from the model.
origin = model.getFeatures(type="FeaturePoint")[0]
axis = model.getFeatures(type="FeatureLinear")[0]
plane = model.getFeatures(type="FeaturePlanar")[0]

# Creating a reference system along a surface using origin, axis and plane.
inspire.geometry.referenceSystem(creationMethod='AT_VERTEX',
                                 origin=origin,
                                 type=True,
                                 firstAxis="Y",
                                 firstAxisValue=axis,
                                 flipFirstAxis=False,
                                 secondPlane='XZ',
                                 secondPlaneValue=None,
                                 flipSecondPlane=True,
                                 ratio=-1,
                                 uRatio=0,
                                 vRatio=0,
                                 plane=None,
                                 system=None,
                                 eulerAngleX=0,
                                 eulerAngleY=0,
                                 eulerAngleZ=0,
                                 orthoLock=True,
                                 absoluteOrigin=None,
                                 systemCoordinateType='RECTANGULAR')
print("Reference System is created at vertex.")
inspire.orientView(direction="isometric")
# Get the last System CF from the model.
systemCF = model.construction[-1]
# Alternatively, you can get the CF by its name from the model
# systemCF = model.construction.getCF(name= 'System 1')
# Edit the System CF:
with systemCF.edit():
    systemCF.firstAxis = 'X'
    # similarly you can change the other parameters of the reference system.

inspire.orientView(direction="isometric")