×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Adding and Exporting Groups to Data Table

Adding and Exporting Groups to Data Table

Adding and Exporting Groups to Data Table

(OP)

I'm new to this forum, and new to using the FEMAP API. I am having a few issues with creating a data table and populating it with the output for a selected set of elements, vectors, and outputs. I am trying to select the elements by selecting a group, and would like to loop through a selection of the groups. Is this possible, can someone take a look at my code and help/ point me in the right direction?

Here is my code thus far:
Sub Main
'Dimension the FEMAP Application Object
Dim App As femap.model
Set App = feFemap()
'Dimension Some Variables
Dim GI As Integer
Dim e As Variant
Dim s As femap.Set
Dim n As Integer
Dim m As Integer
Dim dt As femap.DataTable
Dim FileName As String
Dim g As femap.Set 'This should be a range of groups, i.e. Group 1, Group 2, Group 3
'Set Those Same Variables
Set s = App.feSet
Set e = App.feSet
Set g = App.feSet
Set dt = App.feDataTable 'Create a Data Table Object
rc = dt.Lock(False) 'Unlock the Data Table
If s.SelectMultiID(FT_OUT_CASE,1,"Select OutputSets") = FE_CANCEL Then End 'Select Output Sets Interested In
n = 1 'Set Initial Group Index, Possibly should be 0???
GI = g.Count()
Do While n <= GI 'Loop through all selected groups
m=1 'Set Initial Output Index
rc = dt.Clear() 'Clear Data Table
If e.Select(FT_ELEM,True, "Select Elements" ) = FE_CANCEL Then End 'Select All Elements in Group n
rc = dt.AddColumn(False,False,FT_ELEM, ) 'Do I need to Add Columns to populate data table
Do While m <= GI 'Loop Through All Output Sets, Vectors should be constant for each Output Set and Group, Is there a better way to do this
rc = dt.AddOutput(s,s,nC) 'Add Output to the Data Table
m = m + 1 'Step to Next Output Set
Loop
FileName=FilePath&"\Zone "&n&"\FEMAP_Output.txt" 'Look up File Path of Model and append path with Folder Name of Group, Folders previously defined outside of FEMAP
rc = Save(True,FileName,0) 'Save the Data Table to FileName
n = n + 1 'Step to Next Group
Loop
End Sub

Any help would be greatly appreciated.
Zane

RE: Adding and Exporting Groups to Data Table

(OP)
I've played around with the code a little bit, and have made some updates to it. Any thoughts on it?
Thanks in advance
Sub Main
'Dimension the FEMAP Application Object
Dim App As femap.model
Set App = feFemap()
'Dimension Some Variables
Dim GI As Integer
Dim e As Variant
Dim s As femap.Set
Dim n As Integer
Dim m As Integer
Dim dt As femap.DataTable
Dim FileName As String
Dim g As femap.Set 'This should be a range of groups, i.e. Group 1, Group 2, Group 3, perhaps use ReferencedGroups and All Elements should reference all groups
Dim v As Long
Dim nC As Long
Dim nCC As Long
Dim p As Integer
'Set Those Same Variables
Set s = App.feSet
Set e = App.feSet
Set g = App.feSet 'Should this be App.feGroup
Set v = App.feSet
Set dt = App.feDataTable 'Create a Data Table Object
rc = dt.Lock(False) 'Unlock the Data Table
'Still need to load group or groups into a set to loop through
If s.SelectMultiID(FT_OUT_CASE,1,"Select OutputSets") = FE_CANCEL Then End 'Select Output Sets Interested In
If v.SelectOutputVectorID("Select Output Vectors", 1,0,4,) = FE_CANCEL Then End
n = 1 'Set Initial Group Index, Possibly should be 0???
GI = g.Count() 'Count Length of Group Index
Do While n <= GI 'Loop through all selected groups
m = 1 'Set Initial Output Index, Possibly should be 0???
dt.Clear() 'Clear Data Table
e.AddGroup(FT_ELEM,n) 'Add all elements in Group to set e
Do While m <= GI 'Loop Through All Output Sets, Vectors should be constant for each Output Set and Group, Is there a better way to do this
'rc = dt.AddOutput(s,s,nC) 'I don't think this line is necessary, Add Output to the Data Table, API pg 833
p = 1 'Set Initial Vector Index to 1, Possibly should be 0???
Do While p <= Vector_Count 'Loop through all vectors in set
rc = dt.AddColumn(m,v(p),False,nC,nCC) 'Add First Vector to the data table, API pg 1139
p = p + 1 'Step to Next Vector
Loop
m = m + 1 'Step to Next Output Set
Loop
FileName=FilePath&"\Zone "&n&"\FEMAP_Output.txt" 'Look up File Path of Model and append path with Folder Name of Group, Folders previously defined outside of FEMAP
rc = Save(True,FileName,0) 'Save the Data Table to FileName
e.Clear() 'Clear element selection
n = n + 1 'Step to Next Group
Loop
End Sub






Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources