1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
| Sub GenerateModel()
'Create ETABS API Helper to crete new instance of ETABS App
Dim etHelper As ETABSv1.cHelper
Set etHelper = New ETABSv1.Helper
'Create ETABS new App Object
Dim etApp As ETABSv1.cOAPI
Set etApp = etHelper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
etApp.ApplicationStart
'Create new ETAB Model
Dim etModel As ETABSv1.cSapModel
Set etModel = etApp.sapModel
'Initialize new model with KN/m/C units
etModel.InitializeNewModel (eUnits.eUnits_kN_m_C)
'Set Concrete and Steel Design Codes
etModel.DesignConcrete.SetCode ("IS 456:2000")
etModel.DesignSteel.SetCode ("IS 800:2007")
'Create new grid only model
dim numberOfStories as Integer
dim storyHeight as Double,bottomStoryHeight as Double
dim numberOfLinesX As Integer,numberOfLinesY As Integer
dim spacingX As Double,spacingY As Double
numberOfStories = 4
storyHeight = 3.0 'meter
bottomStoryHeight = 3.0 'meter
numberOfLinesX = 4
numberOfLinesY = 4
spacingX = 5.0 'meter
spacingY = 5.0 'meter'
etModel.File.NewGridOnly numberOfStories, storyHeight, bottomStoryHeight, numberOfLinesX, numberOfLinesY, spacingX, spacingY
'Define Material Properties
Dim concreteGrade As String, steelGrade As String
concreteGrade = "M30"
steelGrade = "HYSD500"
etModel.PropMaterial.AddMaterial concreteGrade, eMatType_Concrete, "India", "Indian", concreteGrade
etModel.PropMaterial.AddMaterial steelGrade, eMatType_Rebar, "India", "Indian", "HYSD Grade 500"
'Create New Rectangular Beam section
Dim beamSection as String
Dim beamWidth As Double, beamDepth As Double, beamCover as Double
beamSection= "B300X500"
beamDepth = 0.5 ' meters
beamWidth = 0.3 ' meters
beamCover = 0.04 ' meters
etModel.PropFrame.SetRectangle beamSection, concreteGrade, beamDepth, beamWidth
'Set reinforcement data
etModel.PropFrame.SetRebarBeam beamSection, steelGrade, steelGrade, beamCover, beamCover, 0, 0, 0, 0
'Create new rectangular column section
Dim columnSection As String
Dim columnWidth As Double, columnDepth As Double, columnCover As Double
columnSection = "C400X400"
columnDepth = 0.4 ' meters
columnWidth = 0.4 ' meters
columnCover = 0.04 ' meters
etModel.PropFrame.SetRectangle columnSection, concreteGrade, columnDepth, columnWidth
'Set reinforcement data
etModel.PropFrame.SetRebarColumn columnSection, steelGrade, steelGrade, 1, 1, columnCover, 0, 3, 3, "20", "10", 0.2, 3, 3, True
'Create new Slab with 125 mm
Dim slabSection As String
Dim slabThickness As Double
Dim slabType As eSlabType, shellType As eShellType
slabSection = "S125"
slabThickness = 0.125 ' meters
slabType = eSlabType_Slab
shellType = eShellType_ShellThin
etModel.PropArea.SetSlab slabSection, slabType, shellType, concreteGrade, slabThickness
Dim i As Integer, j As Integer, k As Integer
Dim x1 As Double, y1 As Double, z1 As Double
Dim x2 As Double, y2 As Double, z2 As Double
'Assign All Columns
x1 = 0: y1 = 0: z1 = 0
x2 = 0: y2 = 0: z2 = bottomStoryHeight
For i = 0 To numberOfStories - 1
y1 = 0
y2 = 0
For k = 0 To numberOfLinesY - 1
x1 = 0
x2 = 0
For j = 0 To numberOfLinesX - 1
'Add columns at grid points
etModel.FrameObj.AddByCoord x1, y1, z1, x2, y2, z2, "", columnSection
x1 = x1 + spacingX
x2 = x2 + spacingX
Next j
y1 = y1 + spacingY
y2 = y2 + spacingY
Next k
If i = 0 Then
z1 = z1 + bottomStoryHeight
Else
z1 = z1 + storyHeight
End If
z2 = z2 + storyHeight
Next i
'Assign All Beams in X Direction
x1 = 0: y1 = 0: z1 = bottomStoryHeight
x2 = spacingX: y2 = 0: z2 = bottomStoryHeight
For i = 0 To numberOfStories - 1
y1 = 0
y2 = 0
For k = 0 To numberOfLinesY - 1
x1 = 0
x2 = spacingX
For j = 0 To numberOfLinesX - 2
'Add columns at grid points
etModel.FrameObj.AddByCoord x1, y1, z1, x2, y2, z2, "", beamSection
x1 = x1 + spacingX
x2 = x2 + spacingX
Next j
y1 = y1 + spacingY
y2 = y2 + spacingY
Next k
z1 = z1 + storyHeight
z2 = z2 + storyHeight
Next i
'Assign All beams in Y Direction
x1 = 0: y1 = 0: z1 = bottomStoryHeight
x2 = 0: y2 = spacingY: z2 = bottomStoryHeight
For i = 0 To numberOfStories - 1
y1 = 0
y2 = spacingY
For k = 0 To numberOfLinesY - 2
x1 = 0
x2 = 0
For j = 0 To numberOfLinesX - 1
'Add columns at grid points
etModel.FrameObj.AddByCoord x1, y1, z1, x2, y2, z2, "", beamSection
x1 = x1 + spacingX
x2 = x2 + spacingX
Next j
y1 = y1 + spacingY
y2 = y2 + spacingY
Next k
z1 = z1 + storyHeight
z2 = z2 + storyHeight
Next i
'Assign Slab
Dim x() As Double, y() As Double, z() As Double
ReDim x(3), y(3), z(3)
x(0) = 0: y(0) = 0: z(0) = bottomStoryHeight
x(1) = spacingX: y(1) = 0: z(1) = bottomStoryHeight
x(2) = spacingX: y(2) = spacingY: z(2) = bottomStoryHeight
x(3) = 0: y(3) = spacingY: z(3) = bottomStoryHeight
'etModel.AreaObj.AddByCoord 4, x, y, z, "", slabSection
For i = 0 To numberOfStories - 1
y(0) = 0
y(1) = 0
y(2) = spacingY
y(3) = spacingY
For k = 0 To numberOfLinesY - 2
x(0)= 0
x(1)= spacingX
x(2)= spacingX
x(3)= 0
For j = 0 To numberOfLinesX - 2
'Add columns at grid points
etModel.AreaObj.AddByCoord 4, x, y, z, "", slabSection
x(0)= x(0) + spacingX
x(1)= x(1) + spacingX
x(2)= x(2) + spacingX
x(3)= x(3) + spacingX
Next j
y(0) = y(0) + spacingY
y(1) = y(1) + spacingY
y(2) = y(2) + spacingY
y(3) = y(3) + spacingY
Next k
z(0) = z(0) + storyHeight
z(1) = z(1) + storyHeight
z(2) = z(2) + storyHeight
z(3) = z(3) + storyHeight
Next i
'Assign Supports
Dim restrains() As Boolean
ReDim restrains(5)
For i = 0 To 5
restrains(i) = True
Next i
Dim totalSupports As Integer
totalSupports = numberOfLinesX * numberOfLinesY
For i = 0 To totalSupports - 1
etModel.PointObj.SetRestraint i * 2 + 1, restrains
Next i
'Assign load Patterns
Dim loadPatternName As String
Dim loadPatternType As eLoadPatternType
Dim selfWeightMultiplier As Double
'Floor Finish + Ceiling Plaster
loadPatternName = "FF+CP"
loadPatternType = eLoadPatternType_SuperDead
selfWeightMultiplier = 0
etModel.LoadPatterns.Add loadPatternName, loadPatternType, selfWeightMultiplier
'Wall Load
loadPatternName = "Wall Load"
loadPatternType = eLoadPatternType_SuperDead
selfWeightMultiplier = 0
etModel.LoadPatterns.Add loadPatternName, loadPatternType, selfWeightMultiplier
'Add Live load to all slabs
Dim slabId As String
Dim slabLoadPatternName As String
Dim slabLoad As Double
Dim slabLoadDir As Integer
Dim slabIsReplaceExisting As Boolean
Dim ret As Integer
slabId = "ALL"
slabLoadPatternName = "Live"
slabLoad = 2
slabLoadDir = 10 '10 for downward direction Gravity
slabIsReplaceExisting = True
etModel.AreaObj.SetLoadUniform slabId, slabLoadPatternName, slabLoad, slabLoadDir, slabIsReplaceExisting,"Global", eItemType_Group
'Add Floor Finish + Ceiling Plaster to all slabs
slabId = "ALL"
slabLoadPatternName = "FF+CP"
slabLoad = 1.5
slabLoadDir = 10 '10 for downward direction Gravity
slabIsReplaceExisting = True
etModel.AreaObj.SetLoadUniform slabId, slabLoadPatternName, slabLoad, slabLoadDir, slabIsReplaceExisting,"Global", eItemType_Group
'Assign Wall loads
Dim frameId As Long
Dim frameLoadPatternName As String
Dim frameLoad As Double
Dim frameLoadDir As Integer
frameLoadPatternName = "Wall Load"
frameLoad = 8
frameLoadDir = 10 '10 for downward direction Gravity
'Assign load in X direction beams
frameId = 1 + numberOfLinesX * numberOfLinesY * numberOfStories
For i = 0 To numberOfStories - 1
For j = 0 To numberOfLinesX - 2
etModel.FrameObj.SetLoadDistributed frameId, frameLoadPatternName, 1, frameLoadDir, 0, 1, frameLoad, frameLoad
frameId = frameId + 1
Next j
'Skip Interior Beams
frameId = frameId + (numberOfLinesX - 1) * (numberOfLinesY-2)
For j = 0 To numberOfLinesX - 2
etModel.FrameObj.SetLoadDistributed frameId, frameLoadPatternName, 1, frameLoadDir, 0, 1, frameLoad, frameLoad
frameId = frameId + 1
Next j
Next i
'Assign load in Y direction beams
For i = 0 To numberOfStories - 1
For j = 0 To numberOfLinesY - 2
etModel.FrameObj.SetLoadDistributed frameId, frameLoadPatternName, 1, frameLoadDir, 0, 1, frameLoad, frameLoad
frameId = frameId + (numberOfLinesX - 1)
etModel.FrameObj.SetLoadDistributed frameId, frameLoadPatternName, 1, frameLoadDir, 0, 1, frameLoad, frameLoad
frameId = frameId + 1
Next j
Next i
'Add Load combinations
Dim comboName As String
Dim comboType As Long
Dim comboLoadType As eCNameType
comboName = "DL+LL+SIDL"
comboType = 0 'Linear
comboLoadType = eCNameType.eCNameType_LoadCase
etModel.RespCombo.Add comboName, comboType
'Add All load cases to combination with load factor 1
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Dead", 1
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Live", 1
etModel.RespCombo.SetCaseList comboName, comboLoadType, "FF+CP", 1
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Wall Load", 1
comboName = "1.5(DL+LL+SIDL)"
comboType = 0 'Linear
comboLoadType = eCNameType.eCNameType_LoadCase
etModel.RespCombo.Add comboName, comboType
'Add All load cases to combination with load factor 1.5
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Dead", 1.5
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Live", 1.5
etModel.RespCombo.SetCaseList comboName, comboLoadType, "FF+CP", 1.5
etModel.RespCombo.SetCaseList comboName, comboLoadType, "Wall Load", 1.5
'Save model
etModel.File.Save GetModelFilePath()
'Run analysis
etModel.Analyze.RunAnalysis
'Close ETABS
etApp.ApplicationExit (False)
'Clean up variables
Set etModel = Nothing
Set etApp = Nothing
End Sub
Public Function GetModelFilePath() As String
'This function returns the path to the ETABS model file
Dim etabsFolder As String
etabsFolder = ThisWorkbook.Path & "\ETABS"
If Dir(etabsFolder, vbDirectory) = "" Then
MkDir etabsFolder
End If
GetModelFilePath = etabsFolder & "\Model.EDB"
End Function
|