(API) How create wooden beam with VBA

(API) How create wooden beam with VBA

dscheven
Explorer Explorer
865 Views
4 Replies
Message 1 of 5

(API) How create wooden beam with VBA

dscheven
Explorer
Explorer

Hello,

 

I have a question about VBA from excel to Robot structural.

How can I create an bar with an section 50x100 and timber material C18.

Below I post the code what I mean. Only the code is for concrete.

 

Thanks.

 

Public Sub CommandButton2_Click()


Dim Robot As New RobotApplication
Robot.Project.New I_PT_FRAME_2D
Robot.Project.Structure.Nodes.Create 1, Range("A2"), 0, 0
Robot.Project.Structure.Nodes.Create 2, Range("B2"), 0, 0
Robot.Project.Structure.Bars.Create 1, 1, 2
Dim Label As RobotLabel
Set Label = Robot.Project.Structure.Labels.Create(I_LT_SUPPORT, "Support")
Dim SupportData As RobotNodeSupportData
Set SupportData = Label.Data
SupportData.UX = 1
SupportData.UY = 1
SupportData.UZ = 1
SupportData.RX = 0
SupportData.RY = 0
SupportData.RZ = 0
Robot.Project.Structure.Labels.Store Label
Robot.Project.Structure.Nodes.Get(1).SetLabel I_LT_SUPPORT, "Support"
Robot.Project.Structure.Nodes.Get(2).SetLabel I_LT_SUPPORT, "Support"
Set Label = Robot.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "Beam 50*50")
Dim section As RobotBarSectionData
Set section = Label.Data
section.ShapeType = I_BSST_CONCR_BEAM_RECT
Dim concrete As RobotBarSectionConcreteData
Set concrete = section.concrete
concrete.SetValue I_BSCDV_BEAM_B, 0.5
concrete.SetValue I_BSCDV_BEAM_H, 0.5
section.CalcNonstdGeometry
Robot.Project.Structure.Labels.Store Label
Robot.Project.Structure.Bars.Get(1).SetLabel I_LT_BAR_SECTION, "Beam 50*50"
Dim caseSW As RobotSimpleCase
Set caseSW = Robot.Project.Structure.Cases.CreateSimple(1, "SW", I_CN_PERMANENT, I_CAT_STATIC_LINEAR)
caseSW.Records.New I_LRT_DEAD
Dim LoadRec As RobotLoadRecord
Set LoadRec = caseSW.Records.Get(1)
LoadRec.SetValue I_DRV_Z, -1
LoadRec.SetValue I_DRV_ENTIRE_STRUCTURE, True
If Robot.Project.CalcEngine.Calculate = True Then
MsgBox Robot.Project.Structure.Results.Bars.Forces.Value(1, 1, 0.5).MY
End If
End Sub

 

0 Likes
Accepted solutions (2)
866 Views
4 Replies
Replies (4)
Message 2 of 5

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @dscheven

 

Here is example code :

 

Dim RLabel As RobotLabel
        
    Dim RLabelData As RobotBarSectionData
    Dim RLabelNSData As RobotBarSectionNonstdData

    Set RLabel = RobApp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "my_section")
    Set RLabelData = RLabel.Data
   
    
    RLabelData.Type = I_BST_NS_RECT
    RLabelData.ShapeType = I_BSST_RECT_FILLED
    
    Set RLabelNSData = RLabelData.CreateNonstd(0)
    
    RLabelNSData.SetValue I_BSNDV_RECT_B, 0.2
    RLabelNSData.SetValue I_BSNDV_RECT_H, 0.4
    
    RLabelData.MaterialName = "C18"
    
    RobApp.Project.Structure.Labels.Store RLabel


Rafal Gaweda
0 Likes
Message 3 of 5

dscheven
Explorer
Explorer

Hi Rafal,

 

Thanks for the fast answer.

I tried to copy in it but when I run the code I get a error on this part

 

Set RLabel = robapp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "my_section12")

 

Am I doing something wrong?

 

Thanks

 

Public robapp As RobotApplication

Public Sub CommandButton2_Click()


Dim Robot As New RobotApplication
Robot.Project.New I_PT_FRAME_2D
Robot.Project.Structure.Nodes.Create 1, Range("A2"), 0, 0
Robot.Project.Structure.Nodes.Create 2, Range("B2"), 0, 0
Robot.Project.Structure.Bars.Create 1, 1, 2
Dim Label As RobotLabel
Set Label = Robot.Project.Structure.Labels.Create(I_LT_SUPPORT, "Support")
Dim SupportData As RobotNodeSupportData
Set SupportData = Label.Data
SupportData.UX = 1
SupportData.UY = 1
SupportData.UZ = 1
SupportData.RX = 0
SupportData.RY = 0
SupportData.RZ = 0
Robot.Project.Structure.Labels.Store Label
Robot.Project.Structure.Nodes.Get(1).SetLabel I_LT_SUPPORT, "Support"
Robot.Project.Structure.Nodes.Get(2).SetLabel I_LT_SUPPORT, "Support"

Dim RLabel As RobotLabel
        
    Dim RLabelData As RobotBarSectionData
    Dim RLabelNSData As RobotBarSectionNonstdData

    Set RLabel = robapp.Project.Structure.Labels.Create(I_LT_BAR_SECTION, "my_section12")
    Set RLabelData = RLabel.Data
   
    
    RLabelData.Type = I_BST_NS_RECT
    RLabelData.ShapeType = I_BSST_RECT_FILLED
    
    Set RLabelNSData = RLabelData.CreateNonstd(0)
    
    RLabelNSData.SetValue I_BSNDV_RECT_B, 0.2
    RLabelNSData.SetValue I_BSNDV_RECT_H, 0.4
    
    RLabelData.MaterialName = "C18"
    
    robapp.Project.Structure.Labels.Store RLabel

Dim caseSW As RobotSimpleCase
Set caseSW = Robot.Project.Structure.Cases.CreateSimple(1, "SW", I_CN_PERMANENT, I_CAT_STATIC_LINEAR)
caseSW.Records.New I_LRT_DEAD
Dim LoadRec As RobotLoadRecord
Set LoadRec = caseSW.Records.Get(1)
LoadRec.SetValue I_DRV_Z, -1
LoadRec.SetValue I_DRV_ENTIRE_STRUCTURE, True
If Robot.Project.CalcEngine.Calculate = True Then
MsgBox Robot.Project.Structure.Results.Bars.Forces.Value(1, 1, 0.5).MY
End If
End Sub
0 Likes
Message 4 of 5

Rafal.Gaweda
Autodesk Support
Autodesk Support
Accepted solution

Hi @dscheven

 

Replace "robapp" by "Robot"



Rafal Gaweda
0 Likes
Message 5 of 5

dscheven
Explorer
Explorer

Thanks Rafal. It works.

0 Likes