Sir,
I am writing a openstaad code using visual basic and my objective is to assign a point load and moment at a group of nodes. Now after executing the code the point force is assigned properly in staad model but point moment is not reflected in staad. For your reference, i am adding the piece of code here and also the output screenshot.
For I = 2 To (j - 1) objOpenSTAAD.Load.SetLoadActive 1 objOpenSTAAD.Load.AddNodalLoad node(I), 0, (-1) * Cells(62 + I, 3), 0, 0, 0, Cells(62 + I, 4) Next I
staad output excel input
can you please help me how to fix this problem ASAP ?
Please use this code and check if it is working
Set objOpenSTAAD = GetObject(, "StaadPro.OpenSTAAD")
Dim node(0) As Longnode(0) = 2
Dim fx(1) As DoubleDim fy(1) As DoubleDim fz(1) As DoubleDim mx(1) As DoubleDim my(1) As DoubleDim mz(1) As Doublefx(0) = 1.56fy(0) = 2.3fz(0) = 3.7mx(0) = 3.9my(0) = 5.8mz(0) = 6
objOpenSTAAD.Load.SetLoadActive 2objOpenSTAAD.Load.Addnodalload node(0), fx(0), fy(0), fz(0), mx(0), my(0), mz(0)
Try adding this to your last argument, CDbl(Cells(62 + I, 4).
The reference for OpenSTAAD should have explained this but it does not. It is absolutely the worst reference manual I have ever seen.
Answer Verified By: Arkadev Ghosh
Hi Arkadev,
Let me explain why your code is not working. When you import a value in your VBA code from any cell, by default the variable type is considered as Variant, it might be Variant/String or Variant/Double depending on the value. Now this variable type is not sufficient for any OpenSTAAD function. If you try to run any OpenSTAAD function with null or variant variable type, either it will not work or incorrect results will be extracted. That's why we always suggest to create a variable with proper variable type, assign the value to that variable and then use that variable in the OpenSTAAD function (this is the solution provided by Shreyanka).
Next question is, from where you get this variable type information. Ideally it needs to be mentioned in the manual but it is not. At this moment, you need to guess it depending on the data, for example, if there is any co-ordinate value or force component, the data type should be Double, for node or member number or load case, it should be Integer/Long etc.
Final information, what Tank mentioned in his reply is absolutely correct. The OpenSTAAD Help manual is an incomplete manual. There are lots of missing functions, variable types are not mentioned, description of several functions and variables are not correct, examples are missing and so on. You can use this manual to get the basic information, and then use your experience or trial and error method to write your code correctly. I always cross check the information provided in the manual with some trial code and then implement the function in the actual code.
thank you sir, it works for me
understood sir, thats why using CDbl actually worked, which in turn make that value as "double". Thank you for your help