www.sefindia.org

STRUCTURAL ENGINEERING FORUM OF INDIA [SEFI]

 Forum SubscriptionsSubscriptions DigestDigest Preferences   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups  RegisterRegister FAQSecurity Tips FAQDonate
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log in to websiteLog in to websiteLog in to websiteLog in to forum 
Warning: Make sure you scan the downloaded attachment with updated antivirus tools  before opening them. They may contain viruses.
Use online scanners
here and here to upload downloaded attachment to check for safety.

Open STAAD

 
Post new topicReply to topic Thank Post    www.sefindia.org Forum Index -> SEFI General Discussion
View previous topic :: View next topic  
Author Message
rahul.leslie
General Sponsor
General Sponsor


Joined: 01 Apr 2008
Posts: 511
Location: Trivandrum

PostPosted: Fri Aug 30, 2024 6:52 am    Post subject: Open STAAD Reply with quote

Hi,

I have been trying to extract model details via OpenSTAAD, but it is showing error (Error 438)... The code is as below

  
Private Sub CommandButton1_Click()
    Dim openSTAADObj As Object
    
    Set openSTAADObj = GetObject(, "StaadPro.OpenSTAAD")
    openSTAADObj.OpenSTAADFile "D:\STD-Files\Str7.std"
    '==========================NODES===============================
    Dim nNodes As Long
    nNodes = openSTAADObj.Geometry.GetNodeCount
    Dim nodesList() As Long
    openSTAADObj.Geometry.GetNodeList nodesList()
    
    Dim xCoord As Double
    Dim yCoord As Double
    Dim zCoord As Double
    
    For i = 1 To nNodes
        openSTAADObj.Geometry.GetNodeCoordinates (nodesList(i - 1)), xCoord, yCoord, zCoord
       
        Worksheets("Sheet2").Range("A" & (i + 3)) = nodesList(i - 1)
        Worksheets("Sheet2").Range("B" & (i + 3)) = xCoord
        Worksheets("Sheet2").Range("C" & (i + 3)) = yCoord
        Worksheets("Sheet2").Range("D" & (i + 3)) = zCoord
    Next i
    '=============================================================
Set openSTAADObj = Nothing
End Sub


The line giving the error is shown highlighted above ... The function used is as documented:



anyboby, any idea what the problem is?

Rahul Leslie



getNodeList.png
 Description:
 Filesize:  57.07 KB
 Viewed:  76 Time(s)

getNodeList.png


Back to top
View user's profile Send private message Visit poster's website
BVRAO
General Sponsor
General Sponsor


Joined: 21 Sep 2009
Posts: 53

PostPosted: Sat Aug 31, 2024 5:34 am    Post subject: Reply with quote

I have developed many applications for  STAAD

I have not understand actually what  is your requirement


you have to declare  Excel also as an object
Back to top
View user's profile Send private message
rahul.leslie
General Sponsor
General Sponsor


Joined: 01 Apr 2008
Posts: 511
Location: Trivandrum

PostPosted: Sun Sep 01, 2024 3:29 pm    Post subject: Reply with quote

Thank you, sir, for your response.
This is a VBA program written within Excel, so Excel need not be made an object... the program is itself residing inside Excel

My only doubt is, whether the function...

openSTAADObj.Geometry.GetNodeList

...is working fine, in your experience. In my case, with the VBA code given in above post, it is giving error, saying:

Run-time error '5'
Invalid procedure call or argument


where could I be wrong?

Rahul Leslie
Back to top
View user's profile Send private message Visit poster's website
JVCSNL
...
...


Joined: 26 Jan 2003
Posts: 172

PostPosted: Mon Sep 02, 2024 4:18 am    Post subject: Reply with quote

did you tried

openSTAADObj.Geometry.GetNodeList(nodesList)


Best Regards,


Jignesh Chokshi
Back to top
View user's profile Send private message
rahul.leslie
General Sponsor
General Sponsor


Joined: 01 Apr 2008
Posts: 511
Location: Trivandrum

PostPosted: Mon Sep 02, 2024 2:14 pm    Post subject: Reply with quote

..tried. It isn't working either.
Back to top
View user's profile Send private message Visit poster's website
BVRAO
General Sponsor
General Sponsor


Joined: 21 Sep 2009
Posts: 53

PostPosted: Thu Sep 05, 2024 2:26 pm    Post subject: Reply with quote

rahul.leslie wrote:
..tried. It isn't working either.


who told   " openSTAADObj "  will be taken os an object in VBA


is there any examples you have


it is very easy   to read the TEXT file like  .STD    .TXT   . ANL in  VBA


and  load  the contents whatever you want .


Thats why am asking  what do you want to do


  
Definitely I will guide you         , I developed so many applications   long back      in excel VBA
Back to top
View user's profile Send private message
JVCSNL
...
...


Joined: 26 Jan 2003
Posts: 172

PostPosted: Fri Sep 06, 2024 4:12 am    Post subject: Open STAAD Reply with quote

Mr. Rao,


The OpenSTAADObj works well in VBA for sure.  It actually allow us to access the entire database rather than .std text file or .anl file having limited information.  It is better to use this object as it can be useful for updating the data within staad model itself through automation programs.


Dear Rahul,

The problem I see is that the nodelist is an array without defined dimension.  

Since, we don't know how many nodes will be there in different models, it is necessary not to define its size in the first place.  

Hence, we shall first define the variable without dimension (dim nodelist() as long  in this case).  

Then, we shall count the nodes and then redimension the variable with exact size.  

Try Below code:


Dim nodesList() As Long

Dim nNodes As Integer
nNodes = openSTAADObj.Geometry.GetNodeCount


ReDim nodesList(0 to (nNodes-1)) As Long

openSTAADObj.Geometry.GetNodeList nodesList


alternatively:


Dim nNodes As Integer
nNodes = openSTAADObj.Geometry.GetNodeCount


Dim nodesList(0 to (nNodes-1)) As Long
openSTAADObj.Geometry.GetNodeList nodesList



I think, these both approaches shall work:



Sharing another example, for support nodes from one of my programs.  Similar syntax.

Dim SupNode() As Long

Dim SC As Integer
SC = OST.Support.GetSupportCount
ReDim SupNode(0 To (SC - 1)) As Long
OST.Support.GetSupportNodes SupNode


Hope this works and your difficulty is solved.  

Best Wishes,

Jignesh V Chokshi

Back to top
View user's profile Send private message
rahul.leslie
General Sponsor
General Sponsor


Joined: 01 Apr 2008
Posts: 511
Location: Trivandrum

PostPosted: Sat Sep 07, 2024 9:46 am    Post subject: Reply with quote

ReDim nodesList(0 to (nNodes-1)) As Long
openSTAADObj.Geometry.GetNodeList nodesList


..wow, it worked 💪... thanks a lot, Jignesh sir 😊

I thought the GetNodeList function would re-dimension as well.

Rahul Leslie
Back to top
View user's profile Send private message Visit poster's website
BVRAO
General Sponsor
General Sponsor


Joined: 21 Sep 2009
Posts: 53

PostPosted: Sun Sep 08, 2024 6:33 pm    Post subject: Re: Open STAAD Reply with quote

[quote="JVCSNL"]Mr. Rao,


The OpenSTAADObj works well in VBA for sure.  It actually allow us to access the entire database rather than .std text file or .anl file having limited information.  It is better to use this object as it can be useful for updating the data within staad model itself through automation programs.



Thanks a lot
without knowing above OpenSTAADObj  


I have developed lot of code for STAAD  

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topicReply to topic Thank Post    www.sefindia.org Forum Index -> SEFI General Discussion All times are GMT
Page 1 of 1

 

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2003, 2008 SEFINDIA, Indian Domain Registration
Publishing or acceptance of an advertisement is neither a guarantee nor endorsement of the advertiser's product or service. advertisement policy