Professional Documents
Culture Documents
Agenda
Programming Outside the FEMAP
Sandbox
Creating FEMAP Programs with
Visual Studio
VB.Net and VC# Programs
Registering Applications in FEMAP
FEMAP and Microsoft Excel
Efficient FEMAP Programming
Techniques
2014-05-15
Word
VS
Femap
Excel
Matlab
SolidEdge
2014-05-15
2014-05-15
Add
Reference
to FEMAP
Library
Create
FEMAP
Application
Object
Associate
Application
Object with
a FEMAP
Session
Work with
FEMAP
Handle
Loss of
Application
Object
Scope
2014-05-15
Add
Reference
to FEMAP
Library
Create
FEMAP
Application
Object
Associate
Application
Object with
a FEMAP
Session
Work with
FEMAP
Handle
Loss of
Application
Object
Scope
Due to COM limitations, when using the FEMAP API via an external
program, only the first instance will be controlled (this limitation is no
longer present when using the API Programming Window)
Regardless of which type library version (ie 10.1,10.2, 10.3) is
referenced, when creating a new FEMAP instance programmatically,
the most recent version of FEMAP launched through the GUI will be
used
When the application object loses scope it must be dealt with
according to how its created
2014-05-15
Tip
Development is not limited to a paid version of VS. The free Express versions are
perfectly capable and, from a FEMAP standpoint, offer the same capabilities.
2014-05-15
Tip
If the FEMAP Type Library is not available in the Reference Manager, look for it in the
FEMAP install directory. The filename is femap.tlb
2014-05-15
2014-05-15
External connections to FEMAP can only be made to the FIRST open FEMAP instance
2014-05-15
2014-05-15
2014-05-15
VB.Net - Example
Example:
Dim app As femap.model
Dim fSurf As femap.Surface
Dim rc As zReturnCode
Dim ddInit(3) As Double
Dim ddProj() As Double
Dim odProj As Object
2014-05-15
VB.Net - Example
Example:
2014-05-15
2014-05-15
2014-05-15
2014-05-15
- Rather than using the fully qualified name for GetActiveObject, this can be
shortened to
femap.model App;
App = (femap.model) Marshal.GetActiveObject("femap.model");
2014-05-15
2014-05-15
VC#.Net - Example
Example:
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
femap;
System.Runtime.InteropServices;
namespace FEMAP_Sandboxes_VS2012
{
class Program
{
static void Main(string[] args)
{
femap.model App;
App = (femap.model)Marshal.GetActiveObject("femap.model");
femap.Set fs;
femap.Node fn;
fs = App.feSet;
fn = App.feNode;
2014-05-15
VC#.Net - Example
Example (continued):
object oNodeID;
object oXyz;
int[] nnNodeId;
double[] ddXyz;
int numNode;
fs.AddAll(zDataType.FT_NODE);
fn.GetCoordArray(fs.ID, out numNode, out oNodeID, out oXyz);
nnNodeId = (int[]) oNodeID;
oXyz = (double[]) oXyz;
App.feAppMessage(zMessageColor.FCM_COMMAND,
"First Node: " + nnNodeId[0].ToString());
}
}
}
2014-05-15
INT4 windowID
INT4 messageID
BOOL bPreventClose
BOOL bPreventHide
INT4 location
INT4 neighborID
ID of neighboring pane
0 main window, 1 message pane, 2 model info tree
3 entity info pane, 4 data table
Info
2014-05-15
End Sub
2014-05-15
2014-05-15
Tip
Access the Excel VBA environment with the keyboard shortcut ALT-F11
2014-05-15
2014-05-15
2014-05-15
2014-05-15
2014-05-15
2014-05-15
2014-05-15
2014-05-15
Efficient FEMAP Programming Techniques Tips on Reducing the Number of COM Calls
Many times, the greatest increase in program performance revolves around
reducing the overall number of COM calls
- Avoid using individual Get/Put calls for entities such as Node or Element that
have GetAll/PutAll methods
- Avoid repeatedly using the .Value method of the Output object use the
helper methods instead
- Avoid retrieving single items from the Results Browsing Object
- When possible, write native methods that can perform some of the same
functionality as FEMAP methods, such as the linear algebra methods
Info
The difference between 1,000 and 10,000 calls may not amount to much, but the
difference between 10,000 calls and 1,000,000 calls may be minutes or hours
2014-05-15
2014-05-15
2014-05-15