×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ETABS API- need some help for extract concrete frame quantties volume
2

ETABS API- need some help for extract concrete frame quantties volume

ETABS API- need some help for extract concrete frame quantties volume

(OP)
I am starting to use ETABS API with Python . I need to extract concrete quantites volume for frames elements (beams&columns). I believe I need to access to area of of all concrete elements and multiply by length or height ? I am not sure how to start with that in API . can somebody help or guide me with reference to learn more except for the etabs api docs ?

Thanks in advance

RE: ETABS API- need some help for extract concrete frame quantties volume

To use API, it's probably best to be using Python 3.0 or higher and you will require to import the modules comtypes. I recommend comtypes v1.1.7.

Also recommend using Anancoda spyder or similar for a python workspace.

1. run the python example in the help docs, this will link it to the CsiEtabsv1.tlb file in the installs folder.
2. after you have run this, it will setup a file in comtypes/gen folder. So next time you have your model open you will just need to run:

import comtypes;
EtabsObject=comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject");
SapModel=EtabsObject.SapModel;

3. Then you want to create some lists and start going thru the data. The functions you will likely need to use as a minimum will be

SapModel.FrameObj.GetAllFrames()
SapModel.PropMaterial.GetNameList()

Most of the getters in SapModel.PropFrame and SapModel.PropMaterial

Let me know how you go, I might be able to help you more during the work week.

RE: ETABS API- need some help for extract concrete frame quantties volume

(OP)
Thanks rscassar for your response .
after the reading the example , I maaaged to open the model and run it by API .
I will start to see those functions you mentioned and see how it works .
I let you know how it did go with me .

RE: ETABS API- need some help for extract concrete frame quantties volume

(OP)
Hello rscassar,
I made a progress in the API script . I managed to get length of all columns and area ,but I have one problem for model.PropFrame.GetRectangle("ConcCol")
function . It only gets width ,depth of the name of section column in function . I want to get (width,depth) of all of them and to be in a tuple .
I tried to use get selected funtion . but it didn't work out for me . below is the code I done

{

import os
import sys
import comtypes.client


def get_all_frames(model):
""" Retrieves select data for all frame objects in the model."""

res = model.FrameObj.GetAllFrames()
total_frames = res[0]
z1=res[8]
z2=res[11]
length = tuple(x-y for x,y in zip(z2,z1))

print("Total frames",total_frames)
print("length",length)

def select_columns(model):
#"select all columns in model to use it later for section_area function "

select = model.FrameObj.GetSelected("ConcCol")
# columns_names=[0]

def get_section_area(model):
#""retrieves section area of frames ""
sec_area = model.PropFrame.GetRectangle("ConcCol")
width = sec_area[2]
depth = sec_area[3]
print("width",width)
print("depth",depth)



ProgramPath = r"C:\Program Files\Computers and Structures\ETABS 17\ETABS.exe"

ModelPath = r"C:\Users\Mostafa\Desktop\python_exercise\example.EDB"
helper = comtypes.client.CreateObject('ETABSv17.Helper')
helper = helper.QueryInterface(comtypes.gen.ETABSv17.cHelper)
#create API helper object
myETABSObject = helper.CreateObject(ProgramPath)

#start ETABS application
myETABSObject.ApplicationStart()
#create SapModel object
SapModel = myETABSObject.SapModel
#initialize model
ret = SapModel.InitializeNewModel()

#open an existing file
ret = SapModel.File.OpenFile(ModelPath)
#run model (this will create the analysis model)
ret = SapModel.Analyze.RunAnalysis()
# selected_objects=SapModel.SelectObj.GetSelected();
# (number_objects_selected,(object_enumeration),(object_id),return_value

result=get_all_frames(SapModel)

result2=select_columns(SapModel)

result3=get_section_area(SapModel)
}

the output is
Total frames 64
length (3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0, 3000.0)
width 375.0
depth 375.0


I need to get width and depth in tuples of all 64 frames . (not only section name in propframe function )

What do you think ?


RE: ETABS API- need some help for extract concrete frame quantties volume

The function model.PropFrame.GetRectangle("ConcCol") will only work for rectangular sections. You probably want to use a more general function PropFrame.GetSectProps(Name)

What you want to to is something like this:

CODE --> python

#Get Frame Objects
frames = model.FrameObj.GetAllFrames()
#Get Frame Lengths
length = tuple(x-y for x,y in zip(z2,z1))
#Create an empty tuple and add frame Cross-sectional area
area=();
for frame_section in frames[2]:
    area+=(model.PropFrame.GetSectProps(frame_section)[0],) 

If you look into the nested list your created "res", this should contain 21 lists list0=number of frames; list1=frame_name (a unique number for all frame objects), list2=frame_section.

RE: ETABS API- need some help for extract concrete frame quantties volume

If you want to get width and depth, you will need to get the frame_name & frame_section, then get the frame type enumerator, then match the enumerator to the section type:

This will loop thru all the frames and get the relevant data

CODE --> python

all_frames=model.FrameObj.GetAllFrames();
for i in range(all_frames[0]):
    frame_name=all_frames[1][i];
    x0,y0,z0=all_frames[6][i],all_frames[7][i],all_frames[8][i];
    x1,y1,z1=all_frames[9][i],all_frames[10][i],all_frames[11][i];
    frame_section=all_frames[2][i];
    frame_type_enum=model.PropFrame.GetTypeOAPI(frame_section)[0];
    if(frame_type_enum==8):
        sect_type='rectangular';
        width,depth=model.PropFrame.GetRectangle(frame_section)[2:4];
    elif(frame_type_enum==9):
        sect_type='circular';
        width=model.PropFrame.GetCircle(frame_section)[2]; 

RE: ETABS API- need some help for extract concrete frame quantties volume

(OP)
Hello

Thanks alot for your help .


Regards


RE: ETABS API- need some help for extract concrete frame quantties volume

Hello all,

i'm new to Python and Etabs API. I'm trying to run the API example from CSi, but every time i'm running the code, i get the following error:



I've tried to delete and reinstall the "comtypes" package but it doesn't help.

Any idea why does this error happen and how to fix it?

Thanks

RE: ETABS API- need some help for extract concrete frame quantties volume

Probably best to start a new thread with questions than to add to existing threads.

Can you please confirm the following:
- Which python development environment that you are using (eg. Spyder).
- Which version of Etabs you have installed.
- Which version of comtypes you have installed, you will find this in the comtypes\__init__.py file.
- In the etabs install folder, what .tlb files do you have. Looks like you are using etabs v17, are they 'CSiAPIv1.tlb' and 'ETABSv1.tlb'.
- In the comtypes/gen folder, there should be some files that have been generated, open these files in a text editor and do they reference these tlb files.

Try opening etabs and running this script.

CODE --> python

import sys
import comtypes.client

try:
    myETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject") 
except (OSError, comtypes.COMError):
    print("No running instance of the program found or failed to attach.")
    sys.exit(-1)
SapModel = myETABSObject.SapModel 

RE: ETABS API- need some help for extract concrete frame quantties volume

Hi rscassar,

Quote (rscassar)

- Which python development environment that you are using (eg. Spyder).
- Which version of Etabs you have installed.
- Which version of comtypes you have installed, you will find this in the comtypes\__init__.py file.
- In the etabs install folder, what .tlb files do you have. Looks like you are using etabs v17, are they 'CSiAPIv1.tlb' and 'ETABSv1.tlb'.
- In the comtypes/gen folder, there should be some files that have been generated, open these files in a text editor and do they reference these tlb files.

- i'm using PyCharm
- Etabs 17
- comtypes version 1.1.7
- there are 3 .tlb files "ETABS.tlb", "ETABS2016.tlb", and "ETABSv17.tlb"
- there is reference only to ETABSv17.tlb

Quote (rscassar)

Try opening etabs and running this script.

After doing this i get the following Error:

Traceback (most recent call last):
File "C:/Users/Stefan/PycharmProjects/ETABS_API/TestFile.py", line 9, in <module>
SapModel = myETABSObject.SapModel
AttributeError: 'POINTER(IUnknown)' object has no attribute 'SapModel'

Process finished with exit code 1

Thanks for your help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close