Cancel
Showing results for 
Search instead for 
Did you mean: 

API Delete Specified Output Vectors

Pioneer
Pioneer

 

Hello,

 

I want to create an API that deletes a select set of output vectors. I am trying to use the feDeleteOutput method, but with no success. This program should mimick working within femap...

 

Delete -> Output -> Vector

 

Can someone help?

 

Thank you,

Samuel

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

    'Initialize output set
    Dim oSet As Set
    Set oSet = App.feSet
    'Initialize vector set
    Dim vSet As femap.Set
    Set vSet = App.feSet

    oSet.Add( 1)

    vSet.Add( 1)
    vSet.Add( 2)
	vSet.Add( 3)
	vSet.Add( 4)
	vSet.Add( 5)
	vSet.Add( 6)
	vSet.Add( 7)
	vSet.Add( 8)

	If App.feDeleteOutput( oSet.ID, vSet.ID ) = FE_FAIL		Then
		App.feAppMessage( FCM_WARNING, "Program Failed to Delete Output")

	End If

End Sub
8 REPLIES

Re: API Delete Specified Output Vectors

Siemens Phenom Siemens Phenom
Siemens Phenom

You didn't say which version of FEMAP you are using, however I'm pretty sure I see the issue.  It has to do with our unfortunate use of the word "Set" with multiple meanings. You called feDeleteOutput with the IDs of two Set objects. In fact, what feDeleteOutput wants is the ID of the Output Set itself and the ID of a Set Object containing the vectors you want to delete. 

 

So, you can either change the call to App.feDeleteOutput( OutputSetID, SetOfVectors.ID )  or you can use "feDeleteOutput2( OutputSetSet.ID, OutputVectorSet.ID )"... it takes the IDs of two Set objects, as you have originally coded ... so all you have to do is change feDeleteOutput to feDeleteOutput2. I believe this would be the best and simplest change given the code you have.

Re: API Delete Specified Output Vectors

Valued Contributor
Valued Contributor

Hi Sams,

 

in addition to solution proposed by Grudy  you could add feSelectOutput function to mimic Femap functionality.

 

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

    Dim oSet As Set
    Set oSet = App.feSet

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

    Dim outVec As femap.Output
    Set outVec = App.feOutput

    Dim rc As femap.zReturnCode

    rc = App.feSelectOutput("Select output vectors",0,FOT_ANY,FOC_ANY,FT_ELEM,True,oSet,vSet)

    If App.feDeleteOutput2( oSet.ID, vSet.ID ) = FE_FAIL		Then
		App.feAppMessage( FCM_WARNING, "Program Failed to Delete Output")
	End If

End Sub

Re: API Delete Specified Output Vectors

Pioneer
Pioneer

Hi Grudy,

 

Thank you for your response. Unfortunately I am using Femap version 11.0.1 so I do not have the feDeleteOutput2 method available. Could you send me an example of how to get the inputs needed for feDeleteOutput? I'm struggling to understand how to obtain the ID of the Output Set itself and the ID of a Set Object containing the vectors to delete.

 

Thank you,

Samuel

Re: API Delete Specified Output Vectors

Siemens Phenom Siemens Phenom
Siemens Phenom

Even without feDeleteOutput2( ) your code is basically correct.  

 

As I expect you are aware, Output/Results is stored in Output Sets... you can have many of these but they each have an ID and they can each contain many Ouptut Vectors. 

 

So, say you wanted to change your code to delete vectors from Output Set #7.  All you have to do is call 

 

The HTML Clipboard

    If App.feDeleteOutput( 7, vSet.ID ) = FE_FAIL       Then
        App.feAppMessage( FCM_WARNING, "Program Failed to Delete Output")

You can completely get rid of the "oSet" object.  If you need to delete the same vectors from multiple Output Sets, all you have to do is put this in a loop and instead of the first argument being "7", it would be a variable that increments to each set where you need to delete vectors .

 

Re: API Delete Specified Output Vectors

Pioneer
Pioneer

Thank you Grudy. I finally got what I wanted to work. Thanks for your help. Here's my code below:

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

    Dim oSet As femap.Set
    Set oSet = App.feSet
    Dim vsk As femap.Set
    Set vsk = App.feSet
    Dim vsd As femap.Set
    Set vsd = App.feSet
    'Dim oVec As femap.OutputSet
    'Set oVec = App.feOutputSet
    Dim RBO As Results
    Set RBO = App.feResults

    'Initialize some other variables
    Dim vecTitle As String

    App.feAppMessage( FCM_ERROR, "API: DeleteUnwanted.BAS" )

    'Add Output Sets to Delete
    oSet.AddAll( FT_OUT_CASE )

    'Add Output Vectors to Keep
    vsk.Add( 6060)	 'Laminate Max Failure Index
    vsk.Add( 7026)  'Plate Top MajorPrn Stress
    vsk.Add( 7027)  'Plate Top MinorPrn Stress
    vsk.Add( 7031)  'Plate Top MaxShear Stress
    vsk.Add( 7033)  'Plate Top VonMises Stress
    vsk.Add( 7426)  'Plate Bot MajorPrn Stress
    vsk.Add( 7427)  'Plate Bot MinorPrn Stress
    vsk.Add( 7431)  'Plate Bot MaxShear Stress
    vsk.Add( 7433)  'Plate Bot VonMises Stress
    vsk.AddRange( 900001, 900003, 1) 'Fx, Fy, Fxy
    vsk.AddRange( 900011, 900013, 1) 'Mx, My, Mxy
    vsk.AddRange( 900021, 900022, 1) 'Qx, Qy
    vsk.Add( 9000000)  'Weld RSS Running Load [lbs/in]

    'Create Set of Output Vectors to Delete
    vsd.AddAllExcept( FT_OUT_DIR, vsk.ID)

    'Delete output vectors
    oSet.Reset( )
    While oSet.Next( )
    	App.feDeleteOutput( oSet.CurrentID, vsd.ID )
    Wend

    App.feAppMessage( FCM_NORMAL, " ")
    App.feAppMessage( FCM_WARNING, "All Output Vectors Deleted Except For:" )

    'List the names of output vectors kept
    vsk.Reset( )
    While vsk.Next( )
    	'Get the Output Vector Names
    	RBO.VectorTitle( oSet.Count, vsk.CurrentID, vecTitle)
    	App.feAppMessage( FCM_NORMAL, Str$( vsk.CurrentID) + ": " + vecTitle)
    Wend

    'List total number of output sets that output vectors were deleted from
    App.feAppMessage( FCM_WARNING, "For" + Str$( oSet.Count) + " Output Sets")

End Sub

Re: API Delete Specified Output Vectors

Pioneer
Pioneer

Grudy,

 

Thank you for your previous help. The API I wrote works, but it is taking a long time looping through each output set and deleting the specified output vectors. Is there a way to speed up this process? Like delete all the specified output vectors from all output sets in one go without looping through? If I go through Femap menu options:

Delete -> Output -> Vector

the deletion process happens almost instantaneously.

Again, I don't have access to feDeleteOutput2( ) since I am using an older version of Femap.

 

Thanks

Sam

Sub Main

	'----------------------------------------------------------------------------------------------------------
	'07/29/2018
	'API deletes all output vectors EXCEPT those explicitly reserved in the code below
	'for ALL output sets
	'----------------------------------------------------------------------------------------------------------

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

    'Initialize variables
    Dim oSet As femap.Set
    Set oSet = App.feSet
    Dim vsk As femap.Set
    Set vsk = App.feSet
    Dim vsd As femap.Set
    Set vsd = App.feSet
    Dim RBO As Results
    Set RBO = App.feResults

    'Initialize some other variables
    Dim vecTitle As String

    App.feAppMessage( FCM_ERROR, "API: DeleteUnwanted.BAS" )

    'Add Output Sets to Delete
    oSet.AddAll( FT_OUT_CASE )

    'Add Output Vectors to Keep
    vsk.Add( 6060)	 'Laminate Max Failure Index
    vsk.Add( 7026)  'Plate Top MajorPrn Stress
    vsk.Add( 7027)  'Plate Top MinorPrn Stress
    vsk.Add( 7031)  'Plate Top MaxShear Stress
    vsk.Add( 7033)  'Plate Top VonMises Stress
    vsk.Add( 7426)  'Plate Bot MajorPrn Stress
    vsk.Add( 7427)  'Plate Bot MinorPrn Stress
    vsk.Add( 7431)  'Plate Bot MaxShear Stress
    vsk.Add( 7433)  'Plate Bot VonMises Stress

    'Create Set of Output Vectors to Delete
    vsd.AddAllExcept( FT_OUT_DIR, vsk.ID)

    'Delete output vectors
    oSet.Reset( )
    While oSet.Next( )
    	App.feDeleteOutput( oSet.CurrentID, vsd.ID )
    Wend

    App.feAppMessage( FCM_NORMAL, " ")
    App.feAppMessage( FCM_WARNING, "All Output Vectors Deleted Except For:" )

    'List the names of output vectors kept
    vsk.Reset( )
    While vsk.Next( )
    	'Get the Output Vector Names
    	RBO.VectorTitle( oSet.Count, vsk.CurrentID, vecTitle)
    	App.feAppMessage( FCM_NORMAL, Str$( vsk.CurrentID) + ": " + vecTitle)
    Wend

    'List total number of output sets that output vectors were deleted from
    App.feAppMessage( FCM_WARNING, "For" + Str$( oSet.Count) + " Output Sets")

End Sub
Highlighted

Re: API Delete Specified Output Vectors

Siemens Phenom Siemens Phenom
Siemens Phenom

Unfortunately, I don't think that there is a faster way given you are using V11.0.2. feDeleteOutput2( ) lets you do just what you want, and it will be fast.  However, it wasn't added until V11.3.  The problem you have with what you are doing isn't really the deletion time, it is simply the transactional overhead with calls thru OLE/COM. If you have a lot of Output Sets, then there are a lot of calls to feDeleteOutput( ). 

Re: API Delete Specified Output Vectors

Pioneer
Pioneer

Ok thank you. I guess its time to update versions. I'll talk to my boss Smiley Wink