Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Update bar section using API

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
raried
514 Views, 2 Replies

Update bar section using API

Hi,

 

I appreciate that this has been answered elsewhere on this forum however these posts haven't helped me. I'm trying to update bar sections (standard UB and UC) in a model with 12,500 bars. I have a table in excel (see table.png below) and want to click the button which runs the following VB code to update the bar sections.

 

Sub Update_Bars_3()
Application.ScreenUpdating = False

Dim robapp As RobotApplication
Set robapp = New RobotApplication
Dim lab_serv As RobotLabelServer
Set lab_serv = robapp.Project.Structure.Labels

Set myrange = Range(Range("A7"), Range("A7").End(xlDown))

For Each Cell In myange

    Dim bar As RobotBar
    Dim Bar_Number As Long
    Bar_Number = Cell.Value
    'Set bar = robapp.Project.Structure.Bars.Get(Bar_Number)
    Set bar = Structure.Bars.Get(Bar_Number)
    Dim rr_section As String
    rr_section = Cell.Offset(0, 3)
    bar.SetLabel I_LT_BAR_SECTION, rr_section
    Set bar = Nothing
Next Cell

Set robapp = Nothing

Application.ScreenUpdating = True
End Sub

 Unfortunately this gives me a "Runtime error 13, type mismatch" error.

 

Any help with this would be greatly appreciated.

 

 

As a follow on question: do I have to have the UB and UC section already added to the Robot sections dialogue box window in order to update the bar table? Is there an easy way to just update the bar table with any (robot valid) standard UB or UC? Or perhaps using the API I can populate the sections list with all the UBs and UCs?

 

Many thanks, Rob

2 REPLIES 2
Message 2 of 3
Rafal.Gaweda
in reply to: raried

myange <> myrange

 

For Each Cell In myrange

    Dim bar As RobotBar
    Dim Bar_Number As Long
    Bar_Number = Cell.Value
    Set bar = robapp.Project.Structure.Bars.Get(Bar_Number)
    Dim rr_section As String
    rr_section = Cell.Offset(0, 3)
    bar.SetLabel I_LT_BAR_SECTION, rr_section
    Set bar = Nothing
Next Cell

 



Rafal Gaweda
Message 3 of 3
Rafal.Gaweda
in reply to: raried

 

As a follow on question: do I have to have the UB and UC section already added to the Robot sections dialogue box window in order to update the bar table? Is there an easy way to just update the bar table with any (robot valid) standard UB or UC? Or perhaps using the API I can populate the sections list with all the UBs and UCs?

 

 Example:

 

Dim robapp As RobotApplication
Set robapp = New RobotApplication
Dim lab_serv As RobotLabelServer
Set lab_serv = robapp.Project.Structure.Labels

Set myrange = Range(Range("A7"), Range("A7").End(xlDown))

Dim SecLab As RobotLabel
Dim SecData As RobotBarSectionData

robapp.Project.Preferences.SetCurrentDatabase I_DT_SECTIONS, "UKST"


For Each Cell In myrange

    Dim bar As RobotBar
    Dim Bar_Number As Long
    Bar_Number = Cell.Value
    Set bar = robapp.Project.Structure.Bars.Get(Bar_Number)
    Dim rr_section As String
    rr_section = Cell.Offset(0, 3)
    
    Set SecLab = robapp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, rr_section)
    Set SecData = SecLab.Data
    SecData.LoadFromDBase rr_section
    robapp.Project.Structure.Labels.Store SecLab
    
    bar.SetLabel I_LT_BAR_SECTION, rr_section
    Set bar = Nothing
Next Cell

 

 



Rafal Gaweda

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report