Mastering Connections in Altair Inspire: Create and Modify Fasteners, Joints with Python APIs
Fasteners
Fasteners connect parts together without allowing movement at the hole location.
Creating Fasteners
When defining fasteners, you can create grounded bolts and grounded screws that act as supports in load cases. A grounded fastener mimics the nut and bolt or screw being fastened to another part that is not available in the model, and appears under Load Cases in the Model Browser instead of under Connectors.
# Example 1 How to open a demo model and create a fasteners. from hwx import inspire #Import a function that allows you to open demo files from the product. from hwx.inspire.demo import openDemoFile # clears the existing model and creates a new session model = inspire.newModel() #Open an existing 'dangler_with_holes.stmod' demo model model = openDemoFile("dangler_with_holes.stmod") #gets the Holes list from the model holes = model.holes for aligned_holes in holes.aligned: bolt = inspire.Fastener(aligned_holes) print(bolt.name + " connects parts '" + aligned_holes[0].part.name + "' and '" + aligned_holes[1].part.name + "'")
Types of fasteners allowed for aligned holes are 'Nut and Bolt', 'Grounded Bolt', 'Screw', 'Grounded Screw'
# Example 2: How to create fasteners on Existing model and change its type. from hwx import inspire # gets the existing model model = inspire.getModel() #gets the Holes list from the model holes = model.holes for aligned_holes in holes.aligned: bolt = inspire.Fastener(aligned_holes) print(bolt.name + " connects parts '" + aligned_holes[0].part.name + "' and '" + aligned_holes[1].part.name + "'") #How to change fasteners type to 'Grounded Bolt' # types of fasteners allowed for aligned holes are 'Nut and Bolt', 'Grounded Bolt', 'Screw', 'Grounded Screw' # types of fasteners allowed for singular holes are 'Grounded Screw', 'Grounded Bolt' #To know the allowed fasteners type on this fasteners object, you can call getAllowedTypes function. print(bolt.getAllowedTypes()) if 'Grounded Bolt' in bolt.getAllowedTypes(): bolt.type = 'Grounded Bolt' else: print(f"'Grounded Bolt' is not an allowed type for {bolt.name}.") #similarly How to change fasteners type to 'Nut and Bolt' if 'Nut and Bolt' in bolt.getAllowedTypes(): bolt.type = ''Nut and Bolt' else: print(f"Nut and Bolt' is not an allowed type for {bolt.name}.")
The axial and shear stiffness for grounded fasteners can be modified.
You can enable fastener pretension and enter a magnitude for the pretension force.
# Example 2: How to create fasteners on Existing model and enable its pretension, or modify shearForce and shearStiffness . from hwx import inspire # gets the existing model model = inspire.getModel() #gets the Holes list from the model holes = model.holes for aligned_holes in holes.aligned: bolt = inspire.Fastener(aligned_holes) print(bolt.name + " connects parts '" + aligned_holes[0].part.name + "' and '" + aligned_holes[1].part.name + "'") # enable fastener pretension and enter a magnitude for the pretension force bolt.enablePretension =True bolt.pretensionForce ='100 N' # disable fastener pretension and enter a magnitude for the pretension force bolt.enablePretension =False #Fasteners can be used as optimization constraints. You can enable optimization for fasteners bolt.enableAllowableForces =True # To disable auto Calculate AllowableForces bolt.autoCalculateAllowableForces=False # how to assign magnitude for fastener's axial Force bolt.axialForce='1000 N' # how to assign magnitude for fastener's shear Force bolt.shearForce='99 N' # To enable auto Calculate AllowableForces # in this case, axial and shear forces will be auto Calculated . bolt.autoCalculateAllowableForces=True #Disable optimization for fasteners bolt.enableAllowableForces =False
You can assign material to the fasteners.
# Assigning material to an existing fasteners. # import inspire module. from hwx import inspire #get existing model model = inspire.getModel() #Querry a fastener named 'Fastener 1' fastener = model.getChild(name = 'Fastener 1') #Get the available material dictionaries from the application. materials = inspire.Material.getMaterials() #Get the required material object ('Steel (C45E)') from material dictionaries material = materials.get('Steel (C45E)') if fastener and material : fastener. material = material print(f"{fastener.name} is assigned with {material.name}.") else: print(f"Either 'Fastener 1' or 'Steel (C45E)' is not available.")
Interactively pick aligned hole and create fasteners
from hwx import inspire #import debug module to use picking context. from hwx.inspire.gui import debug #get existing model model = inspire.getModel() # Create a context to pick aligned hole from the model. #This context allows you to pick interested feature to pick from the model # Once the interested feature is picked you can swipe left to exit the selection mode. aligned_holes= debug.pickOne(model.holes.aligned, helpMessage="Pick aligned hole", picked=True, makeModelTransparent=True) #Create a fastener. bolt = inspire.Fastener(aligned_holes) print(bolt.name + " connects parts '" + aligned_holes[0].part.name + "' and '" + aligned_holes[1].part.name + "'")
Joints
Connect parts together while allowing movement at the joint location. Joint types include grounded pin and grounded sliding pin. Grounded joints appear under Load Cases in the Model Browser, instead of under Connectors.
# Example 1 :Open a dangler_with_holes.stmod demo mode and create joint and then change its type, state, behavior from hwx import inspire from hwx.inspire.demo import openDemoFile #clean the existing model and creates a new session model = inspire.newModel() model = openDemoFile("dangler_with_holes.stmod") #Query the list of aligned holes from the model. holes =model.holes.aligned # Create feature-based Joint joint1 = inspire.Joint(holes[2]) #How to change joint type #Feature based joint types can be 'Pin', 'Grounded Pin', 'Sliding Pin', 'Grounded Sliding Pin', 'Ball and Socket'. #contact-based Joint types can be 'Hinge', 'Cylindrical', 'Translational', 'Ball and Socket', 'Planar', 'Contact', 'Unknown'. print(joint1.getAllowedTypes()) if 'Ball and Socket' in joint1.getAllowedTypes(): joint1.type = 'Ball and Socket' #query all contacts from the model contacts = model.contacts if not contacts: #Update the contacts for the model. model.updateContacts() # Create contact-based Joint contact = model.contacts[0] joint2 = inspire.Joint(contact) #contact-based Joint types can be 'Hinge', 'Cylindrical', 'Translational', 'Ball and Socket', 'Planar', 'Contact', 'Unknown'. if 'Hinge' in joint1.getAllowedTypes(): joint1.type = 'Hinge' #How to query a joint by its name 'Joint 1'. joint1 = model.getChild(type='Joint', name ='Joint 1' ) if joint1: #joint behavior can be Default, Rigid, Flexible #How to change joint behavior to flexible. joint1.behavior = 'Flexible' #joint state can be Locked, Active, Free #How to change joint state to Locked. joint1.state= 'Locked'
Assigning material to joint.
# Assigning material to an existing Joint. # import inspire module. from hwx import inspire #get existing model model = inspire.getModel() #Querry a Joint named 'Joint 1' joint= model.getChild(type ='Joint', name = 'Joint 1') #Get the available material dictionaries from the application. materials = inspire.Material.getMaterials() #Get the required material object ('Steel (C45E)') from material dictionaries material = materials.get('Steel (C45E)') if joint and material : joint.material = material print(f"{joint .name} is assigned with {material.name}.") else: print(f"Either 'Joint 1' or 'Steel (C45E)' is not available.")
Interactively pick aligned hole and create Joint
from hwx import inspire #import debug module to use picking context. from hwx.inspire.gui import debug #get existing model model = inspire.getModel() # Create a context to pick aligned hole from the model. #This context allows you to pick interested feature to pick from the model # Once the interested feature is picked you can swipe left to exit the selection mode. aligned_holes= debug.pickOne(model.holes.aligned, helpMessage="Pick aligned hole", picked=True, makeModelTransparent=True) #Create a fastener. joint= inspire.Joint(aligned_holes) print(joint.name + " connects parts '" + aligned_holes[0].part.name + "' and '" + aligned_holes[1].part.name + "'")
Enabling pretension on a Joint.
# Assigning material to an existing Joint. # import inspire module. from hwx import inspire #get existing model model = inspire.getModel() #Querry a Joint named 'Joint 1' joint= model.getChild(type ='Joint', name = 'Joint 1') #Disable pretension for joint joint.enablePretension=False # Enable pretension for joint joint.enablePretension=True #Assign pretension force joint.pretensionForce='100 N'
Enabling friction properties of a joint
from hwx import inspire model = inspire.getModel() #How to query a joint by its name 'Joint 1'. joint1 = model.getChild(type='Joint', name ='Joint 1' ) if joint1: #joint behavior can be Default, Rigid, Flexible #How to change joint behavior to flexible. joint1.behavior = 'Rigid' # for flexible joint behavior joint1.enableFriction =True