RigidGroup (hwx.inspire)#

class RigidGroup(**kwds)#

Bases: Config

Group of parts which don’t move relative to each other and are realized to motion as a single rigid body.

Rigid groups are mutually exclusive meaning a part can’t be in two at the same time.

Attribute Table#

Name

Type

cg

property

ground

Bool

icon

str

ip

Inertia

location

property

mass

Double

parts

List

position

property

active

Bool

history

History

model

Model

name

String

namespace

str

parent

property

units

UnitsManager

visible

Bool

Method Table#

Name

Description

add (self, parts)

Adds part or parts to the rigid group.

create (**kwds)

Creates and returns a Rigid Group.

destroy (self)

Delete the object removing it from the model.

discard (self, parts)

Remove part or parts from the rigid group.

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

Returns a list of all children that matches the specified type.

getChild (self, name=None, recursive=False, **kwds)

Returns the child of the object which matches the specified unique name.

getChildren (self, type=None, recursive=False, sorted=False, **kwds)

Returns a list of children that is of the specified type.

getClass (className)

Returns the class of the object.

getDependents (self, recursive=False, **kwds)

Get objects that reference this object through a Reference attribute.

getReferences (self, recursive=False, **kwds)

Get objects this object references through a Reference attribute.

isa (self, type=None, filter=None, name=None, wildcard=None, **kwds)

Determines if the object matches the specified settings or not.

modelPositions (self)

Forces all objects to return the original model positions instead of the

remove (self, parts)

Remove part or parts from the rigid group.

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)
sphere = model.createSolidSphere(radius=.5, position=math.Matrix44(origin=(-2, 0, 0)))
rigidGroup = inspire.RigidGroup()
rigidGroup.add([block, cyl])

print("Rigid group contains: " + str(len(rigidGroup.parts)) + " parts.")
print("Rigid group position is: " + str(rigidGroup.position.origin))
print("Rigid group mass is: " + str(rigidGroup.mass))
print("Rigid group center of gravity is: " + str(rigidGroup.cg))

# add another part and see how properties change
rigidGroup.add([sphere])
print("")
print("Rigid group contains: " + str(len(rigidGroup.parts)) + " parts.")
print("Rigid group position is: " + str(rigidGroup.position.origin))
print("Rigid group mass is: " + str(rigidGroup.mass))
print("Rigid group center of gravity is: " + str(rigidGroup.cg))

inspire.fitView()
property parts#

List of parts in the rigid group.

property ground#

Returns True, if any of the rigid group parts is grounded.

property mass#

Returns the combined mass of all the parts of the rigid group.

add(parts)#

Adds part or parts to the rigid group.

It raises a ValueError if the part already exists in a different rigid group.

Parameters:

parts (list[Part]) – List of part or parts to add into rigid group.

remove(parts)#

Remove part or parts from the rigid group.

It raises a ValueError if the part does not exists in this rigid group.

Parameters:

parts (list[Part]) – List of part or parts to remove from the rigid group.

discard(parts)#

Remove part or parts from the rigid group.

Parameters:

parts (list[Part]) – List of part or parts to remove from the rigid group.

property position#

Returns the position of the center of gravity as a Matrix44.

property cg#

Returns the center of gravity point of the rigid group.

property active#

Returns or sets the object activeness.

Setting this on or off sets all children. Setting to True sets all the parents active too.

destroy()#

Delete the object removing it from the model.

The object may come back due to an undo/redo.

getAllChildren(type=None, **kwds)#

Returns a list of all children that matches the specified type.

Parameters:
  • type (list[Named]) – Filter to use to get the children based on object type.

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

Returns:

The list of children that satisfy the supplied filters.

Return type:

list[Union[Part, Motor, BoundaryCondition, …]]

getAttribute(name)#

Returns the Attribute off the class, not the value.

Parameters:

name (str) – Attribute name to find its class.

getChild(name=None, recursive=False, **kwds)#

Returns the child of the object which matches the specified unique name.

Parameters:
  • name (str) – The name of the child object.

  • recursive (bool) – Search all descendents.

  • **kwds – Additional keyword arguments to match attributes of the object.

Returns:

The child object which satisfies the specified filters.

Return type:

Named

getChildren(type=None, recursive=False, sorted=False, **kwds)#

Returns a list of children that is of the specified type.

Parameters:
  • type (Type[Named]) – Filter objects by class.

  • recursive (bool) – True to get all descendent Parts and Assemblies.

  • sorted (bool) – Sort the children base on id.

Returns:

list[Named]

getDependents(recursive=False, **kwds)#

Get objects that reference this object through a Reference attribute.

Parameters:
  • recursive (bool) –

  • **kwds – Filter objects using isa.

Returns:

set[Named]

getGuiValue(attr, **kwds)#

Get value formatted to be shown in the gui

Parameters:

attr (str) – Attribute name to gets its gui value.

Returns:

Returns a string of the value with its gui units, like “5 mm/s”.

Return type:

str

getReferences(recursive=False, **kwds)#

Get objects this object references through a Reference attribute.

Parameters:
  • recursive (bool) –

  • **kwds – Filter objects using isa.

Returns:

set[Named]

getValue(attr)#

Return the attribute value for passed attribute name.

Parameters:

attr (String) – Attribute name to gets its value.

Returns:

Returns the attribute value

Return type:

str

isa(type=None, filter=None, name=None, wildcard=None, **kwds)#

Determines if the object matches the specified settings or not.

Parameters:
  • type (Union[Part, Assembly, Contact..]) – The type of the object.

  • filter (method) – Return value of specified callback method.

  • name (str) – Name that matches exactly with object name.

  • wildcard (str) – A pattern to match exactly with the object name.

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

Returns:

True, if a match is found, otherwise False.

Return type:

bool

modelPositions()#

Forces all objects to return the original model positions instead of the current analysis positions.

Useful when defining draw methods on GeneralObjects where behaviour is different while animating.

property name#

Returns or sets the name of the object.

It can be any text string, including spaces, although it’s best to avoid using the following characters: “ ‘ * ? and $.

While these characters are allowed, they could create difficulties when you export the model to other applications.

property parent#

Returns the parent of this entity.

Type:

Assembly

setValue(attr, value)#

Alias for setattr (attr, value) :param attr: Attribute name to sets its value. :type attr: str :param value: Attribute value to set . :type value: str

setValues(**kwds)#

Sets passed name/value pairs.

Values are set in a standard order (the order the attribute is defined on the class) which is required in certain cases when an attribute’s setter expects another attribute to have already been set. For example, setting a reference before a location that is wrt it.

Parameters:

**kwds – Set attributes in one go.

property visible#

Determines whether the object is visible in the graphics window.

Setting this on or off sets all children. Setting to True sets all the parents visible too.

wasValueSet(attr)#

Check if attribute was set

Parameters:

attr (str) – Attribute name to check it value set or not

Returns:

True, if value was set else false.

Return type:

bool