Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Custom Dockable Pane

Valued Contributor
Valued Contributor

I noticed that one of the new Custom Tools included in Femap 12 is a View Themes pane. Digging through the folder, I realized that this isn't an API script, but is instead an executable. Is there any documentation available for creating additional dockable pane executables from the Femap API?

10 REPLIES 10

Re: Custom Dockable Pane

Siemens Phenom Siemens Phenom
Siemens Phenom

The View Themes pane was created outisde of the Femap API. It was written in vb using visual studio. We don't currently have any documentation/tutorials for creating your own pane but this is something that we will try to create in the near future. 

Re: Custom Dockable Pane

Siemens Phenom Siemens Phenom
Siemens Phenom

If you author your application in Visual Studio, you can then run it embedded in FEMAP as a FEMAP Pane - details can be found in the API docs under - feAppRegisterAddInPane.

 

Mark.

Re: Custom Dockable Pane

Pioneer
Pioneer

 The "view theme" program can only link to the first femap program in memory while more then 1 femap program instances exist in memory, how can we overcome the shortcomings base on the current femap API interface? I have try some methods,eg, by Running object table and by WINDOWS API  AccessibleObjectFromWindow, but I can find no way. If we can link to the active femap instance in memory it will be perfect, we can utilize the more stronger language like vb.net/c++ as same as the internal script language winwrap basic to construct complex program. Could you give some advice?

Re: Custom Dockable Pane

Valued Contributor
Valued Contributor

Ah, okay. I don't suppose anyone has some example pre-compiled code that they could share just to get a feel for what a pane would look like? Unfortunately, my entire VB experience base is in VBA for Office and Femap, so I don't really know where to start in creating a standalone executable.

Re: Custom Dockable Pane

Siemens Phenom Siemens Phenom
Siemens Phenom

Create a new “Windows Forms App” in full Microsoft Visual Basic -Embed1.jpg

 

The first thing you want to do is connect to the FEMAP Type Library so that your programs knows about the FEMAP API.  Go to Project – Add Reference.  Go to the “COM” section, and search for and select the FEMAP Type Library, and in some cases, also choose which version you will be working with -

Embed2.jpg

Double-Click the blank form, and you will now see code associated with the form.  I put my global variables outside all the form stuff, but inside the class, and then add code to connect to FEMAP, hook our form into a FEMAP pane –

 

Public Class Form1
    Dim App As femap.model              'Global Variable to the FEMAP Connection/Sessions
    Dim AppLoaded As Boolean = False    'Global Variable True once the Pane has been registered and connected
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim rc As Long

        Try
            App = GetObject(, "femap.model") 'Connect to the active running FEMAP Session
        Catch ex As Exception
            MsgBox("Error Connectint to FEMAP, Exiting.....", MsgBoxStyle.OkOnly) 'If we can't connect exit gracefully
            Environment.Exit(0)
        End Try

        rc = App.feAppRegisterAddInPane(True, Me.Handle, Me.Handle, True, True, 2, 0) 'Hook our Form in as a FEMAP pane, last two arguments are 2 - dock right, 0 - to the FEMAP Main Windows
        If rc = femap.zReturnCode.FE_OK Then
            AppLoaded = True 'Yes we did it
        End If

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If AppLoaded Then
            App.feAppRegisterAddInPane(False, Me.Handle, Me.Handle, True, True, 2, 0) 'Disconnect our pane
        End If
        Close() 'Exit
    End Sub
End Class

 

 I always add an Exit button first, from the Toolbox, drag a button onto your form.  Center it, and then change its text to “Exit”.

Embed3.jpg 

Now double-click the button.  And you will be taken to the code associated with clicking that button –

Add the code for a clean close –

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If AppLoaded Then
            App.feAppRegisterAddInPane(False, Me.Handle, Me.Handle, True, True, 2, 0) 'Disconnect our pane
        End If
        Close() 'Exit
    End Sub

This is the skeleton for a FEMAP add in, you can now add whatever controls you require and the code behind them to add your custom functions to FEMAP.  Compile this into a .exe, and when it runs -

 

embed4.jpg

The FEMAP integrated development environment is really nice, but with Visual Basic from Microsoft you will have access to a wide array of controls and tools.  In addition, you can access VB.NET and some of the advanaced programming classes available there.  I recently used VB.NET to create a high speed data reader of customer calculated Grid Point Force Balance data.  In VB.NET, a FileStream and StreamReader were used to pull the file into memory for multiple passes, and HashTables were used for random data access.

 

Please let me know if you have any other questions.

 

Mark.

Re: Custom Dockable Pane

Valued Contributor
Valued Contributor

This is perfect! Thanks, Mark!

Re: Custom Dockable Pane

Valued Contributor
Valued Contributor

Not to push my luck, but do you happen to have any sample code that would actually demonstrate how the program exchanges data between Femap objects and .NET objects?

 

To give you some more background on what I'm doing: we stash our results sets as FNOs that we attach to our models for post-processing. Unfortunately, each time we reimport them, the native Nastran subcase IDs are lost, so we have to perform a very tedious renumbering exercise each time. I've created an Excel macro that allows us to pull results IDs and titles into excel, assign new IDs, and then have Femap batch renumber them. I think it would be more intuitive for my team if I could turn this into a native pane.

 

haha, I realize this is a very specific request, but in the absence of documentation, I'm shooting in the dark here.

Re: Custom Dockable Pane

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Hi andyperez,

 

Did you have something like this dockable pane in mind? You can essentially load all of your result IDs/titles into the data grid, then specify a new ID for each result and renumber them, all in FEMAP.

(view in My Videos)

Re: Custom Dockable Pane

Valued Contributor
Valued Contributor

haha, That is literally exactly what I had in mind! Could you share the code for that?