Constraint (hwx.inspire)#

class Constraint(features, position=None, isRemote=False, **kwds)#

Bases: BoundaryCondition

A constraint is used to hold a part so it doesn’t displace when loads are applied to it.

You can apply a constraint to a single point on the model, to an edge or a face, or at the center of a hole.

Attribute Table#

Name

Type

detached

property

direction

Direction

dofs

Attribute

fixed

property

hinge

property

icon

str

inahole

property

position

property

sliding

property

Method Table#

Name

Description

applyToCylindricalHoleCenter (self)

Sets support to act in a single direction across a cylindrical hole center.

applyToFace (self)

Sets support to act in a single direction across the extent of a face.

applyToPoint (self)

Sets support to act in a single direction at a point

setDefaultDOFs (self)

Sets supports DOFS to default.

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

box = model.createSolidBlock(x=1, y=1, z=1)
# Create a cylindrical hole in the block
# The hole is a solid cylinder that is subtracted from the block
cyl = model.createSolidCylinder(radius=0.3)
hollow_part = inspire.geometry.booleanSubtract(targets=box, tools=cyl, keepTools=False)

cyl_feature = hollow_part.getFeatures('FeatureCylindrical')[0]
support1 = inspire.Constraint(cyl_feature, loadCase='current')

planar_feature = hollow_part.getFeatures('FeaturePlanar')[0]
support2 = inspire.Constraint(planar_feature, loadCase='current')

# How to get the degrees of freedom (DOFs) of a constraint
print("Degrees of freedom for support2:", support2.dofs)

# How to change the degrees of freedom (DOFs) of a constraint
# That applied to a cylindrical feature
support1.dofs = [] # This will remove all DOFs
support1.dofs = ['rz'] # This will set the DOFs to only rotation around the hole axis
support1.dofs = [ 'tz'] # This will set the DOFs to only translation along hole axis
support1.dofs = ['rz', 'tz'] # This will set the DOFs to rotation  and translation around hole axis

# How to change the degrees of freedom (DOFs) of a constraint that applied to a planar feature or
# an FeatureCurve feature or a FeaturePoint.
support2.dofs =  ['rx', 'ry', 'rz'] # The default DOFs for the planar feature
support2.dofs = ['rx', 'ry', 'rz', 'tx'] # This will set the translation along the x-axis
support2.dofs = ['rx', 'ry', 'rz', 'ty'] # This will set the translation along the y-axis
support2.dofs = ['rx', 'ry', 'rz', 'tx', 'ty'] # This will sset the translation along the x and y axes

# How to set the default degrees of freedom (DOFs) for a constraint
support2.setDefaultDOFs() # this will set the DOFs to the default values 

# How to convert a constraint that applied on a cylindrical center to a surface.
support1.applyToFace() # This will convert the constraint to a surface constraint

# how to convert a constraint that applied on a cylindrical center / centre to a point.
support1.applyToPoint() # This will convert the constraint to a point constraint

# How to apply a constraint to a cylindrical hole center
support1.applyToCylindricalHoleCenter() # This will apply the constraint to the cylindrical hole center

# How to find if a constraint is sliding
print("Is support1 sliding?", support1.sliding)
# How to find if a constraint is in a hole
print("Is support1 in a hole?", support1.inahole)
# How to find if a constraint is a hinge
print("Is support1 a hinge?", support1.hinge)
# How to find if a constraint is fixed
print("Is support1 fixed?", support1.fixed)
# How to find if a constraint is detached
print("Is support1 detached?", support1.detached)
# How to find the direction of a constraint
print("Direction of support1:", support1.direction)
# How to find the name of a constraint
print("Name of support1:", support1.name)
# How to find the location of a constraint
print("Location of support1:", support1.location)
# How to find the features of a constraint
print("Features of support1:", support1.features)
# How to find the load case of a constraint
print("Load case of support1:", support1.loadCase)

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

Returns direction vector of the entity.

property inahole#

Determines if the constraint is applied on a hole or not.

property detached#

Determines if the constraint is defined on a detached location in space.

property dofs#

Returns or sets a list with the unconstrained degrees of freedom.

To set it you can pass a list e.g [“rx”, “ry”, “rz”], a space seperated string “rx ry rz” or one of the following choices “fixed”, “sliding”, “hinged”.

applyToPoint()#

Sets support to act in a single direction at a point

Example

from hwx import inspire

# Start with a new model
model = inspire.newModel()

# Create a solid block
box = model.createSolidBlock(x=1, y=1, z=1)

# Create a cylindrical hole in the block by subtracting a cylinder
cyl = model.createSolidCylinder(radius=0.3)
hollow_part = inspire.geometry.booleanSubtract(targets=box, tools=cyl, keepTools=False)

# Get a planar feature from the hollow part (for example, one face of the block)
feature = hollow_part.getFeatures('FeatureCylindrical')[0]

# Create a constraint on the planar feature
support = inspire.Constraint(feature, loadCase='current')

# Use applyToPoint() to constrain the feature at a specific point location
support.applyToPoint()

# Display details about the constraint to verify its application
print("Constraint applied to a point:")
print("	Name:", support.name)
print("	Location:", support.location)
print("	Features involved:", support.features)
print("	Load case:", support.loadCase)

# Update the view to see the changes
inspire.orientView(direction="isometric")
applyToFace()#

Sets support to act in a single direction across the extent of a face.

Example

from hwx import inspire

# Start with a new model
model = inspire.newModel()

# Create a solid block
box = model.createSolidBlock(x=1, y=1, z=1)

# Create a cylindrical hole in the block by subtracting a cylinder
cyl = model.createSolidCylinder(radius=0.3)
hollow_part = inspire.geometry.booleanSubtract(targets=box, tools=cyl, keepTools=False)

# Get a cylindrical feature (face) from the hollow part
cyl_feature = hollow_part.getFeatures('FeatureCylindrical')[0]

# Create a constraint on the cylindrical feature
support = inspire.Constraint(cyl_feature, loadCase='current')

# Apply the constraint so it acts on the face of the feature
support.applyToFace()

# Display details about the constraint to verify its application
print("Constraint applied to face:")
print("	Name:", support.name)
print("	Location:", support.location)
print("	Features involved:", support.features)
print("	Load case:", support.loadCase)

# Update the view to see the changes
inspire.orientView(direction="isometric")
inspire.fitView()
applyToCylindricalHoleCenter()#

Sets support to act in a single direction across a cylindrical hole center.

Example

from hwx import inspire

# Start with a new model
model = inspire.newModel()

# Create a solid block
box = model.createSolidBlock(x=1, y=1, z=1)

# Create a cylindrical hole by subtracting a cylinder from the block
cyl = model.createSolidCylinder(radius=0.3)
hollow_part = inspire.geometry.booleanSubtract(targets=box, tools=cyl, keepTools=False)

# Get a cylindrical feature (the hole) from the resulting part
cyl_feature = hollow_part.getFeatures('FeatureCylindrical')[0]

# Create a constraint on the cylindrical feature
support = inspire.Constraint(cyl_feature, loadCase='current')

# By default, the constraint may be applied to the face or center.
# Use applyToCylindricalHoleCenter() to specifically constrain the center of the cylindrical hole.
support.applyToCylindricalHoleCenter()

# Display details about the constraint to verify
print("Constraint applied to cylindrical hole center:")
print("	Name:", support.name)
print("	Location:", support.location)
print("	Features:", support.features)
print("	Load case:", support.loadCase)

# Update the view to see changes in the model display.
inspire.orientView(direction="isometric")
setDefaultDOFs()#

Sets supports DOFS to default.

Default for supports in a hole or two dimensional parts are all constrained, while for the rest it’s rotational DOFs constrained.

Example

from hwx import inspire

# Start with a new model
model = inspire.newModel()

# Create a solid block
box = model.createSolidBlock(x=1, y=1, z=1)

# Create a cylindrical hole by subtracting a cylinder from the block
cyl = model.createSolidCylinder(radius=0.3)
hollow_part = inspire.geometry.booleanSubtract(targets=box, tools=cyl, keepTools=False)

# Retrieve a planar feature from the hollow part
planar_feature = hollow_part.getFeatures('FeaturePlanar')[0]

# Create a constraint on the planar feature with a custom set of DOFs
support = inspire.Constraint(planar_feature, loadCase='current')
support.dofs = ['rx', 'ry', 'rz','tx']  # Custom DOFs

# Print the current DOFs
print("Custom DOFs for support:", support.dofs)

# Reset to default DOFs for the constraint
support.setDefaultDOFs()

# Print the DOFs after resetting to defaults
print("DOFs after resetting to defaults:", support.dofs)

# Update the view to see the changes
inspire.orientView(direction="isometric")
property fixed#

Returns True if support is fixed, applies to holes or surfaces.

When the property is set to False then the support dofs get set to default.

For surface supports it means that all translational DOFs are constrained. For supports in holes it means that all DOFs are constrained.

property sliding#

Returns True if support is sliding, applies to holes or surfaces.

When the property is set to False then the support dofs get set to default.

A sliding support enforces zero displacement in directions normal to the surface direction. Displacements tangent to the surface are unconstrained.

property hinge#

Returns True if support is hinge, applies to holes only.

When the property is set to False then the support dofs get set to default.

Hinge supports allow a part to freely rotate about the center-line of a cylindrical face but constrains movement in both the radial and axial directions. Hinge supports can only be applied to full or partial cylindrical faces.

property position#

Returns and sets the position of the constraint as a M44 matrix.

updatePosition(m44)#

Update the position by multiplying input M44 matrix.