(API) Take forces with characteristic points

(API) Take forces with characteristic points

eng_leandromartins
Enthusiast Enthusiast
2,441 Views
28 Replies
Message 1 of 29

(API) Take forces with characteristic points

eng_leandromartins
Enthusiast
Enthusiast

Hello everyone,

I searched other topics but every time I found something similar the topic was closed because it was too old.

I would like to use API to automatically transfer the results in the image below to Excel.

Capturar.PNG

 

I thank you in advance! 

0 Likes
2,442 Views
28 Replies
Replies (28)
Message 2 of 29

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

hi @eng_leandromartins 

this code saves the current table in a ‘TXT Files’ folder under your project directory and opens it in Excel.

Sub GetTable()
  Dim RobApp As RobotApplication: Set RobApp = New RobotApplication
  If Not (RobApp.Visible = -1 And RobApp.Project.IsActive = -1) Then
    Set RobApp = Nothing: Exit Sub
  End If

  Dim Project As RobotProject, TableFrame As RobotTableFrame, Table As RobotTable
  Set Project = RobApp.Project
  Set TableFrame = Project.ViewMngr.GetTable(1)
  Set Table = TableFrame.Get(1)

  Dim FileName As String, FolderName As String, workPath As String, fso As Object
  FileName = Project.FileName: FolderName = "\TXT Files"
  workPath = Left(FileName, InStrRev(FileName, "\") - 1) & FolderName
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  If Not fso.FolderExists(workPath) Then fso.CreateFolder workPath
  Set fso = Nothing

  Dim EntireFileName As String: EntireFileName = workPath & "\TableTxt.txt"
    
  Dim wb As Workbook
  On Error Resume Next: Set wb = Workbooks(Dir(FileName)): On Error GoTo 0
  If Not wb Is Nothing Then wb.Close False
    
  Table.Printable.SaveToFile EntireFileName, I_OFF_TEXT
  Workbooks.OpenText FileName:=EntireFileName, DataType:=xlDelimited, Semicolon:=True

  Set RobApp = Nothing
End Sub

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 3 of 29

Stephane.kapetanovic
Mentor
Mentor

to create the table and modify the columns

Dim Table As RobotTable
Set Table = RobApp.Project.ViewMngr.CreateTable(I_TT_FORCES, I_TDT_DEFAULT)
  
With Table
  .Select I_ST_BAR, "1to4 9to19"
  .Select I_ST_CASE, "1 2"
  For Each ColumnNumber In Array(269, 270, 282, 271, 24, 149, 480)
    .AddColumn ColumnNumber
  Next
End With

see the updated file (GetCurrentTable.xls) in the following replies

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 4 of 29

eng_leandromartins
Enthusiast
Enthusiast

Thank's @Stephane.kapetanovic

 

Is there any way to set the characteristic point via API?

 

eng_leandromartins_0-1741613316379.png

 

0 Likes
Message 5 of 29

Hi @eng_leandromartins 

I've never tried it. Two options are available where applicable, but non-synchronous multiple points between bars, as shown in your image, are not implemented.

'[...]  
  With RobApp.Project.ViewMngr.CreateTable(I_TT_FORCES, I_TDT_DEFAULT)
    With .Configuration
      ' first option
      .SetValue I_TCV_POSITION_OF_DIVISION_POINT, 0.25
      ' second option
      .SetValue I_TCV_NUMBER_OF_DIVISION_POINTS, 5
    End With
  End With
'[...]

For my own use, I select the load cases, bars, nodes, and relative or absolute positions, and my program takes care of the rest.

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 6 of 29

eng_leandromartins
Enthusiast
Enthusiast

Thank's @Stephane.kapetanovic ,

 

Is there any way to set this flags via API? 

eng_leandromartins_0-1741637690004.png

 

0 Likes
Message 7 of 29

You can do this in Excel. 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 8 of 29

eng_leandromartins
Enthusiast
Enthusiast

Thank's @Stephane.kapetanovic.

Another question. How do I find out which index each column I want to appear?

I looked in the documentation, but I couldn't find anything!

0 Likes
Message 9 of 29

hi @eng_leandromartins 

sometimes, column indexes are provided on the forum; other times, you may need to search for them yourself or develop a bot.

If you can't find them, it's best to ask here.

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 10 of 29

eng_leandromartins
Enthusiast
Enthusiast

Thanks for the answers @Stephane.kapetanovic 
I honestly have no idea how to create a bot to get the column indexes.
I'll ask on the forum. Do you happen to know the index of the Name of member column?

 

eng_leandromartins_0-1741981703713.png

 

0 Likes
Message 11 of 29

750

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 12 of 29

HoshangMustafa
Advisor
Advisor

Hi @Stephane.kapetanovic 

can you elaborate more on this line of code, especially the AddColumn function:

For Each ColumnNumber In Array(269, 270, 282, 271, 24, 149, 480)
    .AddColumn ColumnNumber

 From The Robot API pdf: The function adds to a table a new column that will present data of the
indicated type .

0 Likes
Message 13 of 29

Stephane.kapetanovic
Mentor
Mentor

hi @HoshangMustafa 

each element of the array corresponds to an index number of a column, and the loop adds to the table all the columns in the order defined.

numbers are values defined by enumerations (named constants)

Best regards

 

for example : https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-estimation-of-reinforcement-weigh...

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 14 of 29

HoshangMustafa
Advisor
Advisor

Hi @Stephane.kapetanovic 

where one can find a guide to these index numbers of columns, e.g. what these index numbers would represent: 269, 270, 282, 271, 24, 149, 480?

0 Likes
Message 15 of 29

Stephane.kapetanovic
Mentor
Mentor

Already answered. No guide, you're on your own.

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 16 of 29

HoshangMustafa
Advisor
Advisor

Hi @Stephane.kapetanovic 

it would be more convenient if you were used TableColumnIndex as a variable rather than ColumnNumber, wouldn't it?

0 Likes
Message 17 of 29

Stephane.kapetanovic
Mentor
Mentor

Have you tried it? Could you explain or share your code, please?

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes
Message 18 of 29

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

if this is what you wanted, note that to make the code more practical, you can create your own enumeration and use it as follows

Enum TCI
  BAR_NODE1 = 269
  BAR_NODE2 = 270
  BAR_NAME = 750
  BAR_LENGTH = 271
  BAR_SECTION_NAME = 24
  BAR_DEFL_UZ = 149
  CASE_NAME = 480
End Enum

'[...]
    For Each TbColIndex In Array(TCI.BAR_NODE1, TCI.BAR_NODE2, _
                                 TCI.BAR_NAME, TCI.BAR_LENGTH, _
                                 TCI.BAR_SECTION_NAME, _
                                 TCI.BAR_DEFL_UZ, TCI.CASE_NAME)
      .AddColumn TbColIndex 
    Next
'[...]

Stephanekapetanovic_0-1742032222420.pngStephanekapetanovic_2-1742032452629.png

 

 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
Message 19 of 29

HoshangMustafa
Advisor
Advisor

Hi @Stephane.kapetanovic 

I tried it this way:

Enum TCI
BAR_NODE1 = 269
BAR_NODE2 = 270
BAR_NAME = 750
BAR_LENGTH = 271
BAR_SECTION_NAME = 24
BAR_DEFL_UZ = 149
CASE_NAME = 480
End Enum

Sub module2()
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

Dim Table As RobotTable
Set Table = RobApp.Project.ViewMngr.CreateTable(I_TT_FORCES, I_TDT_DEFAULT)
With Table
.Select I_ST_BAR, "all"
.Select I_ST_CASE, "1 2"
For Each TbColIndex In Array(TCI.BAR_NODE1, TCI.BAR_NODE2, _
TCI.BAR_NAME, TCI.BAR_LENGTH, _
TCI.BAR_SECTION_NAME, _
TCI.BAR_DEFL_UZ, TCI.CASE_NAME)
.AddColumn TbColIndex
Next
End With

End sub

Is it correct?

0 Likes
Message 20 of 29

Stephane.kapetanovic
Mentor
Mentor

hi @HoshangMustafa 

Here is the updated file

Best Regards

 

file updated 03/18/2025

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to accept the solution and leave a < like !
EESignature
0 Likes