Assembly (hwx.inspire)#

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

Bases: Occurrence, Primitives

An assembly is a list of parts.

Assemblies can contain subassemblies, allowing you to organize your model hierarchically. Parts and subassemblies within an assembly are positioned in space relative to the parent assembly. If you translate or rotate a parent assembly, its parts and subassemblies move with it.

Assemblies do not have their own properties. Changing properties for an assembly actually applies the change to the individual parts within the assembly down to the lowest level in the hierarchy. Only properties common to all parts in the assembly are shown.

Attribute Table#

Name

Type

assemblies

property

autoColors

list

cg

property

features

property

parts

property

sketches

property

Method Table#

Name

Description

autoColorParts (self)

Automatically assigns different colors to all the parts in the assembly.

destroy (self)

Destroys assemblies from the model.

getCenterOfGravity (self, includeGround=True)

Returns the centre of gravity of the assembly.

getFeature (self, name=None)

Find feature by its __str__/__repr__.

getFeatures (self, type=None, **kwds)

Returns features that matches the specified filters.

getMass (self, includeGround=True)

Returns the mass of the assembly.

save (self, file)

Save the Assembly in the specified file.

Example

from hwx import inspire
from hwx.common import math

model = inspire.newModel()
assem = inspire.Assembly()
block = assem.createSolidBlock(position=math.Matrix44(origin=(-2, 0, 0)))
cyl = assem.createSolidCylinder(radius=.5)
sphere = assem.createSolidSphere(radius=.5, position=math.Matrix44(origin=(2, 0, 0)))
print("origin.y's:", block.position.origin.y, cyl.position.origin.y, sphere.position.origin.y)

# Move all of the above parts together
assem.position = math.Matrix44(origin=(0, 2, 0))
print("origin.y's:", block.position.origin.y, cyl.position.origin.y, sphere.position.origin.y)
inspire.fitView()
property assemblies#

Descendent assemblies.

Type:

list[Assembly]

property parts#

Descendent parts.

Type:

list[Part]

property sketches#

Descendent sketches.

Type:

list[SketchPart]

property features#

Features from all descendent parts.

Type:

list[Feature]

getFeatures(type=None, **kwds)#

Returns features that matches the specified filters.

Parameters:
  • type (Type[Feature]) – The type of feature to return.

  • **kwds – Additional keyword arguments to match other attributes.

Returns:

A list of features that satisfies all the filter criteria.

Return type:

list [Feature]

getFeature(name=None)#

Find feature by its __str__/__repr__.

Parameters:

name (str) –

Returns:

Feature

property cg#

Center of gravity of the assembly including ground parts

Type:

Point

getCenterOfGravity(includeGround=True)#

Returns the centre of gravity of the assembly.

Parameters:

includeGround (bool) – Include ground parts?

Returns:

Point

getMass(includeGround=True)#

Returns the mass of the assembly.

Parameters:

includeGround (bool) – Include ground parts.

Returns:

float

autoColorParts()#

Automatically assigns different colors to all the parts in the assembly.

save(file)#

Save the Assembly in the specified file.

Parameters:

file (str) –

File name and path, where the file needs to be saved. Valid file extensions are:

’.x_b’, ‘.x_t’, ‘.xmt_bin’, ‘.xmt_txt’, ‘.sat’, ‘.sab’, ‘.iges’, ‘.igs’, ‘.stl’, ‘.step’, ‘.stp’, ‘.obj’, ‘.vrml’, ‘.vrl’.

destroy()#

Destroys assemblies from the model.