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:
Example
from hwx import inspire
model = inspire.newModel()
cylinder1 = model.createSolidCylinder(
radius=1,
height=6,
)
cylinder1.location = (-4, 0, 0)
parts = model.parts
featPlanar = parts[0].getFeatures(type='FeaturePlanar')[1]
featPlanar.pushPull('1m')
inspire.fitView()
print("Cylinder1 is pushed to 1 meter without using variable.")
inspire.orientView(direction="isometric")
# Usage of variable to pushPull a feature.
cylinder2 = model.createSolidCylinder(
radius=1,
height=6,
)
parts = model.parts
featPlanar = parts[0].getFeatures(type='FeaturePlanar')[1]
model.variables.add("depth", type="length", expression=0.8)
featPlanar.pushPull("depth")
inspire.fitView()
print("Cylinder2 is pushed to 1 meter by using variable 'depth'.")
inspire.orientView(direction="isometric")
# Example to edit pushPull operation.
pushPullCF = model.construction[-1]
with pushPullCF.edit():
pushPullCF.depth = 3
inspire.fitView()
print("Cylinder2 is pushed to 3 meter by editing cf.")
inspire.orientView(direction="isometric")
extract#
- extract(features, maintainReference=True)#
Extracts geometry features and transfer them into a new part.
Example
from hwx import inspire
model = inspire.openTutorialFile("Structures/base.x_t")
parts=model.parts
featPlanar=model.parts[0].getFeatures(type='FeaturePlanar')[8]
featPlanar.extract()
print("Extracted part is created")
inspire.orientView(direction="isometric")
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:
Example
# There are two ways, user can create a mirrored part. One by calling
# mirror method on the part, or else select a planar feature on which
# the mirrored part will be created
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
# First using the part
box.mirror(planeOrigin=(0, 0, 1), planeNormal=(0, 0, 1))
print("A new part has been mirrored")
featurePlanar = box.getFeatures(type='FeaturePlanar')[1]
featurePlanar.mirror()
print("Another new part has been mirrored from the planar feature")
inspire.orientView(direction="isometric")
patch#
- patch(features)#
Creates patches to fill in specified missing surfaces.
- Parameters:
features (list[Feature]) – Features to be patched.
- Returns:
New parts created.
- Return type:
list[Part]
Deprecated since version 2024: This will be removed in 2024.2. Use the patch2 function instead
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
cyl = model.createSolidCylinder(radius=0.3)
part = box.booleanSubtract(cyl)
featCircular = part.getFeatures(type='FeatureCircular')[0]
featCircular.patch()
print("Patch is created on a cylindrical face ")
featPlanar = part.getFeatures(type='FeaturePlanar')[2]
featPlanar.deleteFaces()
print("Deleted a planar face from the part ")
inspire.orientView(direction="isometric")
rotate#
- rotate(part, axis, angle, degrees=True)#
Rotates a part around the specified axis.
This is a body rotation.
Example
from hwx import inspire
model = inspire.newModel()
cylinder1 = model.createSolidCylinder(
radius=1,
height=6,
color='blue'
)
cylinder2 = model.createSolidCylinder(
radius=1,
height=6,
color='red'
)
cylinder2.rotate('x', 45, degrees=True)
inspire.fitView()
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
from hwx import inspire
model = inspire.newModel()
cylinder1 = model.createSolidCylinder(
radius=1,
height=6,
color='blue'
)
cylinder2 = model.createSolidCylinder(
radius=1,
height=6,
color='red'
)
cylinder2.translate(x=10, y=0, z=0)
inspire.fitView()
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.
Example
from hwx import inspire
from hwx.common.math import Matrix44
model = inspire.newModel()
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)
cylinder2.move(mat)
inspire.fitView()
deleteFaces#
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
from hwx import inspire
model=inspire.openTutorialFile("Structures/plate.x_t")
part=model.parts[0]
part.scale(2.0)
print("Part is scaled by factor 2")
inspire.fitView()
booleanCombine#
- booleanCombine(target, tools=None)#
Combines the specified parts.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
sphere = model.createSolidSphere()
box.booleanCombine(sphere)
print("Box is combined with sphere")
inspire.orientView(direction="isometric")
booleanSubtract#
- booleanSubtract(targets, tools, keepTools=False)#
Carves out one set of solid objects from another set of solid objects.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
sphere = model.createSolidSphere()
sphere.booleanSubtract(box)
print("Sphere is subtracted with box")
inspire.orientView(direction="isometric")
booleanIntersect#
- booleanIntersect(targets, tools, keepTargets=False, keepTools=False)#
Retains only the intersecting portions of two sets of solid objects.
- Parameters:
- Returns:
The intersected part.
- Return type:
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
sphere = model.createSolidSphere()
sphere.booleanIntersect(box)
print("Sphere is intersected with box")
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:
Example
# There are two ways, user can create a slice part. One by calling
# slice method on the part with cutNormal & cutOrigion and other by calling
# slice method with surfaceFeature to slice out on surface mode.
from hwx import inspire
model = inspire.newModel()
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))
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(location=(-1, 0.5, 0))
feature = box.features[21]
part.slice(surfaceFeature=feature, extendSurface=True)
history.noteState()
print("Another new part has been sliced out from the existing part on Surface Mode")
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.
Example
# There are two ways, user can remove an imprint from model. One by calling
# simplifyImprints on the imprint feature or choose the part from which you
# want to remove the imprints from.
from hwx import inspire
from hwx.inspire.demo import openDemoFile
model = openDemoFile("Imprints.x_t")
linearFeatures = model.getFeatures(type='FeatureLinear')
# Removing Imprint feature
linearFeatures[0].simplifyImprints()
print("A line imprint has been removed from the part")
# Removing Imprints from a part
model.parts[0].simplifyImprints()
print("All the line imprints has been removed from the part")
inspire.orientView(direction="isometric")
simplifyRounds#
- simplifyRounds(entity, roundType='ALL', minSize=0, maxSize=None)#
Finds and removes both round (convex) and fillet (concave) surfaces.
- Parameters:
Example
# 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()
box = model.createSolidBlock()
feats = box.getFeatures(type='FeatureLinear')[:4]
inspire.geometry.edgeFillet(feats, radius='60mm')
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.
Example
# There are two ways, user can remove a hole from model. One by calling
# simplifyHoles on the hole feature or choose the part from which you
# want to remove the holes from.
from hwx import inspire
model = inspire.openTutorialFile("Structures/bracket.x_t")
featCylindrical = model.parts[0].getFeatures(type='FeatureCylindrical')[2]
# Removing the hole feature
featCylindrical.simplifyHoles()
print("A Hole has been removed from the part.")
# Removing holes feature from the part
model.parts[0].simplifyHoles()
print("All the holes has been removed from the part.")
inspire.orientView(direction="isometric")
simplifyPlugs#
- simplifyPlugs(entity, minSize=0, maxSize=None)#
Finds holes and pockets, and plug them by filling the area with a new part
Example
# There are two ways, user can plug holes from model. One by calling
# simplifyPlugs on the hole feature or choose the part from which you
# want to plug the holes from.
from hwx import inspire
model = inspire.openTutorialFile("Structures/bracket.x_t")
featCylindrical = model.parts[0].getFeatures(type='FeatureCylindrical')[2]
# Plug the hole feature
featCylindrical.simplifyPlugs()
print("A Hole has been plugged with new part.")
# Plug all the holes in the part
model.parts[0].simplifyPlugs()
print("All the holes has been with new part.")
inspire.orientView(direction="isometric")
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:
Example
from hwx import inspire
model = inspire.openTutorialFile("Structures/bracket.x_t")
featCircular = model.parts[0].getFeatures(type='FeatureCylindrical')[2]
featCircular.partition(thickness="3 mm")
print("Partition part is created with thickness of 3mm")
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
from hwx import inspire
model = inspire.newModel()
part = model.createSolidBlock()
part.midSurface(surfaceOptions='Left')
print("A Surface has been extracted from part {0}", part)
inspire.orientView(direction="isometric")
chamferByAngle#
- chamferByAngle(feature, angle=45, dist=0.003)#
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.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
featPlane1, featPlane2 = box.getFeatures(type='FeaturePlanar')[0:2]
# Chamfer by angle
featPlane1.chamferByAngle(angle=45, dist=0.05)
print("New chamfers is created.")
inspire.orientView(direction="isometric")
chamferByDistance#
- chamferByDistance(feature, dist1=0.003, dist2=0.003)#
Creates chamfer on a linear or planar feature.
- Parameters:
feature (Feature) – Feature that needs to be chamfer.
dist1 (float) – Chamfer distance from the edge.
dist2 (float) – Chamfer distance from the edge.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
featPlane1, featPlane2 = box.getFeatures(type='FeaturePlanar')[0:2]
# Chamfer by distance
featPlane2.chamferByDistance(dist1=0.06, dist2=0.06)
print("New chamfer is created.")
inspire.orientView(direction="isometric")
shell#
- shell(feature, thickness=1)#
Removes material and create thin walls to generate a shelled part.
- Parameters:
feature (FeatureArea) – Feature to create a shelled part from.
thickness (float) – Shell thickness.
Example
from hwx import inspire
model = inspire.openTutorialFile("Structures/base.x_t")
parts=model.parts
featPlanar=model.parts[0].getFeatures(type='FeaturePlanar')[9]
featPlanar.shell(thickness=.5)
print("Shell is created on base part with the thickness of 0.5mm")
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)#
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 | str) – If extrudeTo1 is a float then its the extrusion length in direction 1 in meters. If extrudeTo1 is a FeautrePoint or a FeaturePlanar then its used to determine the extrusion length in direction 1. If value is a string it can be a Model Variable or a value with units.
extrudeTo2 (float | FeaturePlanar | FeaturePoint | str) – If value is a float then it’s the extrusion length in direction 2 in meters. If value is a FeautrePoint or a FeaturePlanar then it’s used to determine the extrusion length in direction 2. If value is a string it can be a Model Variable or a value with units.
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.
- Returns:
New part created.
- Return type:
Example
from hwx import inspire
# Extrude As Solid
model = inspire.newModel()
s = inspire.core.Sketch()
s.addRectangle2Vertex((0, 0), (2, 2))
s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]
inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea),
"SINGLE", "NEW_PART", extrudeTo1=0.1)
s = inspire.core.Sketch()
s.addCircleCenterRadius((1, 1), 0.3)
s.realize()
sketch_part = model.getAllChildren('SketchPart')[1]
sketch_part.position
p = model.parts[0]
faces = p.getFeatures('FeaturePlanar')
inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea),
"SINGLE", "SUBTRACT", extrudeTo1=faces[4])
# Extrude As Sheet
s = inspire.core.Sketch()
s.addRectangle2Vertex((0, 0), (2, 2))
s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]
inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea),
"SYMMETRY", "NEW_PART", extrudeTo1=0.1, 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:
- Returns:
New part created if newPart was True.
- Return type:
Part|None
Example
from hwx import inspire
# Creating a solid box and applying offset of value 3.0 in face feature and value 0.2 to part
model = inspire.newModel()
box = model.createSolidBlock()
featFace = box.getFeatures(type="FeaturePlanar")
inspire.core.geometry.offset(featFace, value=3.0)
inspire.core.geometry.offset(box, value=0.2)
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]) –
value (float) – Desired offset distance. Negative value means inward direction.
symmetric (bool) – If True, offsets symmetrically on both sides of the part surface.
Example
from hwx import inspire
# Creating a solid box and applying thicken of value 0.2
model = inspire.newModel()
box = model.createSolidBlock()
inspire.core.geometry.thicken(box, value=0.2)
print("Thicken has been applied to a part")
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
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
# 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:
Example
from hwx import inspire
# Creating a sketch of line segment.
model = inspire.newModel()
s = inspire.core.Sketch()
point1 = s.addPoint(0, 0)
start = s.addPoint(0, 5)
s.addLineSegment(point1, start)
s.realize()
sketch_part = model.getAllChildren(inspire.SketchPart)[0]
features = sketch_part.getFeatures(type=inspire.FeatureLinear)
# Creating a circular pipe.
inspire.core.geometry.createPipe(features, section="CIRCLE",
resultType="NEW_PART", thickness=1, size=5)
print("Circular Pipe has been created for given feature path")
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
from hwx import inspire
# Creating a solid block with a hole in it.
model = inspire.newModel()
box = model.createSolidBlock()
cyl = model.createSolidCylinder(radius=0.03)
part = box.booleanSubtract(cyl)
part.location = (0, 0, 0)
feature = model.getFeatures(type="FeatureCylindrical")[0]
location1 = inspire.math.Matrix44(origin=[0.31, 0.30, 1])
# Moving hole to other location
inspire.geometry.moveFaces(feature, location1)
print("Hole is moved from origin to location1 in solid box")
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
# Creating a model to show intersect tool.
model = inspire.newModel()
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.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
cyl = model.createSolidCylinder()
sph = model.createSolidSphere()
# Replace part with ConcentratedMass
cm1 = box.convertToMass()
# Replace multiple parts with ConcentratedMass
cm2 = inspire.geometry.convertToMass([cyl, sph])
print("Parts have been replaced with concentrated masses : ", cm1, cm2)
inspire.orientView(direction="isometric")
replaceFromFile#
- replaceFromFile(part, filePath)#
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
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
filePath = str(inspire.demo.getDemoFilePath('M01_FourBar.x_b'))
part = inspire.geometry.replaceFromFile(box, filePath)
print("Box is replaced with the file: M01_FourBar.x_b")
inspire.orientView(direction="isometric")
replaceFromPart#
- replaceFromPart(part, toolPart, keepToolPart=False)#
Replace part with tool part.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock(x=2, y=2, z=0.5)
cyl = model.createSolidCylinder()
inspire.geometry.replaceFromPart(box, cyl)
print("Box is replaced with Cylinder")
inspire.orientView(direction="isometric")
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
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
feature = model.getFeatures(type="FeatureLinear")[0]
# Creating a circular pattern of box.
box.circularPattern(axis=feature, angle=60, count=6, symmetry=True)
print("Circular pattern has been created for Box")
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
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock(x=0.01, y=0.01, z=0.08)
feature = model.getFeatures(type="FeaturePlanar")[1]
neutralPlane = model.getFeatures(type="FeaturePlanar")[0]
# Creating a draft in Single direction with 20-degree angle.
feature.draft("SINGLE", neutralPlane, angle1=20)
print("Draft has been created in single direction with 20 degree angle")
inspire.orientView(direction="isometric")
convertBodiesToParts#
- convertBodiesToParts(parts)#
Convert disconnected bodies to parts.
Example
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock()
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")
breakInstance#
- breakInstance(parts)#
Break the instances of a part.
- Parameters:
parts (list[Part]) – Parts for breaking instances.
Example
from hwx import inspire
from hwx.inspire.demo import openDemoFile
model = openDemoFile("BreakInstance.stmod")
inspire.geometry.breakInstance([model.parts[0], model.parts[1]])
print("Break Instance has been applied to both parts.")
inspire.orientView(direction="isometric")
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
from hwx import inspire
# Creating a model to show project and split tool.
model = inspire.newModel()
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.core.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)#
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.
- Returns:
New part created if resultType is NEW_PART.
- Return type:
Part|None
Example
from hwx import inspire
model = inspire.newModel()
rectangle = model.createSheetRectangle()
feat = rectangle.getFeatures(inspire.FeaturePlanar)[0]
feat2 = rectangle.getFeatures(inspire.FeatureLinear)[2]
inspire.geometry.revolve2(feat, feat2, "SINGLE", "NEW_PART", angle1=200)
print("Rectangular sheet has been revolved on linear axis for 200 degree")
inspire.fitView()
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()
box = model.createSolidBlock()
edge = box.getFeatures(type='FeatureLinear')[0]
edge.edgeFillet(radius='60mm')
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')#
Sweep a profile along a path to create a solid or 3D surface.
- Parameters:
profiles (FeatureArea | FeatureCurve) – A face or a closed sketch.
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
- Returns:
New part created if resultType is NEW_PART.
- Return type:
Part|None
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch1.addRegularPolygon((0, 0), (1, 0), 7)
sketch2 = inspire.Sketch("Global Y")
sketch2.addLineSegment((0, -2), (0, 5))
sketch2.realize()
sketch1.realize()
sks = model.sketches
path = sks[0].getFeatures(inspire.core.FeatureCurve)
profile = sks[1].getFeatures(inspire.core.FeatureArea)
inspire.geometry.sweep(profile, path, pathDirection="BOTH", twistType="NO_OF_TURNS",
twistTurns=1, twistTurnsDir2=2, resultType="NEW_PART")
print("Sweep has been created in both direction of profile.")
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:
Example
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock()
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()
path = box.getFeatures(type=inspire.FeatureCurve)[0]
# Creating a box pattern along the path.
box.patternAlongPath(path=path, count=3, spacing=1)
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)#
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.
- Returns:
New part created if resultType is NEW_PART.
- Return type:
Part|None
Example
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock(z=2)
feature = model.getFeatures(type=inspire.FeaturePlanar)[0]
inspire.geometry.Plane(feature, "OFFSET", offset=0.05)
systems = model.getAllChildren(type=inspire.geometry.Plane)[-1]
sketch1 = inspire.Sketch()
sketch3 = inspire.Sketch(systems)
sketch1.addRegularPolygon((0, 0), (1, 0), 7)
sketch3.addRegularPolygon((0, 0), (1, 1), 7)
sketch2 = inspire.Sketch("Global Y")
sketch2.addLineSegment((0, -3), (0, 1))
sketch2.realize()
sketch1.realize()
sketch3.realize()
sks = model.sketches
path = sks[0].getFeatures(inspire.core.FeatureCurve)
profile1 = sks[1].getFeatures(inspire.core.FeatureArea)[0]
profile2 = sks[2].getFeatures(inspire.core.FeatureArea)[0]
systems.destroy()
model.parts[0].destroy()
inspire.geometry.multiSweep([profile1, profile2], path, resultType="NEW_PART")
print("Multi Sweep has been created with profile1 and profile2.")
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)#
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.
- Returns:
New part created if resultType is NEW_PART.
- Return type:
Part|None
Example
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock(z=2)
feature = model.getFeatures(type=inspire.FeaturePlanar)[0]
inspire.geometry.Plane(feature, "OFFSET", offset=0.05)
systems = model.getAllChildren(type=inspire.geometry.Plane)[-1]
sketch1 = inspire.Sketch()
sketch3 = inspire.Sketch(systems)
sketch1.addRegularPolygon((0, 0), (1, 0), 7)
sketch3.addRegularPolygon((0, 0), (1, 1), 7)
sketch2 = inspire.Sketch("Global Y")
sketch2.addLineSegment((0, -3), (0, 1))
sketch2.realize()
sketch1.realize()
sketch3.realize()
sks = model.sketches
path = sks[0].getFeatures(inspire.core.FeatureCurve)
profile1 = sks[1].getFeatures(inspire.core.FeatureArea)[0]
profile2 = sks[2].getFeatures(inspire.core.FeatureArea)[0]
systems.destroy()
model.parts[0].destroy()
inspire.geometry.loft([profile1, profile2], resultType="NEW_PART")
print("Loft has been created with profile1 and profile2.")
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:
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch1.addCircleCenterRadius((0, 0), 7)
sketch1.realize()
sks = model.sketches
profile = sks[0].getFeatures(inspire.core.FeatureCircular)[0]
inspire.geometry.helixCurve(profile, startAngle=30)
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:
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch1.addCircleCenterRadius((0, 0), 7)
sketch1.realize()
sks = model.sketches
profile = sks[0].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:
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch1.addLineSegment((0, 0), (0, 1))
sketch1.realize()
sks = model.sketches
curve = sks[0].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:
Example
from hwx import inspire
from hwx.common import math
inspire.newModel()
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:
Example
from hwx import inspire
model = inspire.newModel()
model.createSolidBlock()
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:
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch1.addLineSegment((0, 0), (0, 0.5))
sketch1.realize()
sks = model.sketches
curve = sks[0].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()
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.
Example
from hwx import inspire
model = inspire.newModel()
sketch1 = inspire.Sketch()
sketch2 = inspire.Sketch()
sketch1.addLineSegment((0, -1), (0, 1))
sketch2.addLineSegment((-1, 0), (1, 0))
sketch1.realize()
sketch2.realize()
sks = model.sketches
inspire.geometry.extract(sks[0].getFeatures(inspire.core.FeatureLinear)[0])
inspire.geometry.extract(sks[1].getFeatures(inspire.core.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')#
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
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
featPlane = box.getFeatures(type="FeaturePlanar")[0]
featPlane.shell(thickness=0.01)
sketch1 = inspire.Sketch("Global Y")
sketch1.addLineSegment((0.2, -0.5), (0, -0.5))
sketch1.realize()
sks = model.sketches
profile = sks[0]
inspire.geometry.rib(profile, box, draftAngle=30)
inspire.fitView()
print("Rib has been created in the shell.")
inspire.orientView(direction="isometric")
patch2#
- patch2(features, internalCurves=[], globalContinuity='POSITION', mergeResult=True)#
New Patch tool - Creates patches to fill in specified missing surfaces.
- Parameters:
- Returns:
New parts created.
- Return type:
list[Part]
Example
from hwx import inspire
model = inspire.newModel()
s = inspire.core.Sketch()
s.addRectangle2Vertex((0, 0), (2, 2))
s.realize()
sketch_part = model.getAllChildren('SketchPart')[0]
inspire.geometry.extrude(sketch_part.getFeatures(type=inspire.FeatureArea),
"SINGLE", "COMBINE", extrudeTo1=0.5, extrudeAsSolid=False)
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([f1, f2, f3, f4], globalContinuity="TANGENT",
mergeResult=False)
print("Patch2 is created on a rectangular edges ")
inspire.orientView(direction="isometric")
deleteFaces2#
- deleteFaces2(features)#
New delete faces which deletes the specified faces from the part.
- Parameters:
features (list[Feature]) – Features to be removed.
Example
from hwx import inspire
model = inspire.newModel()
box = model.createSolidBlock()
featPlanar = box.getFeatures(type='FeaturePlanar')[2]
featPlanar.deleteFaces2()
print("
- Deleted a planar face from the part “)
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)#
Deform parts within a specified region.
- Parameters:
parts (list[Part]) – Parts to be deformed.
deformType (str) – Deform Type. - TWIST - BEND - TAPER - SHEAR - STRETCH
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.
- Returns:
New parts created.
- Return type:
list[Part]
Example
from hwx import inspire
model = inspire.newModel()
block = model.createSolidBlock()
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()
sketch1 = inspire.Sketch()
sketch1.addLineSegment((0, 0), (0, 0.5))
sketch1.realize()
sks = model.sketches
curve = sks[0].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.
Example
from hwx import inspire
model = inspire.newModel()
block1 = model.createSolidBlock()
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.
Example
from hwx import inspire
model = inspire.newModel()
block1 = model.createSolidBlock()
block2 = model.createSolidBlock()
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")