×
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 - FrameObj.GetSection

ETABs API - FrameObj.GetSection

ETABs API - FrameObj.GetSection

(OP)
I am trying to retrieve the section properties of specific frame elements with python; it seems like this should be really easy.
Sample code is shown below:

CODE --> Python

Frame = "33"
PropName = ""
SAuto = ""
x = SapModel.FrameObj.GetSection(Frame, SAuto, PropName) 

This is the error that I get:

CODE --> Python

Traceback (most recent call last):
  File "C:/______/Desktop/Python/v1_Get_Section_Property.py", line 16, in <module>
    x = SapModel.FrameObj.GetSection(Frame, SAuto, PropName)
  File "C:\Users\____\AppData\Local\Continuum\anaconda3\lib\site-packages\comtypes\__init__.py", line 655, in call_with_inout
    rescode = func(self_, *args, **kw)
_ctypes.COMError: (-2147417851, 'The server threw an exception.', (None, None, None, 0, None)) 

After receiving this error, ETABs proceeds to crash and shut down, any ideas on how to solve?

Thanks!

S&T

RE: ETABs API - FrameObj.GetSection

unsure why it would crash, if looking to get sections properties for a given frame (unique id='33'). I would try the following:

I wrote this a while back, it may be worth going thru. After getting the assigned section for frame '33', you need to get the type of section given by a CSi enumerator, such as 'rectangle', 'circle' 'I'. And from that you can get the section properties. There is a basic function that will extract the basic data SapModel.PropFrame.GetGeneral(name), this function will give you the general section properties.

CODE --> python

def getAllFrameProps(SapModel):
    """
    @returns frameProps
    """
    allFrameProps=SapModel.PropFrame.GetAllFrameProperties()
    frameProps=[]
    propTypeEnum=['I','Channel','T','Angle','DblAngle','Box','Pipe',
                  'Rectangular','Circle','General','DbChannel','Auto','SD',
                  'Variable','Joist','Bridge','Cold_C','Cold_2C','Cold_Z',
                  'Cold_L','Cold_2L','Cold_Hat','BuiltupICoverplate',
                  'PCCGirderI','PCCGirderU','BuiltupIHybrid','BuiltupUHybrid',
                  'Concrete_L','FilledTube','FilledPipe','EncasedRectangle',
                  'EncasedCircle','BucklingRestrainedBrace','CoreBrace_BRB',
                  'ConcreteTee','ConcreteBox','ConcretePipe','ConcreteCross',
                  'SteelPlate','SteelRod']
    matTypeEnum=['Steel','Concrete','NoDesign','Aluminum','ColdFormed','Rebar',
                 'Tendon','Masonry']
    for i in range(allFrameProps[0]):
        propName=allFrameProps[1][i]
        propType=allFrameProps[2][i]  
        propTypeStr=propTypeEnum[propType-1]
        if(propTypeStr=='Rectangular'):
            propParam=SapModel.PropFrame.GetRectangle(propName)
            propMat=propParam[1]
            propDimX=propParam[2]
            propDimY=propParam[3]
        elif(propTypeStr=='Circle'):
            propParam=SapModel.PropFrame.GetCircle(propName)
            propMat=propParam[1]
            propDimX=propParam[2]
            propDimY=0
        elif(propTypeStr=='I'):
            propParam=SapModel.PropFrame.GetISection(propName)
            propMat=propParam[1]
            propDimX='stdSect'
            propDimY='stdSect'
        else:
            propMat=SapModel.PropFrame.GetMaterial(propName)[0]#.value
        mat=SapModel.PropMaterial.GetMaterial(propMat)
        matType=mat[0]
        matTypeStr=matTypeEnum[matType-1]
        if(matTypeStr=='Concrete'):
            matLocal=SapModel.PropMaterial.GetOConcrete(propMat)
            matGrade=matLocal[0]
        elif(matTypeStr=='Steel'):
            matLocal=SapModel.PropMaterial.GetOSteel(propMat)
            matGrade=matLocal[0]
        elif(matTypeStr=='NoDesign' and 'GLT' in propName):
            matTypeStr='Wood'
            propNameSplit=re.split("[ Xx]",propName)
            propDimX=int(propNameSplit[0])
            propDimY=int(propNameSplit[1])
            matGrade=propNameSplit[2]
        frameProps+=[[propName,propTypeStr,matTypeStr,matGrade,propDimX,propDimY]]
    return frameProps; 

RE: ETABs API - FrameObj.GetSection

(OP)
Thanks rscassar, that helps me in the future.
For now, I am still stuck as I can not identify the section property of frame object '33', in my case a W18x35

Is there any other API function that takes unique name and returns section property?

I am at a loss on why

CODE --> Python

x = SapModel.FrameObj.GetSection(Frame, SAuto, PropName) 
throws an error to me.

CSI technical support has been of little help banghead

S&T

RE: ETABs API - FrameObj.GetSection

(OP)
Seems like I always find a solution right after I have admitted defeat... the LineElm.GetProperty function does the trick for me.

Still curious why the first function does not work

S&T

RE: ETABs API - FrameObj.GetSection

(OP)
Damn, I take it back, LineElm.GetProperty only works if the beam is a simple span beam, girders do not seem to have output...

S&T

RE: ETABs API - FrameObj.GetSection

Try only input the frame id '33'.

CODE --> python

SAuto, PropName, ret = SapModel.FrameObj.GetSection(Frame) 

If you look thru the cFrameObj methods, you'll come to GetSection. The only input that is the frame name. 'PropName', 'SAuto and 'pRetVal' will be returned as output.

CODE --> python

cFrameObj._methods_ = [
    COMMETHOD([dispid(38)], HRESULT, 'GetSection',
              ( ['in'], BSTR, 'Name' ),
              ( ['in', 'out'], POINTER(BSTR), 'PropName' ),
              ( ['in', 'out'], POINTER(BSTR), 'SAuto' ),
              ( ['out', 'retval'], POINTER(c_int), 'pRetVal' )) 

RE: ETABs API - FrameObj.GetSection

(OP)
So weird, still get the same error, I have not had any trouble with any other functions in the API.

CODE --> Python

import comtypes.client

ProgramPath = r"C:\Program Files\Computers and Structures\ETABS 18\ETABS.exe"
ModelPath = r"C:\Users\______\Desktop\ETABs Models\test shears\shear end rxns.EDB"
helper = comtypes.client.CreateObject('ETABSv1.Helper')
helper = helper.QueryInterface(comtypes.gen.ETABSv1.cHelper)
#create API helper object
ETABSObject = comtypes.client.GetActiveObject("CSI.ETABS.API.ETABSObject")
SapModel = ETABSObject.SapModel


frame = '33'
PropName = ""
SAuto = ""
ret = -1
SAuto, PropName, ret = SapModel.FrameObj.GetSection(frame, PropName, SAuto) 

Error code:

CODE --> Python

runfile('C:/Users/aguter/Desktop/Python/v3_Get_Section_Property.py', wdir='C:/Users/aguter/Desktop/Python')
Traceback (most recent call last):

  File "C:\Users\______\Desktop\Python\v3_Get_Section_Property.py", line 18, in <module>
    SAuto, PropName, ret = SapModel.FrameObj.GetSection(frame, PropName, SAuto)

  File "C:\Users\______\Anaconda3\lib\site-packages\comtypes\__init__.py", line 655, in call_with_inout
    rescode = func(self_, *args, **kw)

COMError: (-2147417851, 'The server threw an exception.', (None, None, None, 0, None)) 

S&T

RE: ETABs API - FrameObj.GetSection

try just the frame as single input paramater

>> outputs = SapModel.FrameObj.GetSection(frame);

If that works than have a look at what is stored in outputs.

RE: ETABs API - FrameObj.GetSection

(OP)
Still no dice, same error code.

CODE --> Python

frame = '33'
x = SapModel.FrameObj.GetSection(frame) 

I appreciate all help rscassar, I will let you know what tecch support says when they get back to me.

S&T

RE: ETABs API - FrameObj.GetSection

(OP)
Closing the loop on this case anyone else has this trouble, I upgraded from ETABs v18 to v19 and the issue has been resolved.

S&T

RE: ETABs API - FrameObj.GetSection

Hi
I have the same problem with some of the API methods such as: FrameObj.GetAllFrames(), FrameObj.GetDesignOrientation(), FrameObj.GetNameList() and so on
It is interesting that when I run my code on another Laptop, all are ok and no error occurs. here is some information about both laptops:
1) win 10, Lenovo Legion5 core i7 10th Gen, Using Etabs 18.1.1 (methods do not work on this one)
2) win 10, Samsung series5 core i2 3rd Gen, Using Etabs 18.1.1 (methods work well)

I wrote the code by second laptop and when try to test the .exe file on the first one, errors appears. I found that the second laptop can not get some parameters from the SapModel and then tried to test more methods and found that happens for lots of methods in FrameObj while some of them such as GetElm or GetGUID works well. I should mention that I tested the main code by VSCode on both laptops.

I am trying to figure it out, I will share my experience here and will be glad to here from you.
Regards

RE: ETABs API - FrameObj.GetSection

Hi again,

I have both etabs 19.0.2 and 18.1.1 on my laptop. I ran my code using ETABs 19.0.2 and surprisingly it worked while it didn't work before! I did nothing expect reinstalling comtypes version 1.1.10
my code has two part, it can start a new instance of Etabs or can get the active object since for complex models it takes some time to analyze the model. By this, If I analyze the model one time, I can run my code for that model several times without reanalyze. I can not find out why my code can not get information about frame objects when it uses existing Etabs object, while the same code works well by opening a new instance of Etabs. Wow! FrameObj.GetAllFrame() should work always! I'm confused.
After this experience I start to check Etabs version 18.1.1 again and every thing works well!!!! the code is doing well for both cases, even open new instance of Etabs or get the active object!

So as a result, I think that there is something with comtypes and windows. I will post more if I found anything especial.
Regrads

RE: ETABs API - FrameObj.GetSection

There has been some changes with the python in Etabs v19. They have put it in there release notes the EtabsAPI.chm now has a header for using python. I use this new function

CODE --> python

def attachToInstance2019():
    AttachToInstance = True
    #create API helper object
    helper = comtypes.client.CreateObject('ETABSv1.Helper')
    helper = helper.QueryInterface(comtypes.gen.ETABSv1.cHelper)
    
    if AttachToInstance:
        #attach to a running instance of ETABS
        try:
            #get the active ETABS object
            myETABSObject = helper.GetObject("CSI.ETABS.API.ETABSObject") 
        except (OSError, comtypes.COMError):
            print("No running instance of the program found or failed to attach.")
            sys.exit(-1)
    else:
        sys.exit(-1)

    #create SapModel object
    SapModel = myETABSObject.SapModel
    return SapModel,myETABSObject,helper; 

RE: ETABs API - FrameObj.GetSection

Thanks rscassar,
I still have problem with FrameObj.GetAllFrames() and FrameObj.GetDesignOrientation(frameName). I asked from support@csiamerica.com and will let you know if I get a proper response.

RE: ETABs API - FrameObj.GetSection

Hi again,
It is just required to re-register ETABS.
Here is what you need to do: (CSI response)

We suggest re-registering the ETABS API on your machine:
1. Close all instances of ETABS and any software accessing the ETABS API (e.g. Excel).
2. Open an administrative command prompt (open Command Prompt using right-click, “Run as administrator”).
3. Within the administrative command prompt, navigate to the directory of ETABS v18.1.1.
4. Within the administrative command prompt, run “UnregisterETABS.exe”.
5. Repeat steps 3 and 4 for all versions of ETABS installed on the machine.
6. Within the administrative command prompt, navigate to the installed ETABS v18.1.1.
7. Within the administrative command prompt, run “RegisterETABS.exe”.

Regrads,

RE: ETABs API - FrameObj.GetSection

(OP)
Wow, that is ridiculous! Thanks for posting the feedback.

S&T

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