Add beams inside mechanical at fastener holes automatically
Erik Kostson
Member, Employee Posts: 233
✭✭✭✭
Say we have multiple fastener holes (defined say as named selections), how can we then add automatically beams inside mechanical?
0
Best Answer
-
Below is the code for the automatic beam creation inside mechanical:
It needs to have a cross section folder, and named selections created - each named selection is of the 2 edges that are to be connected by the beam. Beam will be connected to these 2 edges via 2 fixed joints (MPC rigid). Finally a Bolt-Pretension is added to the new beam.
model = ExtAPI.DataModel.Project.Model analysis=model.Analyses[0] ns=model.NamedSelections.Children construction_geometry = model.AddConstructionGeometry() # add folder # add line object for n in ns: # get named sel. hole edge pair needs to be there (so 2 edges) nId=n.Location.Ids a = construction_geometry.AddConstructionLine() pointlist=[] for edge in nId: e = ExtAPI.DataModel.GeoData.GeoEntityById(edge) if str(e.CurveType) =="GeoCurveCircle": ce=e.Centroid # get centre of hole #print(ce) pointlist.append((ce[0],ce[1],ce[2])) # beam points at the centre points=a.CreatePoints(pointlist) for i in range(0,len(points)-1): edge_collection_5 = a.CreateStraightLines([points[i],points[i+1]], [(0,1)]) # create the points and add beam beam=a.AddToGeometry() # create beam geobeam=beam.Bodies[0] # treebody=ExtAPI.DataModel.Project.Model.Geometry.GetBody(geobeam) # get tree body beam cross_sec=ExtAPI.DataModel.GetObjectsByType(DataModelObjectCategory.CrossSections)[0].AddCircularCrossSection() cross_sec.Radius = Quantity(float(e.Radius), "m") treebody.CrossSectionSelection=cross_sec connections = Model.Connections connectiongroup = connections.AddConnectionGroup() j=0 for edge in nId: # create mpc rigid connections joint = connectiongroup.AddJoint() selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) selection.Ids=[geobeam.Vertices[j].Id] joint.MobileLocation = selection selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) selection.Ids=[edge] joint.ReferenceLocation = selection j=j+1 bopr=analysis.AddBoltPretension() bopr.SetDefineBy(1,BoltLoadDefineBy.Load) load = Quantity(1000,'N') bopr.Preload.Output.Field.Output.SetDiscreteValue(0,load) selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) selection.Ids=[geobeam.Edges[0].Id] bopr.Location=selection
0
This discussion has been closed.