Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ETABS API - GetGridSys_2

Status
Not open for further replies.

fracture_point

Structural
Mar 7, 2019
58
I'm writing some code to draw gridlines through the API using Python, but for some reason the ETABS model does doesn't reflect the data. There is no error showing in my console so it seems like the code passes.

Code:
xGrids = [0,5,15]
yGrids = [0,5,15]
xGridNames = ["1","2","3"]
yGridNames = ["A","B","C"]
xVisible = [True,True,True]
yVisible = [True,True,True]
xBubbleLoc = ["Start", "Start", "Start"]
yBubbleLoc = ["Start", "Start", "Start"]

SapModel.GridSys.GetGridSys_2("G1",0,0,0,"Cartesian",3,3,xGridNames,yGridNames,xGrids,yGrids,xVisible,yVisible,xBubbleLoc,yBubbleLoc)

This is based on the CSI API info:

Code:
int GetGridSys_2(
	string Name,
	ref double Xo,
	ref double Yo,
	ref double RZ,
	ref string GridSysType,
	ref int NumXLines,
	ref int NumYLines,
	ref string[] GridLineIDX,
	ref string[] GridLineIDY,
	ref double[] OrdinateX,
	ref double[] OrdinateY,
	ref bool[] VisibleX,
	ref bool[] VisibleY,
	ref string[] BubbleLocX,
	ref string[] BubbleLocY

Is anyone able to identify my issue?
 
Replies continue below

Recommended for you

I do not think the GetGridSys_2 allows you to draw/create gridlines, it will only return gridlines that have already been defined in the model.

Searching the API, I do not see a function that allows you to create gridlines unfortunately.

S&T
 
sticksandtriangles said:
I do not think the GetGridSys_2 allows you to draw/create gridlines, it will only return gridlines that have already been defined in the model.

Searching the API, I do not see a function that allows you to create gridlines unfortunately.

Interesting. I thought named the feature 'Get' was unusual but the inputs required seemed to make me think this method would draw grids, seeing as though it requires an array of numbers.

I have emailed CSI for official confirmation. I'll check back once I have a response.
 
I got the following response from CSI:

(I haven't tested it yet)

If you are using ETABS v18 or v19, you can use the cDatabaseTables functions in the API to modify the "Grid Definitions - Grid Lines" table, which can be used to change the location of gridlines. The cDatabaseTables interface is documented in the ETABS API documentation, the file "CSi API ETABS v1.chm" in the directory where ETABS v18 or v19 has been installed.
 
Looks like GridSys has getters but no setters.

Python:
SapModel.GridSys.GetNameList()
Out[6]: [1, ('G1',), 0]

SapModel.GridSys.GetGridSys('G1')
Out[8]: [0.0, 0.0, 0.0, 0]

SapModel.GridSys.GetGridSysCartesian('G1')
Out[9]: 
[0.0,
 0.0,
 0.0,
 True,
 None,
 None,
 1250.0,
 0,
 4,
 ('1', '2', '3', '4'),
 (-66.7, 5753.0, 12460.0, 18050.0),
 (True, True, True, True),
 ('b', 'b', 'b', 'b'),
 5,
 ('E', 'D', 'C', 'B', 'A'),
 (-27310.0, -19810.0, -14940.0, -7493.0, -2336.0),
 (True, True, True, True, True),
 ('a', 'a', 'a', 'a', 'a'),
 0,
 (),
 (),
 (),
 (),
 (),
 (),
 (),
 0]

There is no method GridSys.SetGridSysCartesian
 
I just started playing with the cDatabaseTables methods (for a different reason than grids) and these methods seem quite powerful.

Anything that you could manipulate in the interactive database is now available to you through the API. It took a good bit of playing around to get the functions to work though which was frustrating, not the most intuitive.

S&T
 
sticksandtriangles said:
It took a good bit of playing around to get the functions to work though which was frustrating, not the most intuitive

Any chance you can share some of your findings? What type of playing around did you have to do?

Cheers!
 
Below is some sample code that makes one gridline with the CDatabaseTables methods.

Python:
FieldsKeysIncluded = ['Name',
 'Grid Line Type',
 'ID',
 'Ordinate',
 'Angle',
 'X1',
 'Y1',
 'X2',
 'Y2',
 'Bubble Location',
 'Visible']
NumberRecords = 1
data = [ 'G1',
 'Y (Cartesian)',
 'test',
 '1500',
 '',
 '',
 '',
 '',
 '',
 'Start',
 'Yes',]
        

y = SapModel.DatabaseTables.SetTableForEditingArray(TableKey,TableVersion,FieldsKeysIncluded, NumberRecords,data)              
    
FillImport = True
z= SapModel.DatabaseTables.ApplyEditedTables(FillImport)
Reviewing the grids, you can see that the test grid has been added.

image1_yjqxtj.png



S&T
 
Fracturepoint, does this work for you?

It was working for me, but after reinstalling some stuff, I now get the following error:

Python:
y = SapModel.DatabaseTables.SetTableForEditingArray(TableKey,TableVersion,FieldsKeysIncluded, NumberRecords,data)

COMError: (-2147467262, 'No such interface supported', (None, None, None, 0, None))

I am running comtypes 1.1.8 and Etabs version 19.0.2.


S&T
 
Hi,
I had the same error for some of methods in FrameObj class. If you have access plz try to run your code by ETABs 18.1.1. I did that and every things work well. I don't know why! but my code sometimes have problem with ETABs 19.0.2 and sometimes is OK. I think there is something with comtypes and windows. I am trying to figure it out. will share my experience here.
remember you need to export and import model as .e2k to be able to run it on version 18.1.1
Regards,
 
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,
 
Thanks Ruhi, appreciate the follow through. I will have to try this out.

At this point our IT guy hates me...

S&T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor