VBA Excel macro for to change an objects parameters in Robot(API)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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.
4. I want also to put "Modèle de calcul" on "coque"
5. In the section of geometry, i want to add the coordinates of each panel nodes
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.
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