Bolt Pretension by Named Selection

Drago
Member, Employee Posts: 17
✭✭✭

After creating a Bolt Pretension with:
newBoltPretension = Model.Analyses[0].AddBoltPretension()
I am wondering how to change the scoping to a Named Selection and how to assign a value. Thank you
Tagged:
0
Best Answers
-
Assuming the NS is ‘Bolt 1‘, with the following it can be assigned to the selection:
Pretension = Model.Analyses[0].AddBoltPretension()
BoltObj = DataModel.GetObjectsByName(selection)[0]
Pretension.Location = Obj
Assuming that the force to be applied is 1000 N, it can be applied with:
Pretension.SetDefineBy(1,BoltLoadDefineBy.Load)
Pretension.Preload.Output.SetDiscreteValue(0,Quantity("1000[N]"))
The solution was taken from KM #2056373
0 -
# Get Beam objects myObj = 'Connections' myBeamsIDs = [] myLoads = [1,2,3,4] model = ExtAPI.DataModel.Project.Model obj = ExtAPI.DataModel.GetObjectsByName(myObj)[0] for beam in obj.Children: if 'Beam' in beam.GetType().ToString(): myBeamsIDs.append(beam.ObjectId) # Create Bolt Pretension for each Beam ctr = 0 for beam in myBeamsIDs: boltPreTens = model.Analyses[0].AddBoltPretension() boltPreTens.InternalObject.GeometryDefineBy = 19 # secret sauce boltPreTens.InternalObject.BeamConnectionSelection = beam load = Quantity(myLoads[ctr],'N') #boltPreTens.Formulation = FormulationType.SmallRotation boltPreTens.Preload.Output.Field.Output.SetDiscreteValue(1,load) ctr +=1
0 -
Alternate method to create Bolt Pretension with Beam Connection scoped to it. As using InternalObject might have some issues (eg: Linux)
boltObj = DataModel.GetObjectsByType(DataModelObjectCategory.Beam)[0] analysisObj = DataModel.AnalysisList[0] boltObj.Activate() import context_menu context_menu.DoEditCopy(ExtAPI) analysisObj.Activate() context_menu.DoEditPaste(ExtAPI)
However, if you are using PyMechanical (Embedded mode), the above solution, or the method suggested in the previous post unforunately doesn't seem to work
Please use the below,
boltPreTens.PropertyByName("GeometryDefineBy").InternalValue = 19
Instead of,
boltPreTens.InternalObject.GeometryDefineBy = 19 # secret sauce
0