Beam End Connections (WB LS-DYNA)

The typical way for connecting beam ends to shells/solids is to use *CONSTRAINED_NODAL_RIGID_BODY. Mechanical creates these keywords when using Remote Points but these can not be directly scoped to different geoemtry entities such as edges, surfaces or vertices. Using this script Remote Points are scoped directly to nodes creating the node set for the rigid body keyword.

Select beam edges in the graphics, specify holeRadius and unit_ and run the script!

Transparent


global allns_
global allrp_
global allcs_

# ---------------------------------------------------- #
# Select beam edges in the graphics
beams_ = ExtAPI.SelectionManager.CurrentSelection
# Input hole radius (float) and unit (string)
holeRadius = 12.806 
unit_ = 'mm'
# ---------------------------------------------------- #

def clear_():
    global allns_
    global allrp_
    global allcs_
    try:
        for ns in allns_: ns.Delete()
    except: pass
    try:
        for rp in allrp_: rp.Delete()
    except: pass
    try:
        for cs in allcs_: cs.Delete()
    except: pass

class beamObj:
    def __init__(self):
        self.Id = None; self.Start = [None,None]; self.End = [None,None]; self.Edge = None

try:
    for ns in allns_: ns.Delete()
except: pass
try:
    for rp in allrp_: rp.Delete()
except: pass
try:
    for cs in allcs_: cs.Delete()
except: pass

beams = list()
allcs_ = list()
allns_ = list()
allrp_ = list()
for index,beam in enumerate(beams_.Entities):
    beam_ = beamObj()
    beam_.Id = beam.Id
    beam_.Edge = beam
    beam_.Start[0] = beam.StartVertex
    beam_.End[0] = beam.EndVertex
    beams.append(beam_)
    start_selection=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    start_selection.Entities = [beam_.Start[0]]
    end_selection=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    end_selection.Entities = [beam_.End[0]]
    beam_selection=ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
    beam_selection.Entities = [beam_.Edge]
    
    cs = Model.CoordinateSystems.AddCoordinateSystem()
    cs.Name = str(index+1) + '_START_CS'
    cs.OriginLocation = start_selection
    cs.CoordinateSystemType = CoordinateSystemTypeEnum.Cylindrical
    cs.PrimaryAxisDefineBy = CoordinateSystemAlignmentType.Associative
    cs.PrimaryAxisLocation = beam_selection
    cs.PrimaryAxis = CoordinateSystemAxisType.PositiveZAxis
    allcs_.append(cs)
    
    beam_.Start[1] = cs
    
    namedSelStart_ = Model.AddNamedSelection()
    namedSelStart_.Name = str(index+1) + '_START_NS'
    namedSelStart_.ScopingMethod = GeometryDefineByType.Worksheet
    namedSelStart_.GenerationCriteria.Add(None)
    namedSelStart_.GenerationCriteria[0].EntityType = SelectionType.MeshNode
    namedSelStart_.GenerationCriteria[0].Criterion = SelectionCriterionType.LocationX
    namedSelStart_.GenerationCriteria[0].Operator = SelectionOperatorType.LessThanOrEqual
    namedSelStart_.GenerationCriteria[0].Value = Quantity(str(holeRadius) + ' [' + unit_ + ']')
    namedSelStart_.GenerationCriteria[0].CoordinateSystem = DataModel.GetObjectById(cs.ObjectId) 
    namedSelStart_.GenerationCriteria.Add(None)
    namedSelStart_.GenerationCriteria[1].Action = SelectionActionType.Filter
    namedSelStart_.GenerationCriteria[1].Criterion = SelectionCriterionType.LocationZ
    namedSelStart_.GenerationCriteria[1].Operator = SelectionOperatorType.Equal
    namedSelStart_.GenerationCriteria[1].Value = Quantity('0 [m]')
    namedSelStart_.GenerationCriteria[1].CoordinateSystem = DataModel.GetObjectById(cs.ObjectId)
    namedSelStart_.Generate()
    allns_.append(namedSelStart_)
    
    rpStart_ = Model.AddRemotePoint()
    rpStart_.Location = namedSelStart_
    rpStart_.Behavior = LoadBehavior.Rigid
    rpStart_.Name = str(index+1) + '_START_RP'
    rpStart_.XCoordinate = cs.OriginX
    rpStart_.YCoordinate = cs.OriginY
    rpStart_.ZCoordinate = cs.OriginZ
    allrp_.append(rpStart_)
    
    cs = Model.CoordinateSystems.AddCoordinateSystem()
    cs.Name = str(index+1) + '_END_CS'
    cs.OriginLocation = end_selection
    cs.CoordinateSystemType = CoordinateSystemTypeEnum.Cylindrical
    cs.PrimaryAxisDefineBy = CoordinateSystemAlignmentType.Associative
    cs.PrimaryAxisLocation = beam_selection
    cs.PrimaryAxis = CoordinateSystemAxisType.PositiveZAxis
    allcs_.append(cs)
    
    beam_.End[1] = cs
    
    namedSelEnd_ = Model.AddNamedSelection()
    namedSelEnd_.Name = str(index+1) + '_END_NS'
    namedSelEnd_.ScopingMethod = GeometryDefineByType.Worksheet
    namedSelEnd_.GenerationCriteria.Add(None)
    namedSelEnd_.GenerationCriteria[0].EntityType = SelectionType.MeshNode
    namedSelEnd_.GenerationCriteria[0].Criterion = SelectionCriterionType.LocationX
    namedSelEnd_.GenerationCriteria[0].Operator = SelectionOperatorType.LessThanOrEqual
    namedSelEnd_.GenerationCriteria[0].Value = Quantity(str(holeRadius) + ' [' + unit_ + ']')
    namedSelEnd_.GenerationCriteria[0].CoordinateSystem = DataModel.GetObjectById(cs.ObjectId) 
    namedSelEnd_.GenerationCriteria.Add(None)
    namedSelEnd_.GenerationCriteria[1].Action = SelectionActionType.Filter
    namedSelEnd_.GenerationCriteria[1].Criterion = SelectionCriterionType.LocationZ
    namedSelEnd_.GenerationCriteria[1].Operator = SelectionOperatorType.Equal
    namedSelEnd_.GenerationCriteria[1].Value = Quantity('0 [m]')
    namedSelEnd_.GenerationCriteria[1].CoordinateSystem = DataModel.GetObjectById(cs.ObjectId)
    namedSelEnd_.Generate()
    allns_.append(namedSelEnd_)
    
    rpEnd_ = Model.AddRemotePoint()
    rpEnd_.Location = namedSelEnd_
    rpEnd_.Behavior = LoadBehavior.Rigid
    rpEnd_.Name = str(index+1) + '_END_RP'
    rpEnd_.XCoordinate = cs.OriginX
    rpEnd_.YCoordinate = cs.OriginY
    rpEnd_.ZCoordinate = cs.OriginZ
    allrp_.append(rpEnd_)
    beams.append(beam_)
Tree.Refresh()