Force (hwx.inspire)#
- class Force(features, location=None, direction=None, magnitude=None, isRemote=False, **kwds)#
Bases:
BoundaryCondition
A force is a push or a pull in a particular direction on a part, and is a type of load.
Forces can be applied to a point, edge, face, or hole center.
Once applied, distributed forces on certain types of features can be converted to bearing forces or traction forces.
Attribute Table# Name
Type
icon
str
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 block = model.createSolidBlock(x=0.5, y=0.5, z=0.5) # apply force on a face feature area =model.getFeatures(type='FeatureArea')[0] forceOnFace = inspire.Force(features=area, magnitude=10.0, loadCase='current') # apply force on a point feature point = block.getFeatures(type='FeaturePoint')[0] forceOnPoint = inspire.Force(features=point,direction=[1, -1, -1], magnitude=10.0, loadCase='current' ) # apply force on a edge feature edge = model.getFeatures(type='FeatureCurve')[0] forceOnEdge = inspire.Force(features =edge, magnitude='20 N' , loadCase='current') print("Some forces values:") print(" Force on face, direction:", forceOnFace.direction) print(" Force on point, magnitude:", forceOnPoint.magnitude) print(" Force on edge, location:", forceOnEdge.location) print("Forces values after modification:") print(" Force on face, direction:", forceOnFace.direction) print(" Force on point, magnitude:", forceOnPoint.magnitude) print(" Force on edge, location:", forceOnEdge.location) # How to convert a force applied on a face to a traction force forceOnFace.traction = True print("Force on face is now a traction force:", forceOnFace.traction) # Create two cylinders cyl1 = model.createSolidCylinder(location=(5, 5, 0), radius=1, height=1) cyl2 = model.createSolidCylinder(location=(5, 5, 0), radius=0.7, height=1) # Boolean subtract cyl2 from cyl1 to form a hollow cylinder hollow_cylinder = inspire.geometry.booleanSubtract(targets=cyl1, tools=cyl2, keepTools=False) # Filter out the cylindrical face features from the hollow cylinder cylSurfaces = hollow_cylinder.getFeatures(type='FeatureCylindrical') face = cylSurfaces[1] forceOnCylindricalFace = inspire.Force( features=face, magnitude=10.0, # numeric force magnitude (default unit N) loadCase='current' ) # How to make a force applied on a cylindrical face to a bearing force # Set the force type to Bearing # bearing force is a type of force that acts only a cylindrical face forceOnCylindricalFace.bearing = True # Alternatively, you can set the force type to traction # Force on a cylindrical face can either be set to traction or bearing. # traction force is a type of force that acts only on a FeatureArea feature # Set the force to traction forceOnCylindricalFace.traction = True # How to make force magnitude parametric # Add a model variable for force magnitude model.variables.add(name="forceMagnitude", type='Force', expression=10) # Assign the variable to the force load magnitude forceOnFace.magnitude = "forceMagnitude" # How to modify the force magnitude variable model.variables.update(name="forceMagnitude", expression=20) # How to change the force magnitude with a string with units forceOnFace.magnitude = "20 N" # How to query the existing forces from the model existing_forces = model.getChildren(type='Force') print("Existing forces in the model:") for force in existing_forces: print(f" Force on {force.features[0].name}, magnitude: {force.magnitude}, " f"direction: {force.direction}, bearing: {force.bearing}, traction: {force.traction}") # How to query the force by its name force_by_name = model.getChild(type='Force', name='Force 1') if force_by_name: print("Queried force by name:") print(f" Force on {force_by_name.features[0].name}, magnitude: {force_by_name.magnitude}, " f"direction: {force_by_name.direction}, bearing: {force_by_name.bearing}, traction: {force_by_name.traction}") inspire.orientView(direction="isometric")
- property magnitude#
The magnitude of the force.
Example
from hwx import inspire # Start with an empty model model = inspire.newModel() # Create two cylinders cyl1 = model.createSolidCylinder(location=(5, 5, 0), radius=1, height=1) cyl2 = model.createSolidCylinder(location=(5, 5, 0), radius=0.7, height=1) # Boolean subtract cyl2 from cyl1 to form a hollow cylinder hollow_cylinder = inspire.geometry.booleanSubtract(targets=cyl1, tools=cyl2, keepTools=False) # Filter out the cylindrical face features from the hollow cylinder cylSurfaces = hollow_cylinder.getFeatures(type='FeatureCylindrical') face = cylSurfaces[1] # Apply a force load on the cylindrical face feature using a numeric magnitude forceOnFace = inspire.Force( features=face, magnitude=10.0, # numeric force magnitude (default unit N) loadCase='current' ) # Display the initial Force magnitude print("Initial force magnitude (numeric):", forceOnFace.magnitude) # --------------------------------------------------------- # Make force magnitude parametric using a model variable # Add a model variable for force magnitude. The default unit for force is N. model.variables.add(name="forceMagnitude", type='Force', expression=10) # Assign the variable to the force load magnitude forceOnFace.magnitude = "forceMagnitude" print("Force magnitude after assigning model variable:", forceOnFace.magnitude) # Modify the force magnitude variable model.variables.update(name="forceMagnitude", expression=20) print("Force magnitude after updating model variable:", forceOnFace.magnitude) # --------------------------------------------------------- # Change the force magnitude using a string with units forceOnFace.magnitude = "20 N" print("Force magnitude after setting a string with units:", forceOnFace.magnitude) # Update the view to reflect modifications inspire.orientView(direction="top") inspire.fitView() # Display all existing forces in the model for verification existing_forces = model.getChildren(type='Force') print("Existing forces in the model:") for force in existing_forces: print(f" Force on {force.features[0].name}, magnitude: {force.magnitude}, " f"direction: {force.direction}") # Optionally, query a force load by its name force_by_name = model.getChild(type='Force', name='Force 1') if force_by_name: print("Queried force by name:") print(f" Force on {force_by_name.features[0].name}, magnitude: {force_by_name.magnitude}, " f"direction: {force_by_name.direction}")
- updatePosition(m44)#
Update the position by multiplying input M44 matrix.