Dear all,
For Robot Structural, I am trying to automatize Time History Analysis with VBA and API. The purpose is to model a running train at different speeds on a bridge.
I have found example of code to export THA results to Excel, but no example on how to code the THA load case and the time functions. The "Robot API.pdf" is sometimes difficult to understand and simple examples would be very useful and time saving. Are there code examples available?
Thank you in advance, Ivan Wouts
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Dim r As New RobotOM.RobotApplication Dim sc As RobotOM.RobotSimpleCase sc = r.Project.Structure.Cases.CreateSimple(2, "time", RobotOM.IRobotCaseNature.I_CN_EXPLOATATION, RobotOM.IRobotCaseAnalizeType.I_CAT_TIME_HISTORY) Dim thfl As RobotOM.RobotTimeHistoryFunctionList thfl = r.Project.Structure.Cases.TimeHistoryFunctions Dim thpc As RobotOM.RobotTimeHistoryPointsCollection thpc = thfl.Create() thpc.Add(0, 0) thpc.Add(1, 1) thpc.Add(2, 0) thfl.Store("a_function", thpc) Dim p As RobotOM.RobotTimeHistoryAnalysisParams p = sc.GetAnalysisParams() p.Set(-1, "a_function", 1, 1) sc.SetAnalysisParams(p)
Another example attached
Hi Rafal
I am looking into the excel file THA creationex and getting an error, when trying to use it.
Could you maybe attach a robot-file, where the excel/vba code work on, so I can figure out, where the error in my file is?
The error is
Run-time error '-2147467259 (80004005)':
Method 'Get' of object 'IRobotTimehistoryAnalysisParams' failed
Best Regards
Jakob Nielsen
Hi Rafal
And maybe also a Robot-file where the "Time history point collection" code works in.
Best Regards
Jakob Nielsen
Hi Rafal
I am trying to use the code, where you are making a pointcollection.
But am getting an error at the following line
"thpc.Add(0,0)"
If you get the time, please send an example?
Best Regards
Jakob
Thanks!
That helped.
But now I get another error
"Object variable or With block not set"
This line is highlighted in the vba code
sc = r.Project.Structure.Cases.CreateSimple(2, "time", RobotOM.IRobotCaseNature.I_CN_EXPLOATATION, RobotOM.IRobotCaseAnalizeType.I_CAT_TIME_HISTORY)
Sub test()
Dim r As New RobotOM.RobotApplication
Dim sc As RobotOM.RobotSimpleCase
sc = r.Project.Structure.Cases.CreateSimple(2, "time", RobotOM.IRobotCaseNature.I_CN_EXPLOATATION, RobotOM.IRobotCaseAnalizeType.I_CAT_TIME_HISTORY)
Dim thfl As RobotOM.RobotTimeHistoryFunctionList
thfl = r.Project.Structure.Cases.TimeHistoryFunctions
Dim thpc As RobotOM.RobotTimeHistoryPointsCollection
thpc = thfl.Create()
thpc.Add 0, 0
thpc.Add 1, 1
thpc.Add 2, 0
thfl.Store "a_function", thpc
Dim p As RobotOM.RobotTimeHistoryAnalysisParams
p = sc.GetAnalysisParams()
p.Set -1, "a_function", 1, 1
sc.SetAnalysisParams (p)
End Sub
Best Regards
Jakob
Hi,
In VBA in front of every variable that is an object You have to write Set.
So, in Your case it would be:
Set sc = r.Project.Structure.Cases.CreateSimple(2, "time", RobotOM.IRobotCaseNature.I_CN_EXPLOATATION, RobotOM.IRobotCaseAnalizeType.I_CAT_TIME_HISTORY)
Regards,
Marcin
Hi Rafal
Would it be possible to get these results using the results query approach to speed up the process?
I am trying to tweak your code from this post https://forums.autodesk.com/t5/robot-structural-analysis-forum/api-is-there-a-way-to-get-results-fas... but in the process of trying to run the original I am getting a 'Class not registered' error for
Res = RobApp.Project.Structure.Results.Query(RobResQueryParams, RobResRowSet)
which appears to be in relation to the 'RobResRowSet' part and so before I try to fix this error I want to make sure it is a possibility.
Of course if it is possible any code adjustments would be much appreciated! And also a fix for the Class error but I have seen a few posts for similar issues so will try those.
Thanks
Is possible to calculate Torsional Amplification factor (Ax ) by dynamic forces from (Response Spectrum Analysis) or need to make procedures to do it?