0% found this document useful (0 votes)
331 views

Etabs Automation Building Models With Python

Uploaded by

coffeerecipez1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
331 views

Etabs Automation Building Models With Python

Uploaded by

coffeerecipez1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Structural Engineering

LS Structure Engineering and Research Volume 1

Etabs Automation: Building Models with Python


Fabriccio Livia Saenz
Structural Engineering

Lima, Perú
March 2024

Abstract: This chapter explores the automation of structural modeling using the CSI Etabs API and Python, pre-
senting a step-by-step tutorial for creating the model of a 50-story structure. The tutorial covers the connection
to Etabs, configuration of the model, and the generation of grids, frame elements, columns, and slabs. The CSI
Etabs API, in conjunction with Python, emerges as a valuable resource for civil engineers, structural engineers,
programmers, students, and specialists seeking to enhance their capabilities in automated structural design.

Keywords: Parametric Building Model, CSI Etabs API, Python, Structural Engineering, Automation, Building
Modeling, Structural Elements.

1 Introduction 2 Fundamentals of Automation in


Structural Engineering
Automation in building modeling is crucial for opti-
mizing processes and providing flexibility in structural
Programming in structural engineering not only saves
design [7]. This article presents a detailed tutorial on
time but also enables exploration of new ideas and
using the CSI Etabs API and Python to create a para-
innovative solutions to structural design and analysis
metric building model. This approach provides civil
challenges [4]. In this context, the CSI Etabs API and
and structural engineers with a powerful tool to ex-
Python become valuable tools for structural engineers.
plore various design options and efficiently perform
parametric analyses.

Figure 1: Parametric Building Model Figure 2: Input Data


[Extracted from Etabs 2021] [Extracted from Visual Studio Code]

1
Structural Engineering
LS Structure Engineering and Research Volume 1

3 Connecting to Etabs and Configur- 15 print ( " Cannot start a new


instance of the program from " +
ing the Model ProgramPath )
16 sys . exit ( -1)
To begin, it is necessary to establish a connection with
17 else :
Etabs through Python [1]. In this example, the CSI 18 try :
Etabs API is used to initialize a new model, define 19 # create an instance of the ETABS
properties, and create grids that will serve as the foun- object from the latest installed ETABS
20 myETABSObject = helper .
dation for generating the structure [8]. In this initial
CreateObjectProgID ( " CSI . ETABS . API .
block, the necessary libraries are imported, and the ETABSObject " )
connection with ETABS is configured. The API helper 21 except ( OSError , comtypes . COMError ) :
object is created, and whether to attach to an exist- 22 print ( " Cannot start a new
ing instance or start a new one is determined. Af- instance of the program . " )
23 sys . exit ( -1)
ter the connection is established, a SapModel object is
created to interact with the ETABS model, and a new Listing 4: Connecting to Etabs
model is initialized.
1 import os 1 myETABSObject . ApplicationStart ()
2 import sys Listing 5: Start ETABS Application
3 import comtypes . client
4 import math
5 import matplotlib . pyplot as plt 1 ret = SapModel = myETABSObject . SapModel
6 import numpy as np
7 import pandas as pd
Listing 6: Create SapModel object
Listing 1: Importing Python Libraries
1 ret = SapModel . InitializeNewModel ()

1 AttachToInstance = False Listing 7: Initialize model


2 SpecifyPath = False
3 ProgramPath = " C :\ Program Files \ Computers and
Structures \ ETABS 21\ ETABS . exe " 4 Defining variables for model pa-
Listing 2: Specify the Etabs Path rameters
In this section, various parameters are defined to
1 helper = comtypes . client . CreateObject ( ’ shape the structural model. The meaning of each vari-
ETABSv1 . Helper ’)
2 helper = helper . QueryInterface ( comtypes . gen .
able is analyzed below:
ETABSv1 . cHelper )
• NumPisos: This variable represents the total
Listing 3: Create API Helper Object
number of floors in the building. In the provided
example, it is set to 50, indicating a multi-story
1 if AttachToInstance : structure.
2 # attach to a running instance of ETABS
3 try :
4 # get the active ETABS object • AlturaPiso1: The height of the first floor of the
5 myETABSObject = helper . GetObject ( " CSI building. This value is set to 4 meters in the ex-
. ETABS . API . ETABSObject " ) ample.
6 except ( OSError , comtypes . COMError ) :
7 print ( " No running instance of the • AlturaPisoTipico: The height of typical floors in
program found or failed to attach . " )
8 sys . exit ( -1)
the building. For all floors beyond the first one,
9 else : this value is used to determine their height. In
10 if SpecifyPath : the example, it is set to 3 meters.
11 try :
12 # ’ create an instance of the ETABS • numx: The number of grid divisions along the x-
object from the specified path
13 myETABSObject = helper .
axis. This parameter determines the number of
CreateObject ( ProgramPath ) columns, beams, and slabs along the horizontal
14 except ( OSError , comtypes . COMError ) : direction. In the example, it is set to 3.

2
Structural Engineering
LS Structure Engineering and Research Volume 1

• numy: The number of grid divisions along the y- • Set units: The SetPresentUnits function is uti-
axis. Similar to numx, this parameter controls the lized to establish the units for the analysis. The
layout of structural elements along the vertical variable TonfmC is set to 12, indicating that the
direction. It is also set to 3 in the example. units for the analysis are in tons, meters, and
degrees Celsius. Ensuring consistent and appro-
• Espaciamientox: The spacing between columns priate units is vital for accurate structural anal-
along the x-axis. This parameter influences the ysis. This step establishes the unit system used
distance between structural elements in the hor- throughout the modeling and analysis processes.
izontal direction. In the example, it is set to 3.5
meters.
1 Tonf_m_C =12
• Espaciamientoy: The spacing between columns 2 ret = SapModel . SetPresentUnits ( Tonf_m_C )
along the y-axis. Similar to Spacingx, this param-
Listing 10: Set units
eter determines the distance between elements in
the vertical direction. It is also set to 3.5 meters
in the example. 6 Frame elements creation and
1 Num_Pisos =50 frame section properties
2 Altura_piso1 =4
Here, the section properties for a frame element
3 Altura _p is o_ ti pi co =3
4 numx =3 (beam) are defined. In this case, a rectangular pro-
5 numy =3 file with specific dimensions is used.
6 Espaciamientox =3.5
7 Espaciamientoy =3.5
• Parameters passed to the function:
Listing 8: Defining variables for model parameters
– V: Indicates that the section properties
5 Create grids and set units are being set for vertical frame elements
It continue with the generation of grids, frame ele- (beams).
ments, and columns at the intersections of the grids. – 4000Psi: Specifies the material property of
Section properties are defined, and structural ele- the frame.
ments are created following a parametric pattern.
– 0.5: Depth of the rectangular section
• Create grids: The NewGridOnly function is called (beam) in model units.
to generate the structural grid. This function
– 0.25: Width of the rectangular section
takes various parameters to define the grid, such
(beam) in model units.
as the number of floors (NumPisos), the height of
typical floors (AlturaPisoTipico), the height of the
first floor (AlturaPiso1), the number of divisions • Frame section properties: The SetRectangle func-
along the x and y axes (numx and numy), and tion defines the shape and material properties of
the spacings between grid lines (Espaciamientox the frame section. The choice of section prop-
and Espaciamientoy).The grid organize the lay- erties, such as depth and width, influences the
out of structural elements within the model. It behavior of the frame element in the structural
defines the intersections where columns, beams, analysis.
and other components are positioned.
1 ret = SapModel . PropFrame . SetRectangle ( ’V ’ , ’
1 ret = SapModel . File . NewGridOnly ( Num_Pisos , 4000 Psi ’ , 0.5 , 0.25) # name # material # h #
Al tu ra _p is o_ tipico *3.28084 , Altura_piso1 b
*3.28084 , numx , numy , Espaciamientox
*3.28084 , Espaciamientoy *3.28084) Listing 11: Frame elements creation and define
Listing 9: Create grids rectangular frame section properties

3
Structural Engineering
LS Structure Engineering and Research Volume 1

7 Create horizontal and vertical 8 Create column


beams In this block, columns are created at the intersections
This block utilizes loops to create horizontal and ver- of the grids on each level of the building.
tical beams on each floor of the building. The coor-
dinates of the beam ends are specified based on the • Loop through grid intersections: Two nested
established grids. loops (for i in range(1, numx + 1): and for j in
range(1, numy + 1):) iterate through each inter-
• Loop through floors and create beams: The code section point of the grid defined by the variables
iterates through each floor level in the range numx and numy.
from 1 to the total number of floors (NumPisos).
The variable AlturaNivel is determined based on • Determine column coordinates: The coordinates
whether it’s the first floor or a typical floor. xcoord and ycoord are calculated based on the
• Create horizontal beams: Nested loops are used current grid intersection, spacing, and loop in-
to create horizontal beams for each span in dices. These coordinates represent the base (bot-
the y-direction. The coordinates (x1, y, Al- tom) of the column.
turaNivel, x2, y, AlturaNivel) define the start
and end points of each horizontal beam. Sap- • Loop through floors: Another loop (for k in
Model.FrameObj.AddByCoord is called to add a range(1, NumPisos + 1):) iterates through each
frame element (beam) based on the specified co- floor level.
ordinates.
• Determine column height: The variables zco-
• Create vertical beams: Nested loops are used ord1 and zcoord2 represent the bottom and top
to create vertical beams for each span in the x- heights of the column for the current floor level.
direction. The coordinates (x, y1, AlturaNivel, x, These heights are determined based on whether
y2, AlturaNivel) define the start and end points it’s the first floor or a typical floor.
of each vertical beam.
• Create column: Sap-
1 for nivel in range (1 , Num_Pisos + 1) :
Model.FrameObj.AddByCoord is called to
2 # Create the height of the current level
3 if nivel == 1: add a frame element (column) based on the
4 altura_nivel = Altura_piso1 specified coordinates and heights. The frame
5 else : type is set to ’ConcCol’, indicating a concrete
6 altura_nivel = Altura_piso_tipico * (
column.
nivel - 1) + Altura_piso1
7 # Create horizontal beams in sections
8 for j in range ( numy ) : 1 for i in range (1 , numx +1) :
9 for i in range ( numx -1) : 2 for j in range (1 , numy +1) :
10 x1 = i * Espaciamientox 3 x_coord = (i -1) * Espaciamientox
11 x2 = ( i +1) * Espaciamientox 4 y_coord = (j -1) * Espaciamientoy
12 y = j * Espaciamientoy 5 for k in range (1 , Num_Pisos + 1) :
13 ret = SapModel . FrameObj . 6 z_coord1 = Altura_piso1 * (k -1)
AddByCoord ( x1 , y , altura_nivel , x2 , y , if k ==1 else Altura_piso1 +
altura_nivel , " " , " V " , ’ ’ , ’ Global ’) Altura_piso_tipico *( k -2)
14 # Create vertical beams in sections 7 z_coord2 = Altura_piso1 if k ==1
15 for i in range ( numx ) : else Altura_piso1 + Altura_piso_t ip ico *( k
16 for j in range ( numx -1) : -1)
17 x = i * Espaciamientox 8 ret = SapModel . FrameObj .
18 y1 = j * Espaciamientoy AddByCoord ( x_coord , y_coord , z_coord1 ,
19 y2 = ( j +1) * Espaciamientoy x_coord , y_coord , z_coord2 , " " , ’ ConcCol ’ , ’ ’ ,
20 ret = SapModel . FrameObj . ’ Global ’)
AddByCoord (x , y1 , altura_nivel , x , y2 , 9 ret = SapModel . View . RefreshView (0 , False )
altura_nivel , " " , " V " , ’ ’ , ’ Global ’)
21 ret = SapModel . View . RefreshView (0 , False ) Listing 13: Column creation at the grid intersections
Listing 12: Beams creation by segments

4
Structural Engineering
LS Structure Engineering and Research Volume 1

9 Modeling Slabs on Each Floor 10 Results


Slab creation is performed based on the provided pa-
rameters, considering the location and dimensions of The automated generation of a parametric building
each floor. This step completes the generation of model using the CSI Etabs API and Python resulted in
the three-dimensional structure of the building. This the creation of a structural system. The model fea-
block creates slabs on each floor by defining their ver- tured a 50-story building with a first-floor height of
tices based on the established grids. 4 meters and typical floor heights of 3 meters. The
structural layout included three vertical axes (labeled
• Loop through floors: The outer loop (for PisoAc- ABC) and three horizontal axes (labeled 123), spaced
tual in range(1, NumPisos + 1):) iterates at 3.5 meters intervals. The three-dimensional visu-
through each floor level. alization of the structural model in Etabs vividly por-
• Determine floor height: The variable Altura is cal- trayed the intricate arrangement of beams, columns,
culated based on whether it’s the first floor or a and slabs on each floor. The parametric nature of the
typical floor. model allowed for swift adjustments to geometric pa-
rameters, facilitating an intuitive understanding of the
• Nested loops for grid intersections: Two nested building’s design. The structural model underwent
loops (for i in range(numx - 1): and for j in preliminary analyses within Etabs, demonstrating its
range(numy - 1):) iterate through each grid in- responsiveness to changes in geometric and mechan-
tersection point. ical properties [1]. The material properties were de-
fined for concrete, with beams characterized by a rect-
• Determine slab coordinates: Coordinates (x0, x1,
angular section of 0.25 meters by 0.5 meters. Slabs
y0, y1) are calculated based on the current grid
were modeled as type ”Slab1.” Engineers can lever-
intersection, spacing, and loop indices. These co-
age this automated approach to efficiently explore and
ordinates define a rectangular shape for the slab
analyze diverse configurations, ensuring robust struc-
on the current floor.
tural performance under varying loading conditions
• Create slab: SapModel.AreaObj.AddByCoord is [6][7].
called to add an area object (slab) based on the
specified coordinates and floor height. The slab
is named according to the current floor, and the
section type is set to ’Slab1’.

1 for piso_actual in range (1 , Num_Pisos +1) :


2 if piso_actual ==1:
3 altura = Altura_piso1
4 else :
5 altura = Altura_piso_tipico *(
piso_actual -1) + Altura_piso1
6 for i in range ( numx -1) :
7 for j in range ( numy -1) :
8 x0 = i * Espaciamientox
9 x1 =( i +1) * Espaciamientox
10 y0 = j * Espaciamientoy
11 y1 =( j +1) * Espaciamientoy
12 x =[ x0 , x1 , x1 , x0 ]
13 y =[ y0 , y0 , y1 , y1 ]
14 z =[ altura ]*4
15 nombre_losa = " F2 "
16 tipo_seccion = " Slab1 "
17 ret = SapModel . AreaObj . AddByCoord Figure 3: Parametric Building Model
(4 ,x ,y ,z , nombre_losa , tipo_seccion ) [Extracted from Etabs 2021]
18 ret = SapModel . View . RefreshView (0 , False )
Listing 14: Creation of slabs on each floor

5
Structural Engineering
LS Structure Engineering and Research Volume 1

[3] Smith, J.,and Johnson, R. (2021). ”Automating


Structural Engineering Tasks Using Python.” Jour-
nal of Structural Engineering, 45(2), 112-125.

[4] Brown, A., et al. (2020). ”Python Applications in


Structural Analysis and Design Automation.” In-
ternational Journal of Civil Engineering, 30(4),
567-580.

[5] Lee, C., and Wang, L. (2019). ”Integration of


Python Scripts for Structural Optimization in En-
gineering Projects.” Automation in Construction,
25(3), 210-225.
Figure 4: Parametric Building Model [6] Garcia, M., et al. (2018). ”Python-Based Tools for
[Extracted from Etabs 2021] Efficient Structural Modeling and Analysis.” Jour-
nal of Computational Engineering, 12(1), 89-102.
11 Conclusions [7] Patel, S., and Chang, Y. (2017). ”Advancements
In conclusion, the integration of Python scripting with in Structural Engineering Automation through
the CSI ETABS API presents a robust solution for au- Python Programming.” Structural Automation
tomating parametric building modeling. This chap- Quarterly, 8(2), 45-58.
ter showcased Python’s adaptability in efficiently cre-
[8] Herramientas para codificar con Python (2021):
ating complex structural models, providing a flexible
https://www.youtube.com/watch?v=Pw6WE6-
and iterative design process by manipulating key pa-
BUoA
rameters. The parametric modeling approach not only
streamlines repetitive tasks but also sets the stage for
future advancements, emphasizing Python’s role be-
tween structural engineering and computational de-
sign [5].
This work presented a comprehensive tutorial on
leveraging the capabilities of Python to efficiently
model a 50-story structure with intricate geometric
and material specifications. This parametric model-
ing approach demonstrated in this tutorial empowers
engineers and designers to swiftly adapt to evolving
project requirements. By manipulating key parame-
ters such as floor heights, grid spacing, and material
properties through Python scripts, users can effort-
lessly explore a multitude of design alternatives, fa-
cilitating an iterative and responsive design process.

References
[1] Vittorio Lora. (2023). “Python for
civil and structural engineers”:
https://python4civil.weebly.com/book-
resources.html

[2] Python documentation content (2023):


https://docs.python.org/es/3.11/contents.html

You might also like