VBA Excel macro for to change an objects parameters in Robot(API)

VBA Excel macro for to change an objects parameters in Robot(API)

gflareUUCY6
Participant Participant
652 Views
2 Replies
Message 2 of 3

VBA Excel macro for to change an objects parameters in Robot(API)

gflareUUCY6
Participant
Participant

Hi!

I have generated a several panels in robot by using an Excel Macro. But the problem is that there are some parameters that i want to change:

 

1. The model is generated as panel (panneau) but them to be "concrete Wall" (voile). I know it doesn't affect the calculation but I would like them to be "concrete Wall" (voile)  instead of panel (panneau) in order to make a diffference. 

gflareUUCY6_0-1681374159555.png

 

2. I want to number each panel like "Panneau 1"; "Panneau 2" ..... (In the image above, the panels are not numbered)

 

3. I want to give each panel a name like "voile_i" (i is the number of the panel)  and put "Elément de construction" on voile. 

gflareUUCY6_1-1681374410698.png

 

4. I want also to put "Modèle de calcul" on "coque"

gflareUUCY6_2-1681374494425.png

 

5. In the section of geometry, i want to add the coordinates of each panel nodes

gflareUUCY6_3-1681374596774.png

 

6.  I want to show the value of each panel thickness in the section "Epaisseur" and for type de ferraillage, i want it to be on voile BA. 

 

gflareUUCY6_4-1681374749374.png

 

Here is my VBA code:

 

'Exemple de l'utilisation de Robot Open Standard
'Robobat - E.WEYERMANN
'v2 09/2001
'cet exemple montre comment :
' - genérer des panneaux
' - créer des appuis élastiques
' - Definir des charges hydrostatiques
' - Définir des charges sur contour
' - Définir des charges uniformes
' - Lancer le calcul
'Messages =====================================
Const msg1 = "Start Robot with a new Frame 3D project, first."
Const msg2 = "Structure is generating ..."
Const msg3 = "Load is defining... "
Const msg4 = "Generation completed!"
Sub kernel4()

Cells.Range("_msg") = msg2
' ouverture de robot, la session s'appellera robapp
Set RobApp = New RobotApplication

' ce sera une structure de type panneaux
RobApp.Project.New (I_PT_SHELL)


'initialisation des valeurs
Call init_value

'création du voile2
Call CreeVoile


' permet de de mailler la structure
'RobApp.Project.CalcEngine.Calculate

'permet de regénérer la vue
Call CreeVueRM

'sauvegarde le projet
Cells.Range("_msg") = msg4

End Sub

Sub CreeVoile()

'***** elements Robot *****
Dim Panel As RobotObjObject
Dim PanelContour As New RobotGeoContour
Dim PanelNode As RobotNode
Dim PanelSegment() As New RobotGeoSegmentLine

'**************************
Dim i As Long
Dim PanelNum As Long
Dim jj As Long
Dim NodeNumber As Long
Dim TotNodeNumb As Long

Call CompterMurs

PanelNum = 1
NodeNumber = 160

For i = 1 To nb_panels

Call initialise_contour_voile

ReDim PanelSegment(1 To nb_panels, 1 To nb_points)
'ReDim PanelNode(1 To nb_panels)

PanelSegment(i, 1).P1.Set Cells(i + 2, 5), Cells(i + 2, 6), Cells(i + 2, 7)
PanelContour.Add PanelSegment(i, 1)

'Set PanelNode = Robot.Project.Structure.Nodes.Create(Cells(i + 2, 5), Cells(i + 2, 6), Cells(i + 2, 7))

PanelSegment(i, 2).P1.Set Cells(i + 2, 8), Cells(i + 2, 9), Cells(i + 2, 10)
PanelContour.Add PanelSegment(i, 2)

PanelSegment(i, 3).P1.Set Cells(i + 2, 14), Cells(i + 2, 15), Cells(i + 2, 16)
PanelContour.Add PanelSegment(i, 3)

PanelSegment(i, 4).P1.Set Cells(i + 2, 11), Cells(i + 2, 12), Cells(i + 2, 13)
PanelContour.Add PanelSegment(i, 4)

PanelContour.Initialize

PanelNum = PanelNum + 1

Set Panel = RobApp.Project.Structure.Objects.Create(2)

Panel.Main.Geometry = PanelContour
Panel.Main.Attribs.Meshed = True
Panel.Initialize
Panel.Update

Material_Name = "BETON" & str(Cells(i + 2, 18))
Set mat = RobApp.Project.Structure.Labels.Create(I_LT_BAR_MATERIAL, Material_Name)
Dim matdata As RobotMaterialData
Set matdata = mat.Data
matdata.Type = I_MT_CONCRETE
matdata.E = 11000 * Cells(i + 2, 18) ^ (1 / 3) * 1000000
matdata.NU = 0
matdata.RO = 24530
matdata.Kirchoff = matdata.E / (2 * (1 + matdata.NU))
matdata.LX = 0.00001
matdata.RE = Cells(i + 2, 18) * 1000000
RobApp.Project.Structure.Labels.Store mat
Panel.SetLabel I_LT_BAR_MATERIAL, Material_Name

thick_name = "EP" & str(Cells(i + 2, 17))
Dim Label As RobotLabel
Set Label = RobApp.Project.Structure.Labels.Create(I_LT_PANEL_THICKNESS, thick_name)
Dim ThickData As RobotThicknessData
Set ThickData = Label.Data
ThickData.ElasticFoundation = 0
ThickData.ThicknessType = I_TT_HOMOGENEOUS
ThickData.MaterialName = Material_Name
Dim HomoThickData As RobotThicknessHomoData
Set HomoThickData = ThickData.Data
HomoThickData.Type = I_THT_CONSTANT
HomoThickData.ThickConst = Cells(i + 2, 17) / 100
RobApp.Project.Structure.Labels.Store Label
Panel.SetLabel I_LT_PANEL_THICKNESS, thick_name
Set Label = Nothing

Panel_name = "voile" & str(i)
Dim Label2 As RobotLabel
Set Label2 = RobApp.Project.Structure.Labels.Create(I_VDA_FE_PANEL_NAMES, Panel_name)
Panel.SetLabel I_LT_PANEL_THICKNESS, thick_name
PanelContour.Clear

Set Panel = Nothing
Set PanelContour = Nothing
ReDim PanelSegment(1 To 1)
Set PanelSegment(1) = Nothing
Next
End Sub


Public Sub CreeVueRM()
' définition d'une vue
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

RobApp.Interactive = True
RobApp.Visible = True
RobApp.Window.Activate
'' aaa = RobApp.ProgramVersion

' robapp.Project.CalcEngine.Calculate ' calculate model

Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view

Set mavueRobot = RobApp.Project.ViewMngr.GetView(1) ' it seems CreateView makes this strange affect, use GetView instead

' mavueRobot.Selection.Get(I_OT_CASE).FromText ("3") ' selecting case for results display
mavueRobot.Redraw (True)

' mavueRobot.Projection = I_VP_XY

' displaying map
' mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_GLOBAL_DISPLACEMENT_Z

mavueRobot.Visible = True
'mavueRobot.Redraw (True)
mavueRobot.ParamsDisplay.Set I_VDA_OTHER_RULER, False
mavueRobot.ParamsDisplay.Set I_VDA_ADVANCED_OFFSETS, False 'afficher exentrements
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SHAPE, False 'afficher croquis barres
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SYMBOLS, True 'afficher symboles barres
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_THICKNESSES, False 'afficher epaisseur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_COLORS, False 'afficher profilés en couleur
mavueRobot.ParamsDisplay.Set I_VDA_FE_FE_INTERIOR, False 'interieur element finis
mavueRobot.ParamsDisplay.Set I_VDA_FE_CLADDING_INTERIOR, False 'interieur bardages
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_INTERIOR, False 'interieur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_FE_FINITE_ELEMENTS, False 'afficher elements finis
RobApp.Project.ViewMngr.Refresh

End Sub


Public Sub CreeVueRM1()
' définition d'une vue
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

RobApp.Interactive = True
RobApp.Visible = True
RobApp.Window.Activate

Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view

Set mavueRobot = RobApp.Project.ViewMngr.GetView(1) ' it seems CreateView makes this strange affect, use GetView instead

mavueRobot.Redraw (True)

mavueRobot.Visible = True

mavueRobot.ParamsDisplay.Set I_VDA_OTHER_RULER, False
mavueRobot.ParamsDisplay.Set I_VDA_ADVANCED_OFFSETS, False 'afficher exentrements
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SHAPE, False 'afficher croquis barres
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SYMBOLS, True 'afficher symboles barres
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_THICKNESSES, False 'afficher epaisseur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_COLORS, False 'afficher profilés en couleur
mavueRobot.ParamsDisplay.Set I_VDA_FE_FE_INTERIOR, False 'interieur element finis
mavueRobot.ParamsDisplay.Set I_VDA_FE_CLADDING_INTERIOR, False 'interieur bardages
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_INTERIOR, False 'interieur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_FE_FINITE_ELEMENTS, False 'afficher elements finis
RobApp.Project.ViewMngr.Refresh

End Sub

0 Likes
653 Views
2 Replies
Replies (2)
Message 1 of 3

gflareUUCY6
Participant
Participant

Hi!

I have create Panel in robot using their coordinate and their thickness which are in an Excel sheet. The macro vba works very well but their some parameters that i want to change but i don't know how to do this.

 

1. I want when i create panels which are "voile" (concrete wall) instead of just panels

gflareUUCY6_0-1681367179873.png

2. I want to number each wall like Wall 1, Wall 2 .... (In the previous figure, the panels are not numbered)

 

3. I want to give each wall a name like "voile_i" (i is the number of the wall) (When i select the panel created, they don't have a name. 

gflareUUCY6_1-1681367497716.png

 

4. I Want also to change "élément de construction" of each panel to "voile" (For the moment, it is "Panneau")

 

gflareUUCY6_2-1681367645973.png

 

5. In geometry, i want to have the panel nodes when i select it

 

6. In the Thickness (epaisseur), i want to see the thickness of the panel when i select it

gflareUUCY6_3-1681367774943.png

 

 

 

Here is my macro VBA:

 

'Exemple de l'utilisation de Robot Open Standard
'Robobat - E.WEYERMANN
'v2 09/2001
'cet exemple montre comment :
' - genérer des panneaux
' - créer des appuis élastiques
' - Definir des charges hydrostatiques
' - Définir des charges sur contour
' - Définir des charges uniformes
' - Lancer le calcul
'Messages =====================================
Const msg1 = "Start Robot with a new Frame 3D project, first."
Const msg2 = "Structure is generating ..."
Const msg3 = "Load is defining... "
Const msg4 = "Generation completed!"
Sub kernel3()

Cells.Range("_msg") = msg2
' ouverture de robot, la session s'appellera robapp
Set RobApp = New RobotApplication

' ce sera une structure de type panneaux
RobApp.Project.New (I_PT_SHELL)


'initialisation des valeurs
Call init_value

'création du voile2
Call CreeVoile


' permet de de mailler la structure
'RobApp.Project.CalcEngine.Calculate

'permet de regénérer la vue
Call CreeVueRM

'sauvegarde le projet
Cells.Range("_msg") = msg4

End Sub

Sub CreeVoile()

'***** elements Robot *****
Dim Panel As RobotObjObject
Dim PanelContour As New RobotGeoContour
Dim PanelNode As RobotNode
Dim PanelSegment() As New RobotGeoSegmentLine

'**************************
Dim i As Long
Dim PanelNum As Long
Dim jj As Long
Dim NodeNumber As Long
Dim TotNodeNumb As Long

Call CompterMurs

PanelNum = 1
For i = 1 To nb_panels

Call initialise_contour_voile

ReDim PanelSegment(1 To nb_panels, 1 To nb_points)


PanelSegment(i, 1).P1.Set Cells(i + 2, 5), Cells(i + 2, 6), Cells(i + 2, 7)
PanelContour.Add PanelSegment(i, 1)

PanelSegment(i, 2).P1.Set Cells(i + 2, 8), Cells(i + 2, 9), Cells(i + 2, 10)
PanelContour.Add PanelSegment(i, 2)

PanelSegment(i, 3).P1.Set Cells(i + 2, 14), Cells(i + 2, 15), Cells(i + 2, 16)
PanelContour.Add PanelSegment(i, 3)

PanelSegment(i, 4).P1.Set Cells(i + 2, 11), Cells(i + 2, 12), Cells(i + 2, 13)
PanelContour.Add PanelSegment(i, 4)

PanelContour.Initialize

PanelNum = PanelNum + 1

Set Panel = RobApp.Project.Structure.Objects.Create(2)

Panel.Main.Geometry = PanelContour
Panel.Main.Attribs.Meshed = True
Panel.Initialize
Panel.Update

Material_Name = "BETON" & str(Cells(i + 2, 18))
Set mat = RobApp.Project.Structure.Labels.Create(I_LT_BAR_MATERIAL, Material_Name)
Dim matdata As RobotMaterialData
Set matdata = mat.Data
matdata.Type = I_MT_CONCRETE
matdata.E = 11000 * Cells(i + 2, 18) ^ (1 / 3) * 1000000
matdata.NU = 0
matdata.RO = 24530
matdata.Kirchoff = matdata.E / (2 * (1 + matdata.NU))
matdata.LX = 0.00001
matdata.RE = Cells(i + 2, 18) * 1000000
RobApp.Project.Structure.Labels.Store mat
Panel.SetLabel I_LT_BAR_MATERIAL, Material_Name

thick_name = "EP" & str(Cells(i + 2, 17))
Dim Label As RobotLabel
Set Label = RobApp.Project.Structure.Labels.Create(I_LT_PANEL_THICKNESS, thick_name)
Dim ThickData As RobotThicknessData
Set ThickData = Label.Data
ThickData.ElasticFoundation = 0
ThickData.ThicknessType = I_TT_HOMOGENEOUS
ThickData.MaterialName = Material_Name
Dim HomoThickData As RobotThicknessHomoData
Set HomoThickData = ThickData.Data
HomoThickData.Type = I_THT_CONSTANT
HomoThickData.ThickConst = Cells(i + 2, 17) / 100
RobApp.Project.Structure.Labels.Store Label
Panel.SetLabel I_LT_PANEL_THICKNESS, thick_name


Panel_name = "voile" & str(i)
Dim Label2 As RobotLabel
'Set Label2 = RobApp.Project.Structure.Labels.Create(I_VDA_FE_PANEL_NAMES, Panel_name)
Panel.SetLabel I_LT_I_VDA_FE_PANEL_NAMES, Panel_name
Set Label = Nothing

PanelContour.Clear


PanelContour.Clear

Set Panel = Nothing
Set PanelContour = Nothing
ReDim PanelSegment(1 To 1)
Set PanelSegment(1) = Nothing
Next
End Sub


Public Sub CreeVueRM()
' définition d'une vue
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

RobApp.Interactive = True
RobApp.Visible = True
RobApp.Window.Activate
'' aaa = RobApp.ProgramVersion

' robapp.Project.CalcEngine.Calculate ' calculate model

Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view

Set mavueRobot = RobApp.Project.ViewMngr.GetView(1) ' it seems CreateView makes this strange affect, use GetView instead

' mavueRobot.Selection.Get(I_OT_CASE).FromText ("3") ' selecting case for results display
mavueRobot.Redraw (True)

' mavueRobot.Projection = I_VP_XY

' displaying map
' mavueRobot.ParamsFeMap.CurrentResult = I_VFMRT_GLOBAL_DISPLACEMENT_Z

mavueRobot.Visible = True
'mavueRobot.Redraw (True)
mavueRobot.ParamsDisplay.Set I_VDA_OTHER_RULER, False
mavueRobot.ParamsDisplay.Set I_VDA_ADVANCED_OFFSETS, False 'afficher exentrements
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SHAPE, False 'afficher croquis barres
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SYMBOLS, True 'afficher symboles barres
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_THICKNESSES, False 'afficher epaisseur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_COLORS, False 'afficher profilés en couleur
mavueRobot.ParamsDisplay.Set I_VDA_FE_FE_INTERIOR, False 'interieur element finis
mavueRobot.ParamsDisplay.Set I_VDA_FE_CLADDING_INTERIOR, False 'interieur bardages
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_INTERIOR, False 'interieur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_FE_FINITE_ELEMENTS, False 'afficher elements finis
RobApp.Project.ViewMngr.Refresh

End Sub


Public Sub CreeVueRM1()
' définition d'une vue
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication

RobApp.Interactive = True
RobApp.Visible = True
RobApp.Window.Activate

Dim mavueRobot As IRobotView3 ' this is important to set IRobotView3 if you want to make screen capture of this view

Set mavueRobot = RobApp.Project.ViewMngr.GetView(1) ' it seems CreateView makes this strange affect, use GetView instead

mavueRobot.Redraw (True)

mavueRobot.Visible = True

mavueRobot.ParamsDisplay.Set I_VDA_OTHER_RULER, False
mavueRobot.ParamsDisplay.Set I_VDA_ADVANCED_OFFSETS, False 'afficher exentrements
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SHAPE, False 'afficher croquis barres
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_SYMBOLS, True 'afficher symboles barres
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_THICKNESSES, False 'afficher epaisseur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_SECTIONS_COLORS, False 'afficher profilés en couleur
mavueRobot.ParamsDisplay.Set I_VDA_FE_FE_INTERIOR, False 'interieur element finis
mavueRobot.ParamsDisplay.Set I_VDA_FE_CLADDING_INTERIOR, False 'interieur bardages
mavueRobot.ParamsDisplay.Set I_VDA_FE_PANEL_INTERIOR, False 'interieur panneaux
mavueRobot.ParamsDisplay.Set I_VDA_FE_FINITE_ELEMENTS, False 'afficher elements finis
RobApp.Project.ViewMngr.Refresh

End Sub

 

0 Likes
Message 3 of 3

Stephane.kapetanovic
Mentor
Mentor

hi @gflareUUCY6 

https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-creating-thin-members-walls-and-s...

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