Hello!
I have written a script in VBA in Excel to get some reactions. In my computer I have Robot 2014.
When I try to apply it to a model created in Robot 2013, none of the Robot objects work and the script stops in the first line.
I have tried to save the model with a different name, but that doesn't seem to convert it into Robot 2014.
The same sintaxis work fine in a different model created in 2014.
Any ideas on how to make the code work?
My code:
Public RobApp As RobotApplication
Sub GetForcesinSlabPanels()
'%%%%% Robot Objects %%%%%%%%%%%%%
'Nodes
Dim NodeSel As RobotSelection
Dim NodeCol As RobotNodeCollection
Dim RNode As RobotNode
Dim n_i As Long 'Node counter
'PANEL
Dim PanelSel As RobotSelection
Dim PanelCol As RobotObjObjectCollection
Dim p_i As Long 'Panel counter
Dim RPanel As RobotObjObject
Dim obj As RobotObjObject
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Step 0 - 'Open Robot model___________________________________________________________________
'Get hold of Robot Application
Set RobApp = New RobotApplication
If Not RobApp.Visible Then
Set RobApp = Nothing
MsgBox "Open Robot and load Model", vbOKOnly, "ERROR"
Exit Sub
End If
'Step 1 - 'Get panels already selected_________________________________________________________
Set PanelSel = RobApp.Project.Structure.Selections.Get(I_OT_PANEL) 'PANEL selection
Set PanelCol = RobApp.Project.Structure.Objects.GetMany(PanelSel) 'Panel collection
2) Another question:
How to disable the Robot warnings you get when you try to change something in the structure that will affect the results.
Many thanks!
V.
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
2) Another question:
How to disable the Robot warnings you get when you try to change something in the structure that will affect the results.
Robapp.Project.CalcEngine.AutoFreezeResults = False
Robapp.Project.Structure.ResultsFreeze = False
Hello,
I send below the excel file with my code. I would like to run it with a model created in Robot 2013, in my computer I have installed Robot 2014 only.
In my spreadsheet, I don't have the possibility of referencing the Robot Object Modeller 2013. I cannot begin to debug my code because it stops in the first Robot object I try to set.
Many thanks,
V.
Hello Rafel,
I have created a small Robot model in Robot 2014 to test the script. In this new version I have eliminated the programming errors. I still cannot run this with a model created in Robot 2013.
Please see attached.
Many thanks,
V.
Hello Rafel,
I send you a more polished version of my script. There are two problems with it:
a) I don't seem to be able to compute correctly at how many panels a given node is.
See code below:
'_______________________________________________
' computes num_repeat = number of panels where our node is present
' factor = 1/num_repeat for adding reaction contribution of node
'_______________________________________________________
'
Public Function getFactor_n_i(RobotNode As RobotNode, _
PanelCol As RobotObjObjectCollection, _
myPanel As RobotObjObject) As Double
'panels
Dim p_ii As Long: Dim n_ii As Long
Dim obj2 As RobotObjObject
Dim targetPanelnum As Long
'nodes
Dim NodeSel2 As RobotSelection
Dim Nodecol2 As RobotNodeCollection
Dim Nodeslist2 As String
Dim targetNodeNumber As Long
Dim lookforNodeNumber As Long
'gen
Dim num_repeat As Long
lookforNodeNumber = RobotNode.Number
num_repeat = 0 'Number of times RNode has been found in the panel collection
For p_ii = 1 To PanelCol.Count
targetPanelnum = PanelCol.Get(p_ii).Number
Nodeslist2 = ""
If myPanel.Number = targetPanelnum Then
num_repeat = num_repeat + 1
GoTo check_next_panel_nodes
Else
Set obj2 = RobApp.Project.Structure.Objects.Get(targetPanelnum)
Nodeslist2 = obj2.Main.Nodes
Set NodeSel2 = RobApp.Project.Structure.Selections.Create(I_OT_NODE)
NodeSel2.FromText ""
NodeSel2.FromText Nodeslist2
Set Nodecol2 = RobApp.Project.Structure.Objects.GetMany(NodeSel2) 'Node collection
End If
For n_ii = 1 To Nodecol2.Count
targetNodeNumber = Nodecol2.Get(n_ii).Number
If lookforNodeNumber = targetNodeNumber Then
num_repeat = num_repeat + 1
End If
Next n_ii
check_next_panel_nodes:
Next p_ii
If num_repeat = 0 Then
getFactor_n_i = 0 'Error
Else
getFactor_n_i = 1 / num_repeat
End If
End Function
b) I am not able to run this code with a model created in Robot 2013. I have created the script in VBA in Excel 2013.
How could I convert the Robot model or the script?
I attach here complete code and Robot 2014 test model.
Kind regards,
V.
b) I am not able to run this code with a model created in Robot 2013. I have created the script in VBA in Excel 2013.
How could I convert the Robot model or the script?
It works fine on my comp.
Try:
Open windows command prompt window (cmd.exe) in Admin mode then run this commands:
"C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2013\System\Exe\robot.EXE" /unRegServer
"C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2014\System\Exe\robot.EXE" /unRegServer
"C:\Program Files\Autodesk\Autodesk Robot Structural Analysis Professional 2014\System\Exe\robot.EXE" /RegServer /full
if you have more robots you have to unregister them before the last line above in the same way as shown above
a) I don't seem to be able to compute correctly at how many panels a given node is.
See code below:
My example code
Public Sub Button1_click() Dim Robapp As RobotApplication Set Robapp = New RobotApplication Dim selpanel As RobotSelection Dim selnode As RobotSelection Dim col As RobotObjObjectCollection Set selnode = Robapp.Project.Structure.Selections.Create(I_OT_NODE) Set selpanel = Robapp.Project.Structure.Selections.CreateFull(I_OT_PANEL) Set col = Robapp.Project.Structure.Objects.GetMany(selpanel) ccount = col.Count NodeNumber = 116 Dim panel As RobotObjObject Dim panelnumberswithnodes As String panelnumberswithnodes = "" For c = 1 To ccount Set panel = col.Get(c) nodeslist = panel.Main.Nodes selnode.FromText Str(NodeNumber) selnode.AndText nodeslist If selnode.Count <> 0 Then panelnumberswithnodes = panelnumberswithnodes + " " + Str(panel.Number) Next c MsgBox panelnumberswithnodes Set col = Nothing Set iscsel = Nothing Set Robapp = Nothing End Sub
Hello Rafel,
I don't have admin rights in my computer. Unticking all the Robot libraries except the Robot object modeler did the trick in my computer:
Capture Robot References.PNGCapture Robot References.PNG
Thanks a lot!
V.
Hello Rafel,
Thank you a lot. This worked perfectly.
For the record, the error in my script was that you cannot create a collection using:
.GetMany(RobotSelection)
if the RobotSelection have only one element.
Cheers,
V.