Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding and Exporting Groups to Data Table

Status
Not open for further replies.

zanestoy

Structural
Apr 25, 2012
10

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
 
Replies continue below

Recommended for you

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






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor