×
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

Add Area by Coord Method - ETABS API

Add Area by Coord Method - ETABS API

Add Area by Coord Method - ETABS API

(OP)
I'm trying to write some code in Python that draws a slab in ETABS. However, API documentation is scarce for Python for this method. An example is given for VB:

CODE

'add area object by coordinates
   ReDim x(5)
   ReDim y(5)
   ReDim z(5)
   x(0) = 50:   y(0) = 0
   x(1) = 100:  y(1) = 0
   x(2) = 150:  y(2) = 40
   x(3) = 100:  y(3) = 80
   x(4) = 50:   y(4) = 80
   x(5) = 0:    y(5) = 40
   ret = SapModel.AreaObj.AddByCoord(6, x, y, z, Name) 

I don't quite know how to manipulate this for Python. The C# documentation shows:

CODE

int AddByCoord(
	int NumberPoints,
	ref double[] X,
	ref double[] Y,
	ref double[] Z,
	ref string Name,
	string PropName = "Default",
	string UserName = "",
	string CSys = "Global"
) 

Should I be passing arrays of x,y,z coordinates? Does anyone know how to create the equivalent code in Python?

Thanks!

RE: Add Area by Coord Method - ETABS API

Attached is the method in the comtypes.gen py file.

CODE --> python

cAreaObj._methods_ = [
    COMMETHOD([dispid(1)], HRESULT, 'AddByCoord',
              ( ['in'], c_int, 'NumberPoints' ),
              ( ['in', 'out'], POINTER(_midlSAFEARRAY(c_double)), 'X' ),
              ( ['in', 'out'], POINTER(_midlSAFEARRAY(c_double)), 'Y' ),
              ( ['in', 'out'], POINTER(_midlSAFEARRAY(c_double)), 'Z' ),
              ( ['in', 'out'], POINTER(BSTR), 'Name' ),
              ( ['in', 'optional'], BSTR, 'PropName', 'Default' ),
              ( ['in', 'optional'], BSTR, 'UserName', '' ),
              ( ['in', 'optional'], BSTR, 'CSys', 'Global' ),
              ( ['out', 'retval'], POINTER(c_int), 'pRetVal' )), 

Your require four input needs to be:

NumberPoints: int
X: list (of float type)
Y: list (of float type)
Z: list (of float type)

For a 4-noded shell elements, the X, Y & Z lists must have five elements, the values need to go [node1,node2,node3,node4,node1].

General finite elements rules apply, element won't be added if nodes aren't collinear and I think you might get into trouble if adding a 4-node element with a reflexive internal angle.

My preference is to add an area element by add by point method.

CODE --> python

areaPts=()
areaPt1=SapModel.PointObj.AddCartesian(ptX1coord,ptY1coord,ptZ1coord)
areaPts+=(areaPt1[0],)
areaPt2=SapModel.PointObj.AddCartesian(ptX2coord,ptY2coord,ptZ2coord)
areaPts+=(areaPt2[0],)
areaPt3=SapModel.PointObj.AddCartesian(ptX3coord,ptY3coord,ptZ3coord)
areaPts+=(areaPt3[0],)
areaPt4=SapModel.PointObj.AddCartesian(ptX4coord,ptY4coord,ptZ4coord)
areaPts+=(areaPt4[0],)
nosPts=len(areaPts)
newArea=""
areaObj=SapModel.AreaObj.AddByPoint(nosPts,areaPts,newArea) 


RE: Add Area by Coord Method - ETABS API

This python code did the trick for me, be sure to add the refresh view part of the code or else you won't see the area object you created.

CODE --> Python

x = [0,0,100,0]
y = [0,100,100,0]
z = [0,0,0,0]
Name = '12'
UserName = ''

PropName = "Slab1"
area = SapModel.AreaObj.AddByCoord(4, x, y, z, Name, PropName, UserName)
ret = SapModel.View.RefreshView(0, False) 

S&T

RE: Add Area by Coord Method - ETABS API

rscassar, where is the comptypes.gen py file located?

Seems like there is a lot of good stuff in there as compared to just the .chm file that has been my only reference.

S&T

RE: Add Area by Coord Method - ETABS API

(OP)
Thank you both for the info, I appreciate how active you both are!

RE: Add Area by Coord Method - ETABS API

It will be located with your site packages. If u are using anaconda spyder as a python environoment, go

>> help(comtypes)

At the bottom, it will give file locations "c:\users\XXXXXX\anaconda3\lib\site-packages\comtypes\__init__.py"

In that comtypes folder, there will be a gen folder. In the gen folder there will be few files depending on how my programs u access through comtypes. Open the one that says ETAB2018.py, in that it will reference the file it uses will be an obscure filename "from comtypes.gen import _769D0CFD_A487_4251_A5D4_29A737893481_0_54_0".

This file will have all the classes and methods that you can use.


RE: Add Area by Coord Method - ETABS API

(OP)
Do you guys have any advice on the following thing:

I am trying to get ETABS to draw slab area elements on each floor using Python. I have a list containing point data for each node's XYZ coords on a given story:

CODE

[[[0.0, 0.0, 3.0], [0.0, 24.0, 3.0], [24.0, 24.0, 3.0], [24.0, 0.0, 3.0]], [[0.0, 0.0, 6.0], [0.0, 24.0, 6.0], [24.0, 24.0, 6.0], [24.0, 0.0, 6.0]], [[0.0, 0.0, 9.0], [0.0, 24.0, 9.0], [24.0, 24.0, 9.0], [24.0, 0.0, 9.0]]]] 

I have the following code which loops through to create a floor on the first floor (3m):

CODE

for i in range(len(slabCoordListTwo[0])):
    
        x.append(slabCoordListTwo[0][i][0])
        y.append(slabCoordListTwo[0][i][1])
        z.append(slabCoordListTwo[0][i][2])] 

This creates the x,y,z array for the first story set of nodes, but I'm not sure how to nest another for loop to do this for each story.

Do you have any advice?

RE: Add Area by Coord Method - ETABS API

your nested list is 3 deep. Are your extra stories in slabCoordListTwo[1] and slabCoordListTwo[2] etc.

If they are you can add an extra step to the loop:

CODE

for i in range(len(slabCoordListTwo)):
    for j in range(len(slabCoordListTwo[i])):
        x.append(slabCoordListTwo[i][j][0])
        y.append(slabCoordListTwo[i][j][1])
        z.append(slabCoordListTwo[i][j][2])] 

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