Cancel
Showing results for 
Search instead for 
Did you mean: 

FEMAP API - SelectIDInSet method not working

Creator
Creator

FEMAP v11.3.2

I am trying to use the newer API method SelectIDInSet, but Femap dumps out of the program when it encounters the method. There is no error returned. Anyone else encountered this? Test script below.

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

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

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

	Dim nID As Long

	If nd2Set.Select( FT_NODE, True, "Select Nodes" ) <> FE_OK Then End

	App.feAppMessage( FCM_NORMAL, "Set " & CStr(nd2Set.ID))

    If ndSet.SelectIDInSet( FT_NODE, "Select a node in the set", nd2Set.ID, nID ) <> FE_OK Then End
    'ndSet.SelectIDInSet( FT_NODE, "Select a node in the set", nd2Set.ID, nID ) ' Tried removing If..End
    'ndSet.SelectID( FT_NODE, "Select a node in the set", nID ) ' Regular SelectID works

    App.feAppMessage( FCM_NORMAL, "Selected " & CStr(nID))

End Sub
5 REPLIES

Re: FEMAP API - SelectIDInSet method not working

Siemens Phenom Siemens Phenom
Siemens Phenom

This method is designed for Objects just as Results Sets, LoadSets and Constraint Sets - not Femap Set Objects.

 

Ex:


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

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

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

    Dim nID As Long

    Dim oSet As OutputSet
    Set oSet = App.feOutputSet

    oSet.Get(oSet.First)

    rc = ndSet.SelectIDInSet( FT_OUT_DIR , "Select a Vector in the set", oSet.ID, nID )
    'ndSet.SelectIDInSet( FT_NODE, "Select a node in the set", nd2Set.ID, nID ) ' Tried removing If..End
    'ndSet.SelectID( FT_NODE, "Select a node in the set", nID ) ' Regular SelectID works

    App.feAppMessage( FCM_NORMAL, "Selected " & CStr(nID))

End Sub

SelectIDInSet.png

Re: FEMAP API - SelectIDInSet method not working

Creator
Creator

Thanks RCatania for checking.

I realize in the API it states an example is an output vector, but almost all the verbiage in API for this method is the same as SelectID. The remarks state it can be used for nodes and elements. If it really isn't to be used for for all items like SelectID, then the API should state that. Currently the API looks like a cut/paste of SelectID with only minor changes. I expected it to function similarly. I was just trying the method out. I really just wanted to limit the nodes available for selection in a program I have. Was going to see if this method would do it.

selectidinset.png

Re: FEMAP API - SelectIDInSet method not working

Siemens Phenom Siemens Phenom
Siemens Phenom

Thank you for pointing that out.  We have updated the documentation to better reflect the use for this method.  In the meantime, I've created an API that mimics the behavior and hopefully dos what you are looking for:

 


'Make Objects Global
    Dim App As femap.model
    Dim ndSet As femap.Set
    Dim nd2Set As femap.Set
    Dim nID As Long, entity As Long, a As Long
    Dim i As Integer
    Dim msg() As Long
    Dim lists$()

Sub Main
    Set App = feFemap()
    Set ndSet = App.feSet
    Set nd2Set = App.feSet

    entity = FT_NODE
    ndSet.AddAll(entity)
    n = 0
    While ndSet.Next()
        ReDim Preserve lists$(n)
        lists$(n) = Str$( ndSet.CurrentID )
        n += 1
    Wend

    Begin Dialog UserDialog 100,100,200,203,"Select in Set",.DlgFunc ' %GRID:10,7,1,1
        TextBox 10,7,90,21,.TextBox1
        MultiListBox 10,35,180,133,lists(),.List
        OKButton 110,175,80,21
        PushButton 10,175,90,21,"Screen Pick",.Screen
        CheckBox 120,7,70,20,"Show",.CheckBox1
        CancelButton 160,140,30,14, .Cancel
    End Dialog
    Dim dlg As UserDialog
    'dlg.List = Array(0,0)
    Dialog dlg ' show dialog (wait for ok)

    On Error GoTo Skip
    For j = 0 To UBound(msg)
        App.feAppMessage(FCM_NORMAL,Str$(msg(j)))
    Next j
    Skip:

End Sub
'See DialogFunc help topic for more information.
Function DlgFunc(DlgItem$, Action%, SuppValue?) As Boolean
    Select Case Action%
    Case 1 ' Dialog box initialization
        Beep
        'SendKeys "{Enter}"
        'Hide the cancel button.
        DlgVisible "Cancel",False
    Case 2 ' Value changing or button pressed
        Select Case DlgItem$
            Case "OK"
                App.feViewRegenerate(0)
                If DlgFocus() <> "OK" Then
                    DlgFunc = True
                End If
                m = 0

                'Plan to Print Everything in Listbox if nothing highlighted
                On Error GoTo NoHighlight
                For m = 0 To UBound(lists)
                    ReDim Preserve msg(m)
                    msg(m) = Val(lists(m))
                Next

                'Overwrite with what's highlighted, otherwise use the whole listbox
                For m = 0 To UBound(DlgValue("List"))
                    ReDim Preserve msg(m)
                    msg(m) = Val(lists( DlgValue("List")(m) ))
                Next m
                NoHighlight:

            Case "Screen"
                DlgFunc = True
                    ndSet.Clear()
                    ndSet.Select(entity,True,"Select Sub-set")
                    Call ShowIt()
                    Call UpdateListBox()
                        DlgListBoxArray "list",lists$()
                        DlgFunc = True
            Case "CheckBox1"
                Call ShowIt()
            Case "Cancel","Esc"

                End
            Case Else
                DlgFunc = False
        End Select
    Case 3 ' TextBox or ComboBox text changed
        DlgFunc = True
        'DlgValue("List") = 0
        Call SingleID()
        Call ShowIt()
    Case 4 ' Focus changed
        Debug.Print "DlgFocus="""; DlgFocus(); """"
        DlgFunc = True
    Case 5 ' Idle
    Case 6 ' Function key
    End Select
End Function
Sub ShowIt()

If DlgValue("CheckBox1") = 1 Then
    ndSet.Show(entity)
Else
    App.feViewRegenerate(0)
End If

End Sub
Sub UpdateListBox()
'i must = integer for WinWrap ListBox types
i = 0
While ndSet.Next()
    ReDim Preserve lists$(i)
    lists$(i) = Str$(ndSet.CurrentID)
    i += 1
Wend
End Sub
Sub SingleID()
    ReDim Preserve lists$(0)
    lists$(0) = DlgText("TextBox1")
    DlgListBoxArray "list",lists$()
End Sub

Re: FEMAP API - SelectIDInSet method not working

Creator
Creator

Thanks RCatania for the clarification on this method and also the API script. The script gets me what I need, so thank you very much for your help.

I did get 2 type mismatch errors that had to be corrected. Trying to put strings in a Long Array.

api_correction.png

Re: FEMAP API - SelectIDInSet method not working

Siemens Phenom Siemens Phenom
Siemens Phenom

Good catch.  I was going back and forth on my String vs Long defintions so that's my mistake.  Interestingly, BASIC allowed me to get away with it on my end.  Anyway, I've updated the script above.