Cavities (hwx.inspire.Holes)#

class Cavities(populate=True, **kwds)#

Bases: Holes

A list of hollows in the model

Useful for plugging cavities. Unlike Holes that are used for regular shaped (cylindrical, slotted) which are used in defining Part connections, like Motors and Actuators, Cavities can be irregular shaped.

Method Table#

Name

Description

cavities (self)

Returns a list of hollows in the model

plugAll (self)

Create and return parts that fills the cavities

populate (self, minsize=None, maxsize=None, parts=None)

Get the cavities for the specified parts or the entire model

Example

from hwx import inspire

def createBlockWithHole(radius=0.3, location=(0, 0, 0)):
   model = inspire.getModel()
   box = model.createSolidBlock()
   cyl = model.createSolidCylinder(radius=radius)
   part = box.booleanSubtract(cyl)
   part.location = location
   return part

model = inspire.newModel()
createBlockWithHole()
createBlockWithHole(location=(1.5, 0, 0))

inspire.fitView()

# Query all the cavities from the model
cavities = model.cavities
print("Cavities :", cavities)

# Get features from a cavity
cavity = cavities[0]
print("Features: ", cavity.features)
inspire.highlight(cavity)

# Plug a cavity
# Observe a new part is created in the model browser which plugs the hole
cavity.plug()

# Plug all the cavities
# Observe a new part is created in the model browser which plugs the hole
cavities.plugAll()
populate(minsize=None, maxsize=None, parts=None)#

Get the cavities for the specified parts or the entire model of parts were not specified

Parameters:
  • minsize (float) – Get the holes with a size larger than minsize

  • maxsize (float) – Get the holes with a size smaller than maxsize

  • parts (Part, list[Parts]) – Get the holes for these parts

cavities()#

Returns a list of hollows in the model

plugAll()#

Create and return parts that fills the cavities