Cancel
Showing results for 
Search instead for 
Did you mean: 

Listing Model Info to Data Table

Pioneer
Pioneer

Hi All.

 

Below I have a code to list model Info to a data table, the only problem I have is how do I get it to list all the info on one data table instead of it changing to 3 different data tables.

 

Thanks in advance.

 

The HTML Clipboard

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    Dim data As femap.DataTable
    Set data = App.feDataTable

    rc = data.Clear

    Dim ndSet As femap.Set
    Set ndSet = App.feSet

    Dim C1 As Variant 'Node IDs
    Dim C2 As Variant 'Node X
    Dim C3 As Variant 'Node Y
    Dim C4 As Variant 'Node Z
    Dim C5 As Variant 'Element IDs
    Dim C6 As Variant ' Property IDs
    Dim C7 As Variant 'Property Titles

    Dim xDisp As femap.Output
    Set xDisp = App.feOutput
    Dim yDisp As femap.Output
    Set yDisp = App.feOutput
    Dim zDisp As femap.Output
    Set zDisp = App.feOutput

    Dim feNode As femap.Node
    Set feNode = App.feNode
    Dim ndID As Long
    Dim count As Long
    Dim ndCount As Long

    Dim e As femap.Elem
    Set e = App.feElem
    Dim elemID As Long
    Dim elemCount As Long
    Dim count1 As Long
    Dim elemSet As femap.Set
    Set elemSet = App.feSet

    Dim p As femap.Prop
    Set p = App.feProp
    Dim propID As Long
    Dim propCount As Long
    Dim count2 As Long
    Dim propTitle As String
    Dim propSet As femap.Set
    Set propSet = App.feSet

    count = 0

    rc = ndSet.Select( FT_NODE, True, "Select Nodes to Add to Data Table" )
    ndCount = ndSet.Count
    If ndCount > 0 Then
        ReDim C1(ndCount) As Long
        ReDim C2(ndCount) As Double
        ReDim C3(ndCount) As Double
        ReDim C4(ndCount) As Double


        ndID = ndSet.First

        While ndID > 0
            rc = feNode.Get( ndID )
            C1(count) = ndID
            C2(count) = feNode.x
            C3(count) = feNode.y
            C4(count) = feNode.z

            count = count + 1
            ndID = ndSet.Next
        Wend

        Dim newColID As Long
        rc = data.AddColumn( False, False, FT_NODE, 0, "Node ID", FCT_INT, ndCount, C1, C1, newColID )
        rc = data.AddColumn( False, False, FT_NODE, 0, "Node X", FCT_DOUBLE, ndCount, C1, C2, newColID )
        rc = data.AddColumn( False, False, FT_NODE, 0, "Node Y", FCT_DOUBLE, ndCount, C1, C3, newColID )
        rc = data.AddColumn( False, False, FT_NODE, 0, "Node Z", FCT_DOUBLE, ndCount, C1, C4, newColID )

    End If

    count1 = 0

    rc = elemSet.Select( FT_ELEM, True, "Select Elements to Add to Data Table" )
    elemCount = elemSet.Count
    If elemCount > 0 Then
        ReDim C5(elemCount) As Long

        End If

        elemID = elemSet.First
        While elemID > 0
            rc = e.Get( elemID )
            C5(count1) = elemID

            count1 = count1 + 1
            elemID = elemSet.Next

        Wend


        rc = data.AddColumn( False, False, FT_ELEM, 0, "Element ID", FCT_INT, elemCount, C1, C5, newColID )

    count2 = 0

    rc = propSet.Select( FT_PROP, True, "Select Properties to Add to Data Table" )
    propCount = propSet.Count
    If propCount > 0 Then
        ReDim C6(propCount) As Long
        ReDim C7(propCount) As String

        propID = propSet.First
        While propID > 0
            rc = p.Get( propID )
            C6(count2) = propID
            C7(count2) = p.title

            count2 = count2 + 1
            propID = propSet.Next

        Wend


        rc = data.AddColumn( False, False, FT_PROP, 0, "Property ID", FCT_INT, propCount, C1, C6, newColID)
        rc = data.AddColumn( False, False, FT_PROP, 0, "Property Title", FCT_STRING, propCount, C1, C7, newColID )
    End If

End Sub