A Simple Femap API Program Tutorial : to generate a rectangular patch of nodes.

1) Follow steps 1 to 4 in tutorial 1 to add a command button to the worksheet

2) The code :-

Option Explicit

Private Sub CommandButton1_Click()

Dim gfemap As Object

Dim oNode As Object

Dim i As Integer

Dim J As Integer

Dim iNID As Integer  ‘Will be used to count the node ID

Dim dx As Double

Dim dy As Double

Dim dz As Double

iNID = 1 ‘Start the node IDs at 1

‘The following line will connect gfeamp variable to the open femap

‘session. Using gfemap we can access all the functionallity of

‘femap from our VBA code.

Set gfemap = GetObject(, “femap.model”)

‘The next line connects oNode to the femap feNode object

Set oNode = gfemap.fenode

‘next count i & J to get some X.y values

For i = 0 To 10

  For J = 0 To 10

    dx = i * 0.1               ‘Create some x,y values for the nodes

    dy = J * 0.1

    dz = 0.5

    oNode.X = dx           ‘Set the X,Y,Z properties of the femap node object

    oNode.y = dy

    oNode.z = dz

    oNode.ID = iNID       ‘Set the node ID

    oNode.Put (iNID)      ‘Put the node back into femap at this ID location

    iNID = iNID + 1         ‘Increment the node ID

  Next J

Next i

End Sub

3) Exit design mode, press the command button  and do a Femap regenerate. You should have a patch of nodes as illustrated below:-