Part (hwx.inspire)#

class Part(parent=None, **kwds)#

Bases: PartOccurrence

A geometric object made up of any combination of solids, surfaces, and curves (Features). It can also be a mesh.

Attribute Table#

Name

Type

autoCalcMotionContactResolution

Bool

designSpace

Bool

dimensions

property

flexible

Bool

holes

property

ignoreFlexibility

Bool

maxFreq

Double

minGap

Double

modeType

Enum

motionContactResolution

Enum

numModes

Int

orderType

Enum

rigid

property

rigidGroup

Reference

sheetThickness

Double

strainCalculation

Bool

stressCalculation

Bool

Method Table#

Name

Description

booleanCombine (target, tools=None)

Combines the specified parts.

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

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

booleanSubtract (targets, tools, keepTools=False)

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

breakInstance (parts)

Break the instances of a part.

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.

convertBodiesToParts (parts)

Convert disconnected bodies to parts.

convertToMass (parts, parent=None)

Replace Parts to concentrated mass.

convertToTriangleMesh (parts)

Convert Parts to triangle mesh.

findMinimumSeparation (self, other)

Find closest points between two parts

getClosestPoint (self, point)

Get closest point on part from passed point

getRayIntersections (self, origin, direction)

Find list of points where ray intersects part

identifyShape (self)

Attempts to identify the part geometry as a known shape.

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

Intersect tool that deletes excess faces, edges and vertices.

intersectCurve (targets, tools, combineCurves=False)

Split intersecting curves or wire bodies into several curves.

intersects (self, other)

Finds whether the two parts intersect.

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.

makeSmooth (parts=None, maintainVolume=True, intensity=0.5, iterations=40)

Smoothens parts from the selected parts with passed params.

midSurface (part, surfaceOptions=’Mid’)

Extracts a midsurface or side faces from thin solids, and determine where

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

Mirrors part across a symmetry plane.

move (part, position)

Translates and/or rotates a part.

offset (input, value, newPart=False)

Offset surfaces or parts.

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.

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

removeIsland (part)

Finds small disconnected regions of a mesh part and delete them.

removeSmooth (parts=None)

replaceFromFile (part, filePath)

Replace part with the contents of a file.

replaceFromPart (part, toolPart, keepToolPart=False)

Replace part with tool part.

rib (sketch, targetPart, ribThickness=0.01, flipMaterialDirection=False, offsetDirection=’MID’, ribDirection=’NORMAL’, draftAngle=0, reverseDraftDirection=False)

Extrude rib geometry from a sketch to stiffen your model.

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

Rotates a part around the specified axis.

scale (parts, value=1.1)

Resizes the part to the specified scale value.

shrinkWrap (parts=None, voxelSize=-1, merge=True, sharpen=False)

Creates a new part/parts from the selected parts with a single isosurface

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

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

thicken (parts, value, symmetric=True)

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

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

Translates by the specified distance.

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

Example

from hwx import inspire
from hwx.common import math

model = inspire.newModel()
block = model.createSolidBlock(position=math.Matrix44(origin=(-2, 0, 0)))
cyl = model.createSolidCylinder(radius=.5, position=math.Matrix44(zv=(1, 1, 0)))
sphere = model.createSolidSphere(radius=.5, position=math.Matrix44(origin=(2, 0, 0)))
inspire.orientView(direction="isometric")

print("block mass:", block.mass.guiValue)
print("cyl mass:", cyl.mass.guiValue)
print("sphere mass:", sphere.mass.guiValue)
property flexible#

Makes the part flexible, if set to True.

property rigid#

Determines if the part is a rigid or not.

property ignoreFlexibility#

Allows the part to ignore flexibility.

class ModeType(value)#

Bases: Enum

An enumeration.

Attribute Table#

Name

Type

MaxFreq

ModeType

NumModes

ModeType

property modeType#

How normal modes are defined.

property maxFreq#

Upper bound frequency for the eigenvalue analysis of the flexible part.

property numModes#

Specifies the number of modes of the part.

property stressCalculation#

Determines whether to calculate stress or not.

property strainCalculation#

Determines whether to calculate the strain or not.

class OrderType(value)#

Bases: Enum

An enumeration.

Attribute Table#

Name

Type

Accurate

OrderType

Faster

OrderType

property orderType#

Order of elements for flexbody mesh.

property designSpace#

Determines whether the part is a design space.

A part must be designated as a design space if we intend to optimize it.

property autoCalcMotionContactResolution#

Returns or sets the motion contact fidelity properties from the part.

property motionContactResolution#

The resolution of the motion contact. It can be:

  • “verylow”

  • “low”

  • “medium”

  • “high”

  • “veryhigh”

property rigidGroup#

The rigid group this object belongs to.

property dimensions#

Number of dimensions utilized by the part’s features:

  • 0 - a point

  • 1 - a line

  • 2 - a sheet

  • 3 - a 3 dimensional part

property sheetThickness#

Thickness of the 2D part used in volume calculation.

property holes#

Returns a list of holes for this part.

Unlike the model.holes property which returns a list that has extra information like aligned and singular, this returns a standard Python list.

identifyShape()#

Attempts to identify the part geometry as a known shape.

The shapes can be:

  • Box

  • Ellipsoid

  • Sphere

  • Cylinder

  • frustum

  • axi-symmetric gear

  • rack

Returns:

The identified shape.

Return type:

Box,Ellipsoid,Sphere..

intersects(other)#

Finds whether the two parts intersect.

Parameters:

other (Part) – The 2nd part.

Returns:

True if they intersect, False otherwise.

Return type:

bool

findMinimumSeparation(other)#

Find closest points between two parts

Parameters:

other (Part) – The 2nd part.

Returns:

namedtuple(“ClosestPoints”, “point1 point2 distance feature1 feature2”)

booleanCombine(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

booleanIntersect(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

booleanSubtract(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

breakInstance()#

Break the instances of a part.

Parameters:

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

circularPattern(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.

convertBodiesToParts()#

Convert disconnected bodies to parts.

Parameters:

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

Returns:

Newly created parts.

Return type:

list[Part]

convertToMass(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.

convertToTriangleMesh()#

Convert Parts to triangle mesh.

Parameters:

parts (list[Part]) – Parts to be converted in triangle mesh.

getClosestPoint(point)#

Get closest point on part from passed point

getRayIntersections(origin, direction)#

Find list of points where ray intersects part

intersect(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

intersectCurve(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

linearPattern(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.

makeSmooth(maintainVolume=True, intensity=0.5, iterations=40)#

Smoothens parts from the selected parts with passed params.

Parameters:
  • parts (list[Part]) – A list of parts to smooth

  • maintainVolume (bool) – If True part volume is targeted to be preserved. If false smoothening is done more aggressively every iteration

  • intensity (float[0.2, 0.9]) – this control how aggressive the smoothening operation is every iteration.

  • iterations (int) – The number of iterations algorithm does smoothening. Higher number results in smoother mesh

midSurface(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.

mirror(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

move(position)#

Translates and/or rotates a part.

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

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

offset(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

patternAlongPath(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.

projectAndSplit(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.

removeIsland()#

Finds small disconnected regions of a mesh part and delete them.

Parameters:

part (Part) – Part having island.

removeSmooth()#

Removes any existing smoothening from passed parts

Parameters:

parts (list[Part]) – A list of parts to removing smooothing from.

replaceFromFile(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.

replaceFromPart(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.

rib(targetPart, ribThickness=0.01, flipMaterialDirection=False, offsetDirection='MID', ribDirection='NORMAL', draftAngle=0, reverseDraftDirection=False)#

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, veverse the draftAngle direction otherwise not.

rotate(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.

scale(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.

shrinkWrap(voxelSize=-1, merge=True, sharpen=False)#

Creates a new part/parts from the selected parts with a single isosurface

The shrinkwrap is useful when you want to merge optimized results with non-design-space regions.

You would do this so you can fit a single PolyNURBS over the entire model. By default, the selected parts are merged into a single part. This option can be disabled by setting merge to False.

Parameters:
  • parts (list[Part]) – A list of parts to be shrink wrapped.

  • voxelSize (float) – Size of each voxel of the shrink wrapped part. Size value should be in the range 0 to 1 Defaults to -1 to auto compute the voxel dimension of the part.

  • merge (bool) – Merge the shrink wrapped parts into single or multiple parts.

  • sharpen (bool) – If set to True, then sharpen the edges of the new shrink wrapped part.

Returns:

Returns a new shrink wrapped part

Return type:

Part

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

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.

Returns:

The new sliced part created.

Return type:

Part

thicken(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.

translate(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.

trimAndSplit(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.