Mastering Connections in Altair Inspire: Create and Modify Bushings, Connectors (Spider) with Python APIs
Karthi Kandasamy
Altair Employee
Bushings
Create bushings between the selected surfaces of the parts.
from hwx import inspire #clear the existing model and create a fresh session. model = inspire.newModel() #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box1 = model.createSolidBlock() #Move the part object to (-2,0,0) location box1 .translate(x=-2, y=0, z=0) #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box2 = model.createSolidBlock() #Query a feature planar from box1 part object. face1 = box1.getFeatures(inspire.FeaturePlanar)[5] #Query a feature planar from box2 part object. face2 = box2.getFeatures(inspire.FeaturePlanar)[2] # Create Bushing bushing = inspire.Bushing(primaryFeatures=face1, secondaryFeatures=face2, name ='Bushing 1') # Fit the model to the screen. inspire.fitView() #Modify the existing bushing #Query an existing bushing with name 'Bushing 1' bushing = model.getChild(type ='Bushing', name = 'Bushing 1') #Modify the name of the bushings bushing.name = 'bushing connector' #Modify Translational stiffness of Bushing ( TX, TY, TZ ) bushing.stiffness =[100.0, 100.0, 100.0] #Modify damping stiffness of Bushing ( TX, TY, TZ ) bushing.damping=[100.0, 100.0, 100.0] #Modify forcePreload of Bushing ( FX, FY, FZ ) bushing.forcePreload = [100.0, 100.0, 100.0] #Modify angularStiffness of Bushing ( RX, RY, RZ ) bushing.angularStiffness=[100.0, 100.0, 100.0] #Modify angular Damping of Bushing ( RX, RY, RZ ) bushing.angularDamping=[100.0, 100.0, 100.0] #Modify torque Preload of Bushing bushing.torquePreload=[100.0, 100.0, 100.0] #Modify mass of Bushing bushing.mass='100 kg'
Creating a Grounded bushing
from hwx import inspire #clear the existing model and create a fresh session. model = inspire.newModel() #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box1 = model.createSolidBlock() #Move the part object to (-2,0,0) location box1 .translate(x=-2, y=0, z=0) #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box2 = model.createSolidBlock() #Query a feature planar from box1 part object. face1 = box1.getFeatures(inspire.FeaturePlanar)[5] #Query a feature planar from box2 part object. face2 = box2.getFeatures(inspire.FeaturePlanar)[2] # Create grounded Bushing bushing = inspire.Bushing(primaryFeatures=face1, secondaryFeatures=face2, name ='Bushing 1',grounded=True) # Fit the model to the screen. inspire.fitView()
Interactively select the features to create bushings
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 area feature 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. primaryFeatures= debug.pick('FeatureArea',multi=True, helpMessage="Pick primary features and exit the context to pick secondary features. ") secondaryFeatures= debug.pick('FeatureArea',multi=True, helpMessage="Pick secondary features and exit the context to create bushings. ") # Create Bushing bushing = inspire.Bushing(primaryFeatures, secondaryFeatures)
Connectors (Spiders)
Connectors link points, edges, or faces to each other, and are shown as red lines radiating from a central point. They are generally used to connect two parts together, or to apply a load or support at a distance.
from hwx import inspire #clear the existing model and create a fresh session. model = inspire.newModel() #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box1 = model.createSolidBlock() #Move the part object to (-2,0,0) location box1 .translate(x=-2, y=0, z=0) #Creating a solid block with default dimensions (x=1m, y=1m, z=1m) box2 = model.createSolidBlock() #Query a feature planar from box1 part object. face1 = box1.getFeatures(inspire.FeaturePlanar)[5] #Query a feature planar from box2 part object. face2 = box2.getFeatures(inspire.FeaturePlanar)[2] #Creating connector/spider between two faces. spider = inspire.Spider(face1 , face2) inspire.fitView() #modify the spider/connector properties. #query a connector with name 'Connector 1'. spider = model.getChild(type='Spider', name ='Connector 1' ) #Modify the connector / spider type to 'Flexible'. spider.connectionType ='Flexible' #Modify the connector / spider type to 'Rigid'. spider.connectionType ='Rigid'
Interactively select the features to create bushings
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 area feature 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. features= debug.pick('Feature',multi=True, helpMessage="Pick two features and exit the context to create connector. ") # Create spider spider = inspire.Spider(features[0],features[1])
1