EnforcedDisplacement (hwx.inspire)#

class EnforcedDisplacement(features, location=None, direction=None, magnitude=0.001, name='', isRemote=False, **kwds)#

Bases: BoundaryCondition

Create enforced displacement on supplied features.

Attribute Table#

Name

Type

connectionType

Enum

magnitude

Double

Method Table#

Name

Description

updatePosition (self, m44)

Update the position by multiplying input M44 matrix.

Example

from hwx import inspire
# Start with an empty model
model = inspire.newModel()
# Alternatively, you can get an existing model
# model = inspire.getModel()
# Create a solid block
box = model.createSolidBlock(x=1, y=1, z=0.1)
# Get a planar feature from the box (using the first available face)
planarFeature = box.getFeatures(type='FeaturePlanar')[0]
enforcedDisp = inspire.EnforcedDisplacement(
  planarFeature, location=[1.0, 1.0, 1.0], magnitude=0.001, loadCase='current'
)
# show some properties
print("Some Displacement Contraint properties:")
print("Location: " + str(enforcedDisp.location))
print("Direction: " + str(enforcedDisp.direction))

# modify some properties
enforcedDisp.location = planarFeature.location
enforcedDisp.direction = [0.0, 0.0, -1.0]

inspire.orientView(direction="front")
inspire.fitView()

# show modified properties
print("Displacement Contraint properties after modification:")
print("Location: " + str(enforcedDisp.location))
print("Direction: " + str(enforcedDisp.direction))

# how to make the enforced displacement parametric
# Add a model variable for enforced displacement magnitude
model.variables.add(name="enforcedDispMagnitude", type='Length', expression=0.001)
# Assign the variable to the enforced displacement magnitude
enforcedDisp.magnitude = "enforcedDispMagnitude"

# How to modify the enforced displacement magnitude variable
model.variables.update(name="enforcedDispMagnitude", expression=0.002)
# How to change the enforced displacement magnitude with a string with units
enforcedDisp.magnitude = "0.002 m"
# How to query the existing enforced displacements from the model
existing_enforced_displacements = model.getChildren(type='EnforcedDisplacement')
print("Existing enforced displacements in the model:")
for disp in existing_enforced_displacements:
    print(f"	Enforced Displacement on {disp.features[0].name}, "
    f"magnitude: {disp.magnitude}, direction: {disp.direction}, "
    f"location: {disp.location}")
# How to query the enforced displacement by its name   

enforced_disp_by_name = model.getChild(type='EnforcedDisplacement', name='Enforced Displacement 1')
if enforced_disp_by_name:
    print("Queried enforced displacement by name:")
    print(f"	Enforced Displacement on {enforced_disp_by_name.features[0].name}, " 
    f"magnitude: {enforced_disp_by_name.magnitude}, "
    f"direction: {enforced_disp_by_name.direction}, "
    f"location: {enforced_disp_by_name.location}")

# Update the view to see the changes

inspire.orientView(direction="isometric")
property magnitude#

The magnitude of displacement.

property connectionType#

The type of the connection. Valid choices are:

  • Rigid

  • Flexible

updatePosition(m44)#

Update the position by multiplying input M44 matrix.