Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

ETABS API-2016

Status
Not open for further replies.

hamedall

Structural
Joined
Oct 7, 2024
Messages
2
Location
CA
i want to create custom grid lines in etabs2016 API by Python. Has anybody solved how to create custom grid lines?
 
you want to use database tables

Python:
def add_gridlines_for_system(SapModel,grid_sys,gridlines,
                              ord_type='coord'):
    """
    grid_sys='G1';
    gridlines=[['01',[-19660,20910],[-22520,43740]],
                ['02',[-8614,24430],[-12540,45580]],
                ['03',[-5529,24240],[-9604,46210]],
                ['04',[6046,25720],[22.4,48720]]
              ];
    """
    table_key2='Grid Definitions - Grid Lines';
    grid_gen=get_table_for_editing_array(table_key2,SapModel);
    table_version=grid_gen[0][0];
    fields_key=grid_gen[0][1];
    nos_records=grid_gen[0][2];
    existing_table_data=list(grid_gen[0][3]);
    #loop thru the gridlines and see if they are preexisting
    grids_to_add=[];
    for grid in gridlines:
        grid_name=grid[0];
        grid_exists=False;
        for key in grid_gen[1]:
            gridSys=grid_gen[1][key]['Name'];
            gridID=grid_gen[1][key]['ID'];
            if(grid_sys==gridSys and grid_name==gridID):
                grid_exists=True;
        if(grid_exists==False):
            grids_to_add.append(grid_name);
    #add the grids to the grid data
    new_table_data=[];
    for grid in gridlines:
        grid_name=grid[0];
        if(ord_type=='coord'):
            grid_x1=str(grid[1][0]);
            grid_y1=str(grid[1][1]);
            grid_x2=str(grid[2][0]);
            grid_y2=str(grid[2][1]);
        elif(ord_type=='points'):
            #get the point coord
            pt1,pt2=grid[1];
            grid_x1,grid_y1=SapModel.PointObj.GetCoordCartesian(pt1)[0:2];
            grid_x1,grid_y1=round(grid_x1,3),round(grid_y1,3);
            grid_x1,grid_y1=str(grid_x1),str(grid_y1);
            grid_x2,grid_y2=SapModel.PointObj.GetCoordCartesian(pt2)[0:2];
            grid_x2,grid_y2=round(grid_x2,3),round(grid_y2,3);
            grid_x2,grid_y2=str(grid_x2),str(grid_y2);
        if(grid_name in grids_to_add):
            new_table_data.extend([grid_sys,'General (Cartesian)',grid_name,
                '','',grid_x1,grid_y1,grid_x2,grid_y2,
                'End','Yes']);
            nos_records+=1;
    table_data=existing_table_data+new_table_data;
    SapModel.DatabaseTables.SetTableForEditingArray(table_key2,
        table_version,fields_key,nos_records,table_data);
    #apply the table for editing
    ret_val=SapModel.DatabaseTables.ApplyEditedTables(True);
    print(ret_val[-2]);
    SapModel.View.RefreshView();
    return None;
 
I can not run this by API ETABS 2016. No such commands SetTableForEditingArray for API etabs 2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top