cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Bolt Check (AISC ASD 9th edition) API for FEMAP , Metric bolts

Creator
Creator

The attached FEMAP API program performs a simple bolt check (for bearing type) connections, according to AISC ASD 9th edition. Metric bolts are available from the drop down list.

 

It is intended for quick sizing of bolts (and it is best used with the hole-to-hole fastener macro available from the "custom tools" --> "meshing". 

 

Output is printed to the message window, and looks like this (after copied to a text editor):

image004.png

 

 The code is as follows:

 

 

'This macro is created to quickly check bolts according to AISC 9th edition
'(tension and shear check is considered only)
'
'No Responsibility is Taken For Results Obtained From this API
'
'Written for FEMAP 11.2

' Rev. 0 , Date: 21-02-2017, Created by P. Barabas (barabas.pete [ at ] gmail.com)


Sub Main

	'Attach the active FEMAP model to the macro
    	Dim App As femap.model

	Set App = GetObject(,"femap.model")



        RESTART:

Call Bolt

rc = App.feAppMessageBox(2,"Would you like to check other bolts?")

If rc = -1 Then

	GoTo RESTART

End If

End Sub




Sub Bolt

	'Attach the active FEMAP model to the macro
	Dim App As femap.model
	Set App = GetObject(,"femap.model")

	'create an element set Object
	Dim Elem_set As Object
	Set Elem_set = App.feSet

	'create a load set object
	Dim load_set As Object
	Set load_set = App.feSet

	'create  element object
	Dim feElem As Object
	Set feElem = App.feElem

	'create output vector objects
	Dim ouVec1 As Object
	Set ouVec1 = App.feOutput

	Dim ouVec2 As Object
	Set ouVec2 = App.feOutput

	Dim ouVec3 As Object
	Set ouVec3 = App.feOutput

	Dim nb_load As Long
	Dim nb_element As Long
	Dim ouSetID As Long

	Dim totalShear As Double
	Dim shear1 As Double
	Dim shear2 As Double
	Dim axial As Double

	Dim UC_shear As Double
	Dim UC_axial As Double

	Dim UC_max_axial As Double

	Dim Max_ID_axial  As Double
	Dim Max_OS_axial  As Double

	Dim	UC_max_shear As Double

	Dim Status As String

	Dim OutText1 As String
	Dim OutText2 As String
	Dim OutText3 As String
	Dim OutText4 As String
	Dim OutText5 As String
	Dim OutText6 As String
	Dim Max_status As String


	UC_max_shear = 0
	UC_max_axial = 0

	UC_max_shear = 0
	UC_max_axial = 0

rc = App.feAppMessage(4, "**** API simple bolt check started ****") 	'Black bold
rc = App.feAppMessage(2, "***************************************")
rc = App.feAppMessage(2, "Simple bolt checks according to AISC (ASD) 9th edition.")
rc = App.feAppMessage(2, "Rev. 0 , Date: 21-02-2017, Created by P. Barabas (barabas.pete [at] gmail.com).")

'Label to navigate with GoTo
Select_element:

Elem_set.Select(FT_ELEM,True,"Select BEAM elements to process")
'supress (remove) any plates selected accidentally
    Dim elt_plate As Object
    Set elt_plate = App.feSet
    elt_plate.AddRule(FET_L_PLATE,FGD_ELEM_BYTYPE)
    Elem_set.RemoveSet(elt_plate.ID)

 'supress (remove) any RIGIDS selected accidentally
    Dim elt_rigid As Object
    Set elt_rigid = App.feSet
    elt_plate.AddRule(FET_L_RIGID,FGD_ELEM_BYTYPE)
    Elem_set.RemoveSet(elt_rigid.ID)

If Elem_set.Count = 0 Then
	GoTo Select_element
	Else
		'do nothing
End If

nb_element=Elem_set.Count

'Label to navigate with GoTo
Select_OutputSet:

App.feSelectOutputSets("Select output sets to process", load_set)

If load_set.Count = 0 Then
	GoTo Select_OutputSet
	Else
		'do nothing
End If

nb_load=load_set.Count



' create DropList for User Dialog

Dim BoltList (16) As String
Dim BoltMaterialList (2) As String
Dim OVR_List (2) As String

BoltList (0) = "M4"
BoltList (1) = "M6"
BoltList (2) = "M7"
BoltList (3) = "M8"
BoltList (4) = "M10"
BoltList (5) = "M12"
BoltList (6) = "M14"
BoltList (7) = "M16"
BoltList (8) = "M18"
BoltList (9) = "M20"
BoltList (10) = "M22"
BoltList (11) = "M24"
BoltList (12) = "M27"
BoltList (13) = "M30"
BoltList (14) = "M33"
BoltList (15) = "M36"
BoltList (16) = "M39"

BoltMaterialList (0) = "5.6"
BoltMaterialList (1)= "8.8"
BoltMaterialList (2)= "10.9"

OVR_List (0) = "1.00"
OVR_List (1)= "1.33"
OVR_List (2)= "1.50"


	Begin Dialog UserDialog 390,266 ' %GRID:10,7,1,1

		GroupBox 20,7,350,56,"System of Units",.GroupBox2

		text 40,28,290,21,"FEMAP force input must be in [N].",.Text5


		GroupBox 20,70,350,147,"Select Properties",.GroupBox1
		text 40,91,190,21,"BOLT SIZE",.Text1
		DropListBox 240,91,120,21,BoltList(),.DropListBox1

		text 40,119,190,21,"BOLT GRADE",.Text2
		DropListBox 240,119,120,28,BoltMaterialList(),.DropListBox2

		text 30,147,190,21,"Allowable Overstress Ratio",.Text3
		DropListBox 240,147,120,28,OVR_List(),.DropListBox3

		text 30,182,190,28,"Threads INCLUDED in shear plane?",.Text4

		OptionGroup .Threads_included
			OptionButton 240,175,120,14,"No",.OptionButton4
			OptionButton 240,196,120,14,"Yes",.OptionButton5

		CancelButton 90,224,120,35
		OKButton 230,224,120,35




	End Dialog

	Dim dlg As UserDialog
	Dialog dlg

'capture user input

'rc = App.feAppMessage(2, "Unit system scale factor: " & Scale  )

	'input for bolt size
		Dim BoltSize As Double
		If  dlg.DropListBox1 = 0 Then
			BoltSize = 4
		ElseIf  dlg.DropListBox1 = 1  Then
			BoltSize = 6
		ElseIf  dlg.DropListBox1 = 2  Then
			BoltSize = 7
		ElseIf  dlg.DropListBox1 = 3  Then
			BoltSize = 8
		ElseIf  dlg.DropListBox1 = 4  Then
			BoltSize = 10
		ElseIf  dlg.DropListBox1 = 5  Then
			BoltSize = 12
		ElseIf  dlg.DropListBox1 = 6  Then
			BoltSize = 14
		ElseIf  dlg.DropListBox1 = 7  Then
			BoltSize = 16
		ElseIf  dlg.DropListBox1 = 8  Then
			BoltSize = 18
		ElseIf  dlg.DropListBox1 = 9  Then
			BoltSize = 20
		ElseIf  dlg.DropListBox1 = 10  Then
			BoltSize = 22
		ElseIf  dlg.DropListBox1 = 11  Then
			BoltSize = 24
		ElseIf  dlg.DropListBox1 = 12  Then
			BoltSize = 27
		ElseIf  dlg.DropListBox1 = 13  Then
			BoltSize = 30
		ElseIf  dlg.DropListBox1 = 14  Then
			BoltSize = 33
		ElseIf  dlg.DropListBox1 = 15  Then
			BoltSize = 36
		ElseIf  dlg.DropListBox1 = 16  Then
			BoltSize = 39
		Else
			rc = App.feAppMessage(3, "Bolt size ERROR"  )
		End If

'rc = App.feAppMessage(2, "Selected bolt size: " & BoltSize & " [mm]"  )

	'input for bolt grade
		Dim F_ub As Double
		If  dlg.DropListBox2 = 0 Then
			F_ub = 500
		ElseIf  dlg.DropListBox2 = 1  Then
			F_ub = 800
		ElseIf  dlg.DropListBox2 = 2  Then
			F_ub = 1000
		Else
			rc = App.feAppMessage(3, "Grade selection ERROR"  )
		End If

'rc = App.feAppMessage(2, "Bolt ultimate tensile strength: " & F_ub & " [MPa]"  )

	'input for Allowable Overstress Ratio (OVR)
		Dim OVR As Double
		If  dlg.DropListBox3 = 0 Then
			OVR = 1.00
		ElseIf  dlg.DropListBox3 = 1  Then
			OVR = 1.33
		ElseIf  dlg.DropListBox3 = 2  Then
			OVR = 1.50
		Else
			rc = App.feAppMessage(3, "OVR selection ERROR"  )
		End If

'rc = App.feAppMessage(2, "Allowable Overstress Ratio: " & OVR  )

	'input for Thread in Shear Area
		Dim TSA As Boolean
		If  dlg.Threads_included = 0 Then
			TSA = False
		ElseIf  dlg.Threads_included = 1  Then
			TSA = True
		Else
			rc = App.feAppMessage(3, "Thread selection ERROR"  )
		End If

'rc = App.feAppMessage(2, "Thread included in shear plane: " & TSA  )

' calculate basic constants for AISC (ASD) code check 9th Edition, Table J3.2

	'cross section area of bolt
	Dim A_bolt As Double

	A_bolt =Format( (BoltSize * BoltSize) * 3.1415926535 / 4 , "#.#0")' in [mm^2]

	'Tensile capacity of one bolt
	Dim fb_tensile As Double

	fb_tensile = Format( 0.33 * A_bolt * F_ub, "#.0") ' in [N/mm2]

	'Shear capacity of one bolt
	Dim fb_shear As Double

		If TSA = False Then
			fb_shear =Format( 0.22 * A_bolt * F_ub, "#.0") ' in [N/mm2]

		Else
			fb_shear = Format(0.17 * A_bolt * F_ub, "#.0") ' in [N/mm2]
		End If

rc = App.feAppMessage(2, "Selected bolt size: " & BoltSize & " [mm]; " & "Bolt Area: " & A_bolt & "[mm]; Bolt ultimate tensile strength: " & F_ub & " [MPa]" & " ; Tensile capacity [N]: " & fb_tensile & " ; Shear capacity [N]: " & fb_shear  )
rc = App.feAppMessage(2, "*")
rc = App.feAppMessage(2, "*")

'walk through all the selected output sets and all selected bolts
load_set.Reset

While load_set.Next

		rc = App.feAppMessage(4, "Output Set: " & load_set.CurrentID & "  *******************************************************************")
		'create the header
									  				    '<-------1><-------2><-------3><-------4><-------5><-------6><-------7><-------8><-------9><------10>
			rc = App.feAppMessage(2,"ElemID   | Output Set |Axial Force [N] | Shear Force [N] | Allowable Axial Force [N] | Allowable Shear Force [N] | UC Axial | UC Shear | Status")

			Elem_set.Reset

			ouSetID = load_set.CurrentID

		While Elem_set.Next

					feElem.ID = Elem_set.CurrentID

				'code here to extract the loads
					ouVec1.setID = ouSetID
					ouVec2.setID = ouSetID
					ouVec3.setID = ouSetID

					rc = ouVec1.Get( 3018 ) 'Beam Shear 1
					rc = ouVec2.Get( 3019 ) 'Beam Shear 2
					rc = ouVec3.Get( 3022 ) 'Beam Axial Force

					shear1 =  Format(ouVec1.Value( feElem.ID ),"#.0")
					shear2 =  Format(ouVec2.Value( feElem.ID ),"#.0")
					axial =  Format(ouVec3.Value( feElem.ID ),"#.0")

					'rc = App.feAppMessage(2,"For Element " + Str$(feElem.ID) + " Axial, Total Shear " + Str$( axial ) + " " + Str$( totalShear ) )

				'code to calculate shear force and consider tension only in bolts
					totalShear = Format(Sqr( shear1 * shear1 + shear2 * shear2 ),"#.0")

						If axial<0 Then
							axial = 0
						Else
							'do nothing
						End If


				'code to calculate Unity Checks

						UC_axial = Format( axial / fb_tensile , "#.00")
						UC_shear = Format( totalShear/ fb_shear , "#.00")

						If UC_axial < OVR And UC_shear < OVR Then
							Status="OK"
							Else
								Status="Fail"
						End If


				'add code here to collect the max UC

						If UC_max_axial<= UC_axial Then
							UC_max_axial = UC_axial
								Max_ID_axial = feElem.ID
								Max_OS_axial = load_set.CurrentID

							Else
								'do nothing
						End If

						If UC_max_shear<= UC_shear Then
							UC_max_shear = UC_shear
								Max_ID_shear = feElem.ID
								Max_OS_shear = load_set.CurrentID
							Else
								'do nothing
						End If


				'add code here to write the output to the message window

						'Formatting the output fields

							OutText1 = Left(CStr(Elem_set.CurrentID) & "                    ", 9)
							OutText2 = Left(CStr(load_set.CurrentID) & "                    ", 12)
							OutText3 =Right(CStr( "                                             " & axial) , 16)
							OutText4 = Right(CStr("                                             " &totalShear) , 17)
							OutText5 = Right(CStr("                                             " &fb_tensile) , 27)
							OutText6 = Right(CStr("                                             " &fb_shear) , 27)

					'rc = App.feAppMessage(2,"ElemID   | Output Set |Axial Force [N] | Shear Force [N] | Allowable Axial Force [N] | Allowable Shear Force [N] | UC Axial | UC Shear | Status")
				rc = App.feAppMessage(2,OutText1 & "|" & OutText2 & "|" &  OutText3 & "|" & OutText4 & "|" & OutText5 & "|" & OutText6 & "|   " & UC_axial & "   |   " & UC_shear & "   | " & Status )

		Wend

Wend

'add the code check summary here

rc = App.feAppMessage(4, "****************************** Bolt Checks Summary ***********************************")		'black bold
rc = App.feAppMessage(2, " Max UC axial : " & UC_max_axial & "  at element ID: " & Max_ID_axial & " OutPut Set ID: " & Max_OS_axial)
rc = App.feAppMessage(2, " Max UC shear: " & UC_max_shear & "  at element ID: " & Max_ID_shear & " OutPut Set ID: " & Max_OS_shear)


						If UC_max_axial > OVR Or UC_max_shear > OVR Then
								Max_status = "FAIL"
							Else
								Max_status = "OK"
						End If

rc = App.feAppMessage(4, " Overall Status: " & Max_status )

rc = App.feAppMessage(2, "***************************************************************************") 	' blue text
rc = App.feAppMessage(3, "*** There may be other check necessary, like bearing and tear out!!! ****")		' red bold
rc = App.feAppMessage(4, "****************************** Finished ***********************************")		'black bold

End Sub

 

 

 Enjoy! 

 
2 REPLIES

Re: Simple Bolt Check (AISC ASD 9th edition) API for FEMAP , Metric bolts

Genius
Genius

Hello PBarabas,

 

I think there is a failure in your code:

 

 'supress (remove) any RIGIDS selected accidentally
    Dim elt_rigid As Object
    Set elt_rigid = App.feSet
    'elt_plate.AddRule(FET_L_RIGID,FGD_ELEM_BYTYPE) -- this must be elt_rigid
    elt_rigid.AddRule(FET_L_RIGID,FGD_ELEM_BYTYPE)
    Elem_set.RemoveSet(elt_rigid.ID)

 

Best regards,

 

Peter Kaderasz

Re: Simple Bolt Check (AISC ASD 9th edition) API for FEMAP , Metric bolts

Creator
Creator

Yes, you are correct. I have updated the code. Thanks for your input!

'This macro is created to quickly check bolts according to AISC 9th edition
'(tension and shear check is considered only)
'
'No Responsibility is Taken For Results Obtained From this API
'
'Written for FEMAP 11.2

' Rev. 2 , Date: 25-03-2017, Created by P. Barabas (barabas.pete [ at ] gmail.com)


Sub Main

'Attach the active FEMAP model to the macro
Dim App As femap.model

Set App = GetObject(,"femap.model")



RESTART:

Call Bolt

rc = App.feAppMessageBox(2,"Would you like to check other bolts?")

If rc = -1 Then

GoTo RESTART

End If

End Sub


Sub Bolt

'Attach the active FEMAP model to the macro
Dim App As femap.model
Set App = GetObject(,"femap.model")

'create an element set Object
Dim Elem_set As Object
Set Elem_set = App.feSet

'create a load set object
Dim load_set As Object
Set load_set = App.feSet

'create element object
Dim feElem As Object
Set feElem = App.feElem

'create output vector objects
Dim ouVec1 As Object
Set ouVec1 = App.feOutput

Dim ouVec2 As Object
Set ouVec2 = App.feOutput

Dim ouVec3 As Object
Set ouVec3 = App.feOutput

Dim nb_load As Long
Dim nb_element As Long
Dim ouSetID As Long

Dim totalShear As Double
Dim shear1 As Double
Dim shear2 As Double
Dim axial As Double
Dim comb As Double

Dim UC_shear As Double
Dim UC_axial As Double
Dim UC_comb As Double

Dim UC_max_axial As Double
Dim UC_max_comb As Double
Dim UC_max_shear As Double

Dim Max_ID_axial As Double
Dim Max_OS_axial As Double

Dim Max_ID_comb As Double
Dim Max_OS_comb As Double


Dim Status As String

Dim OutText1 As String
Dim OutText2 As String
Dim OutText3 As String
Dim OutText4 As String
Dim OutText5 As String
Dim OutText6 As String
Dim OutText7 As String
Dim OutText8 As String
Dim OutText9 As String
Dim OutText10 As String
Dim Max_status As String


UC_max_shear = 0
UC_max_axial = 0
UC_max_comb = 0


rc = App.feAppMessage(4, "**** API simple bolt check started ****") 'Black bold
rc = App.feAppMessage(2, "***************************************")
rc = App.feAppMessage(2, "Simple bolt checks according to AISC (ASD) 9th edition.")
rc = App.feAppMessage(2, "Rev. 1 , Date: 05-03-2017, Created by P. Barabas (barabas.pete@gmail.com).")
rc = App.feAppMessage(2, "Note 1: The combined bolt check is according to AISC 13th Edition, Formula (J3-3b), all other checks are according to AISC 9th Table J3.2 ")

'Label to navigate with GoTo
Select_element:

rc=Elem_set.Select(FT_ELEM,True,"Select BEAM elements to process")
'supress (remove) any plates selected accidentally
Dim elt_plate As Object
Set elt_plate = App.feSet
elt_plate.AddRule(FET_L_PLATE,FGD_ELEM_BYTYPE)
Elem_set.RemoveSet(elt_plate.ID)

'supress (remove) any RIGIDS selected accidentally
Dim elt_rigid As Object
Set elt_rigid = App.feSet
elt_rigid.AddRule(FET_L_RIGID,FGD_ELEM_BYTYPE)
Elem_set.RemoveSet(elt_rigid.ID)

If rc = FE_CANCEL Then Exit Sub


If Elem_set.Count = 0 Then
GoTo Select_element
Else
'do nothing
End If

nb_element=Elem_set.Count

'Label to navigate with GoTo
Select_OutputSet:

rc=App.feSelectOutputSets("Select output sets to process", load_set)

If rc = 0 Then Exit Sub
If rc = FE_NOT_EXIST Then Exit Sub


If load_set.Count = 0 Then
GoTo Select_OutputSet
Else
'do nothing
End If

nb_load=load_set.Count



' create DropList for User Dialog

Dim BoltList (16) As String
Dim BoltMaterialList (2) As String
Dim OVR_List (2) As String

BoltList (0) = "M4"
BoltList (1) = "M6"
BoltList (2) = "M7"
BoltList (3) = "M8"
BoltList (4) = "M10"
BoltList (5) = "M12"
BoltList (6) = "M14"
BoltList (7) = "M16"
BoltList (8) = "M18"
BoltList (9) = "M20"
BoltList (10) = "M22"
BoltList (11) = "M24"
BoltList (12) = "M27"
BoltList (13) = "M30"
BoltList (14) = "M33"
BoltList (15) = "M36"
BoltList (16) = "M39"

BoltMaterialList (0) = "5.6"
BoltMaterialList (1)= "8.8"
BoltMaterialList (2)= "10.9"

OVR_List (0) = "1.00"
OVR_List (1)= "1.33"
OVR_List (2)= "1.50"


Begin Dialog UserDialog 390,266 ' %GRID:10,7,1,1

GroupBox 20,7,350,56,"System of Units",.GroupBox2

text 40,28,290,21,"FEMAP force input must be in [N].",.Text5


GroupBox 20,70,350,147,"Select Properties",.GroupBox1
text 40,91,190,21,"BOLT SIZE",.Text1
DropListBox 240,91,120,21,BoltList(),.DropListBox1

text 40,119,190,21,"BOLT GRADE",.Text2
DropListBox 240,119,120,28,BoltMaterialList(),.DropListBox2

text 30,147,190,21,"Allowable Overstress Ratio",.Text3
DropListBox 240,147,120,28,OVR_List(),.DropListBox3

text 30,182,190,28,"Threads INCLUDED in shear plane?",.Text4

OptionGroup .Threads_included
OptionButton 240,175,120,14,"No",.OptionButton4
OptionButton 240,196,120,14,"Yes",.OptionButton5

CancelButton 90,224,120,35
OKButton 230,224,120,35




End Dialog

Dim dlg As UserDialog
Dialog dlg

'capture user input

'rc = App.feAppMessage(2, "Unit system scale factor: " & Scale )

'input for bolt size
Dim BoltSize As Double
If dlg.DropListBox1 = 0 Then
BoltSize = 4
ElseIf dlg.DropListBox1 = 1 Then
BoltSize = 6
ElseIf dlg.DropListBox1 = 2 Then
BoltSize = 7
ElseIf dlg.DropListBox1 = 3 Then
BoltSize = 8
ElseIf dlg.DropListBox1 = 4 Then
BoltSize = 10
ElseIf dlg.DropListBox1 = 5 Then
BoltSize = 12
ElseIf dlg.DropListBox1 = 6 Then
BoltSize = 14
ElseIf dlg.DropListBox1 = 7 Then
BoltSize = 16
ElseIf dlg.DropListBox1 = 8 Then
BoltSize = 18
ElseIf dlg.DropListBox1 = 9 Then
BoltSize = 20
ElseIf dlg.DropListBox1 = 10 Then
BoltSize = 22
ElseIf dlg.DropListBox1 = 11 Then
BoltSize = 24
ElseIf dlg.DropListBox1 = 12 Then
BoltSize = 27
ElseIf dlg.DropListBox1 = 13 Then
BoltSize = 30
ElseIf dlg.DropListBox1 = 14 Then
BoltSize = 33
ElseIf dlg.DropListBox1 = 15 Then
BoltSize = 36
ElseIf dlg.DropListBox1 = 16 Then
BoltSize = 39
Else
rc = App.feAppMessage(3, "Bolt size ERROR" )
End If

'rc = App.feAppMessage(2, "Selected bolt size: " & BoltSize & " [mm]" )

'input for bolt grade
Dim F_ub As Double
If dlg.DropListBox2 = 0 Then
F_ub = 500
ElseIf dlg.DropListBox2 = 1 Then
F_ub = 800
ElseIf dlg.DropListBox2 = 2 Then
F_ub = 1000
Else
rc = App.feAppMessage(3, "Grade selection ERROR" )
End If

'rc = App.feAppMessage(2, "Bolt ultimate tensile strength: " & F_ub & " [MPa]" )

'input for Allowable Overstress Ratio (OVR)
Dim OVR As Double
If dlg.DropListBox3 = 0 Then
OVR = 1.00
ElseIf dlg.DropListBox3 = 1 Then
OVR = 1.33
ElseIf dlg.DropListBox3 = 2 Then
OVR = 1.50
Else
rc = App.feAppMessage(3, "OVR selection ERROR" )
End If

'rc = App.feAppMessage(2, "Allowable Overstress Ratio: " & OVR )

'input for Thread in Shear Area
Dim TSA As Boolean
If dlg.Threads_included = 0 Then
TSA = False
ElseIf dlg.Threads_included = 1 Then
TSA = True
Else
rc = App.feAppMessage(3, "Thread selection ERROR" )
End If

'rc = App.feAppMessage(2, "Thread included in shear plane: " & TSA )

' calculate basic constants for AISC (ASD) code check 9th Edition, Table J3.2

'cross section area of bolt
Dim A_bolt As Double

A_bolt =Format( (BoltSize * BoltSize) * 3.1415926535 / 4 , "#.#0")' in [mm^2]

'Tensile capacity of one bolt
Dim fb_tensile As Double

fb_tensile = Format( 0.33 * A_bolt * F_ub, "#.0") ' in [N/mm2]

'Shear capacity of one bolt
Dim fb_shear As Double

If TSA = False Then
fb_shear =Format( 0.22 * A_bolt * F_ub, "#.0") ' in [N/mm2]

Else
fb_shear = Format(0.17 * A_bolt * F_ub, "#.0") ' in [N/mm2]
End If

rc = App.feAppMessage(2, "Selected bolt size: " & BoltSize & " [mm]; " & "Bolt Area: " & A_bolt & " [mm2]; Bolt ultimate tensile strength: " & F_ub & " [MPa]" & " ; Tensile capacity [N]: " & fb_tensile & " ; Shear capacity [N]: " & fb_shear )
rc = App.feAppMessage(2, "*")
rc = App.feAppMessage(2, "*")

'walk through all the selected output sets and all selected bolts
load_set.Reset

While load_set.Next

rc = App.feAppMessage(4, "Output Set: " & load_set.CurrentID & " *******************************************************************")
'create the header
'<-------1><-------2><-------3><-------4><-------5><-------6><-------7><-------8><-------9><------10>
rc = App.feAppMessage(2,"ElemID | Output Set |Axial Force [N] | Shear Force [N] | Allowable Axial Force [N] | Allowable Shear Force [N] | UC Axial | UC Shear | UC Combined | Status")

Elem_set.Reset

ouSetID = load_set.CurrentID

While Elem_set.Next

feElem.ID = Elem_set.CurrentID

'code here to extract the loads
ouVec1.setID = ouSetID
ouVec2.setID = ouSetID
ouVec3.setID = ouSetID

rc = ouVec1.Get( 3018 ) 'Beam Shear 1
rc = ouVec2.Get( 3019 ) 'Beam Shear 2
rc = ouVec3.Get( 3022 ) 'Beam Axial Force

shear1 = Format(ouVec1.Value( feElem.ID ),"#.0")
shear2 = Format(ouVec2.Value( feElem.ID ),"#.0")
axial = Format(ouVec3.Value( feElem.ID ),"#.0")

'rc = App.feAppMessage(2,"For Element " + Str$(feElem.ID) + " Axial, Total Shear " + Str$( axial ) + " " + Str$( totalShear ) )

'code to calculate shear force and consider tension only in bolts
totalShear = Format(Sqr( shear1 * shear1 + shear2 * shear2 ),"#.0")

If axial<0 Then
axial = 0
Else
'do nothing
End If


'code to calculate Unity Checks

UC_axial = Format( axial / fb_tensile , "#.00")
UC_shear = Format( totalShear/ fb_shear , "#.00")

' UC combined calculation is from Equation J3-3b of AISC 13th Edition!!!! As similar formula does not exist in AISC 9th Edition.

comb = 1.3 * fb_tensile - (fb_tensile / fb_shear) * totalShear

If fb_tensile < comb Then
UC_comb =Format( axial / fb_tensile , "#.00")
Else
UC_comb =Format( axial / comb , "#.00")
End If


If UC_axial < OVR And UC_shear < OVR And UC_comb < OVR Then
Status="OK"
Else
Status="Fail"
End If


'add code here to collect the max UC

If UC_max_axial<= UC_axial Then
UC_max_axial = UC_axial
Max_ID_axial = feElem.ID
Max_OS_axial = load_set.CurrentID

Else
'do nothing
End If

If UC_max_shear<= UC_shear Then
UC_max_shear = UC_shear
Max_ID_shear = feElem.ID
Max_OS_shear = load_set.CurrentID
Else
'do nothing
End If

If UC_max_comb<= UC_comb Then
UC_max_comb = UC_comb
Max_ID_comb = feElem.ID
Max_OS_comb = load_set.CurrentID
Else
'do nothing
End If

'add code here to write the output to the message window

'Formatting the output fields

OutText1 = Left(CStr(Elem_set.CurrentID) & " ", 9)
OutText2 = Left(CStr(load_set.CurrentID) & " ", 12)
OutText3 =Right(CStr( " " & axial) , 16)
OutText4 = Right(CStr(" " & totalShear) , 17)
OutText5 = Right(CStr(" " & fb_tensile) , 27)
OutText6 = Right(CStr(" " & fb_shear) , 27)
OutText7 = Right(CStr(" " & UC_axial) , 4)
OutText8 = Right(CStr(" " & UC_shear) , 4)
OutText9 = Right(CStr(" " & UC_comb) , 9)
OutText10 = Right(CStr(" " & Status) , 5)

'rc = App.feAppMessage(2,"ElemID | Output Set |Axial Force [N] | Shear Force [N] | Allowable Axial Force [N] | Allowable Shear Force [N] | UC Axial | UC Shear | Status")
rc = App.feAppMessage(2,OutText1 & "|" & OutText2 & "|" & OutText3 & "|" & OutText4 & "|" & OutText5 & "|" & OutText6 & "| " & OutText7 & " | " & OutText8 & " | " & OutText9 & " | " & OutText10)

Wend

Wend

'add the code check summary here

rc = App.feAppMessage(4, "****************************** Bolt Checks Summary ***********************************") 'black bold
rc = App.feAppMessage(2, " Max UC axial : " & UC_max_axial & " at element ID: " & Max_ID_axial & " OutPut Set ID: " & Max_OS_axial)
rc = App.feAppMessage(2, " Max UC shear: " & UC_max_shear & " at element ID: " & Max_ID_shear & " OutPut Set ID: " & Max_OS_shear)
rc = App.feAppMessage(2, " Max UC comb: " & UC_max_comb & " at element ID: " & Max_ID_comb & " OutPut Set ID: " & Max_OS_comb)


If UC_max_axial > OVR Or UC_max_shear > OVR Or UC_max_comb > OVR Then
Max_status = "FAIL"
Else
Max_status = "OK"
End If

rc = App.feAppMessage(4, " Overall Status: " & Max_status )

rc = App.feAppMessage(2, "***************************************************************************") ' blue text
rc = App.feAppMessage(3, "*** There may be other check necessary, like bearing and tear out!!! ****") ' red bold
rc = App.feAppMessage(4, "****************************** Finished ***********************************") 'black bold

End Sub