(API) Reading bar sections

(API) Reading bar sections

Anonymous
Not applicable
2,530 Views
7 Replies
Message 1 of 8

(API) Reading bar sections

Anonymous
Not applicable

I am developing a code on python and I get trouble trying to locale the path for acess the information of bar sections, dimensions, length...
I find the path to get the results of stresses and forces on my structure but im stucked on this problem for days, cant locale where the information of bar section and length are searching through debug console.
Another thing I notice: On API i can acess public methods on debug console but i cant acess public fields but i dont know why this happen

Here an example the code for get the results for bars i made, if something is missing please tell me:

 

import clr 
clr.AddReference('C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2021\System\Exe\Interop.RobotOM.dll')
from RobotOM import *
 
Robotapp = RobotApplicationClass()
project = Robotapp.Project
preferences = project.Preferences
structure = project.Structure
bars = structure.Bars
labels = structure.Labels
results = structure.Results
r_Bars = results.Bars
cases = structure.Cases
storeys = structure.Storeys

 

project.Open("C:\Temp\\projeto.rtd")
force_serv = r_Bars.Forces
bar_col = bars.GetAll()
Num_barras = bars.FreeNumber - 1
for i in range(Num_barras):
    #Select barra
    bar = bars.Get(i+1) 
    print ("Bar", i,":", bar)

    #cases of loads
    cas_col = cases.GetAll()
    Num_cas = cases.FreeNumber - 1

    for j in range(Num_cas)
        #Select case
        cas = cas_col.Get(j+1)
        print("Case", j, ":", cas) 



Thanks in advance

0 Likes
Accepted solutions (1)
2,531 Views
7 Replies
Replies (7)
Message 2 of 8

1234eddie
Advocate
Advocate

Hi @Anonymous 

 

interesting code, i have a question about this. you are using: 

"bar_col=bars.GetAll()"

and then you use bars.FreeNumber - 1 

 

Why are you using freenumber in this case?(i have never seen this before)

what i always use is count the bar_col and loop on the count.

 

Bar data is stored in IRobotBarSectionDataValue.

which bar data do you want get with your script?

 

Message 3 of 8

Anonymous
Not applicable

bars.GetAll() is for get the force through loop, I use bar.FreeNumber cause i cant acess the field for bar_col.Count, thats what make me so confused, when I inspect the variables on debug I only able to acess the methods instead methos and fields.

I cant find the path to IRobotBarSection on debug, i can acess but not using the previous variables...

0 Likes
Message 4 of 8

1234eddie
Advocate
Advocate

Hi 

This is what's listed in the SDK tutorial map by "reading the basic geometry".

Hope this will help you. if not, share youre script and i will try to have a look at it sometime.

Declare the main variable representing the Robot application and connect it to the currently running instance of Robot.
 	
Dim robapp As IRobotApplication
Set robapp = New RobotApplication
 	Get the collection of all bars from the structure.
 	
Set bar_col = robapp.Project.Structure.Bars.GetAll()
 	Iterate for consecutive bars from the collection.
 	
For i = 1 To bar_col.Count
 	 	Get the object representing the following (i-th) bar in the collection.
 	 	
Set bar = bar_col.Get(i)
 	 	Read required attributes of the i-th bar.
 	 	
bar_num = bar.Number
start_node_num = bar.StartNode
end_node_num = bar.EndNode
 	 	Declare variables defining individual nodes.
 	 	
Dim start_node As IRobotNode, end_node As IRobotNode
 	 	Get the node with start_node_num number from the server.
 	 	
Set start_node = robapp.Project.Structure.Nodes.Get(start_node_num)
 	 	Read the values of coordinates x, y, z for the node with start_node_num number.
 	 	
start_node_x = start_node.X
start_node_y = start_node.Y
start_node_z = start_node.Z
 	 	Get the node with end_node_num from the server and read its coordinates.
 	 	
Set end_node = robapp.Project.Structure.Nodes.Get(end_node_num)
end_node_x = end_node.X
end_node_y = end_node.Y
end_node_z = end_node.Z
 	 	Free all declared variable references.
 	 	
Set bar = Nothing
Set start_node = Nothing
Set end_node = Nothing
 	Repeat the operation of reading data for the next bar from the collection.
 	
Next
 	Free all the references declared in the example.
 	
Set bar_col = Nothing
Set robapp = Nothing
Message 5 of 8

Anonymous
Not applicable

Thanks Eddie, i figure it out, i wasn't correctly acessing the directory, I needed to concatenate the variable using IRobot... my code after all:

#Importando bibliotecas
    #O módulo clr é um módulo de strings
    #Utilizando o pythonnet o módulo clr serve como um python package
import clr 
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import sys
#GUI toolkit
#import tkinter as tk

#------------------------------------------------------------------------------------------#
#Adicionando path de referencias e importando objetos da bilbioteca
    #A linha abaixo adiciona a referencia à função clr, ou seja adiciona o arquivo ao python package
clr.AddReference('C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2021\System\Exe\Interop.RobotOM.dll')
    #Da acesso aos módulos da biblioteca compartilhada do Robot (Habilita a utilização dos objetos do Robot)
from RobotOM import *
from System import Object
from System import Environment
from matplotlib import pyplot as plt
#from tkinter import *

#------------------------------------------------------------------------------------------#
#Abre a aplicação
Robotapp = RobotApplicationClass()
#Abre a janela
Robotapp.Interactive = 1
Robotapp.Visible = 1
project = Robotapp.Project
#Abre o projeto ja existente
project.Open("C:\Temp\\projeto.rtd")

#Definindo variaveis
preferences = project.Preferences
structure = project.Structure
bars = structure.Bars
    #Server de acesso ás barras
labels = structure.Labels
    #Server de acesso a seções
#secoes = labels.GetAvailableNames(3)
#IRobotBarSectionType

selections = structure.Selections

results = structure.Results
r_Bars = results.Bars

cases = structure.Cases

obj = structure.Objects



#Acessando informações do projeto
    #Acessando servidores
        #Acessa o servidor de resultados para barras (API->Get the results-> Results for bars -> Forces)
force_serv = r_Bars.Forces

    #Acessando objetos no servidor
#Pega a coleção de resultado para todas as barras
bar_col = RobotBarCollection(bars.GetAll())
cas_col = IRobotCaseCollection(cases.GetAll())


precisão = 0.1 #em m
precisão_decimal = 1

#------------------------------------------------------------------------------------------#
#Cria uma seleção com vigas apenas
seleção_vigas = RobotSelection(selections.Create(1))
for i1 in range(bar_col.Count):
    structural_type = obj.GetStructuralType(i1+1)
    if structural_type == 1:
        seleção_vigas.AddOne(i1+1)
    else:
            pass
vigas = IRobotCollection(bars.GetMany(seleção_vigas))
print(vigas.Count)
#------------------------------------------------------------------------------------------#





#definir uma funçao Valor = (M ou F, Barra, Caso, Ponto)
def MomentoX(Viga_NumeroCaso_NumeroPonto😞
    if obj.GetStructuralType(Viga_Numero) == 1:
        L = IRobotBar(bars.Get(Viga_Numero)).Length 
        MX1 = force_serv.Value(Viga_Numero, Caso_Numero, Ponto/L).MX /1000
        return MX1
        #print(MX)
    else:
        pass    
def MomentoY(Viga_NumeroCaso_NumeroPonto😞
    if obj.GetStructuralType(Viga_Numero) == 1:
        L = IRobotBar(bars.Get(Viga_Numero)).Length 
        MY1 = force_serv.Value(Viga_Numero, Caso_Numero, Ponto/L).MY /1000
        return MY1
        #print(MY)
    else:
        pass  
def MomentoZ(Viga_NumeroCaso_NumeroPonto😞
    if obj.GetStructuralType(Viga_Numero) == 1:
        L = IRobotBar(bars.Get(Viga_Numero)).Length 
        MZ1 = force_serv.Value(Viga_Numero, Caso_Numero, Ponto/L).MZ /1000
        #print(MZ)
        return MZ1
    else:
        pass 
 
 
 
With this I can acess all Moments value for beams just calling MomentoX(Beam number, case number, point at bar), the code have some portuguese so could be a quite dificult to read
 
Now im working on this...
but I still cant acess section dimentions, I dont found anything on internet or on API that (even on VBA) could lead me to figure this out 😕
0 Likes
Message 6 of 8

1234eddie
Advocate
Advocate

Hi @Anonymous 

 

I get your code, at least the english parts.

 

@Rafal.Gaweda can you help @Anonymous with his question


@Anonymous wrote:
Now im working on this...
but I still cant acess section dimentions, I dont found anything on internet or on API that (even on VBA) could lead me to figure this out 😕

Thanks in advance

Message 7 of 8

Rafal.Gaweda
Autodesk Support
Autodesk Support

Hi @Anonymous 

 

Examples

Steel:

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-macro-for-creating-panel-profiles-from-bars/td-p/6045239

 

Concrete:

 

    Dim RLabel As RobotLabel
    Dim RBSD As RobotBarSectionData
    Dim RBSCRD As RobotBarSectionConcreteData

    Set RLabel = RobApp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "MY RC BEAM")
    
    Set RBSD = RLabel.Data
    RBSD.ShapeType = I_BSST_CONCR_BEAM
    Set RBSCRD = RBSD.Concrete
    
    RBSCRD.SetValue I_BSCDV_BEAM_B, 0.2
    RBSCRD.SetValue I_BSCDV_BEAM_H, 0.5
    
    
    RobApp.Project.Structure.Labels.Store RLabel
    
        Set RLabel = RobApp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "MY RC COLUMN")
    
    Set RBSD = RLabel.Data
    RBSD.ShapeType = I_BSST_CONCR_COL_R
    Set RBSCRD = RBSD.Concrete
    
    RBSCRD.SetValue I_BSCDV_COL_B, 0.2
    RBSCRD.SetValue I_BSCDV_COL_H, 0.5
    
    RBSD.CalcNonstdGeometry
    RobApp.Project.Structure.Labels.Store RLabel


Rafal Gaweda
Message 8 of 8

Anonymous
Not applicable
Accepted solution

Thanks for help, I figure it out how to do on Python but Its quite difficult, I have to concatenate multiple objects to acess the value from the object acessing specific label and getting the data

I'll leave the code here case someone in future have the same troubble:

bar1 = IRobotBar(bars.Get(1))
labelbar1 = IRobotLabel(bar1.GetLabel(3))

data = IRobotBarSectionData(labelbar1.Data)