damian dad
Post on 14-Apr-2016
213 Views
Preview:
DESCRIPTION
TRANSCRIPT
12.01.2016 FE Programming
http://m3d.org.uk/Example10.htm 1/2
[ Contact ] [ Consultancy ] [ Free Finite Element Analysis Software ] [ Finite Element Programming ][ Femap Programming ] [ Nastran Pre & Post ] [ Tutorials ] [ Disclaimer ]
A Simple Femap API Program Tutorial: to automatically create a Femap loadset and apply some nodal forces.
Step 1 : Follow tutorial 4 to create the patch of element shown below:
the node labels are shown and range from 1 to 121
2) Create a new workbook and add a command button on sheet 1 as demonstrated in tutorial 1. Fill columns 1 to 4with dummy node id,Fx,Fy,Fz values to apply for nodes 1 to 121 as illustrated below:
3) The Code :
Option Explicit Private Sub CommandButton1_Click()Dim gfemap As ObjectDim LoadSet As ObjectDim Load As ObjectDim lLsetID As LongDim i As IntegerDim lNID As LongDim dFx As DoubleDim dFy As DoubleDim dFz As DoubleDim iRow As IntegerDim WS As WorksheetSet WS = ThisWorkbook.Worksheets(1)iRow = 2 'start row of our data in Excel
12.01.2016 FE Programming
http://m3d.org.uk/Example10.htm 2/2
Set gfemap = GetObject(, "femap.model") 'The open femap sessionSet LoadSet = gfemap.feLoadSet 'Set loadSet to a new femap feLoadSet objectSet Load = gfemap.feLoadMesh() 'set load to a femap loadmesh object which will hold the 'the force values at a particular node' Create the new load set in femaplLsetID = LoadSet.NextEmptyID 'Get a unique ID for the loadsetLoadSet.Title = "Dummy LSet" 'Name itLoadSet.Put (lLsetID) 'Put it into Femap'loop through all the data on the worksheetDo Until WS.Cells(iRow, 1) = "" lNID = WS.Cells(iRow, 1) 'The node id for the force dFx = WS.Cells(iRow, 2) 'The force values to apply at this node dFy = WS.Cells(iRow, 3) dFz = WS.Cells(iRow, 4) Load.meshID = lNID 'the node ID for this load Load.Type = 1 'load of type force Load.Load(0) = dFx 'set the force values Load.Load(1) = dFy Load.Load(2) = dFz Load.XOn = True 'make this dof active Load.YOn = True Load.ZOn = True Load.SetID = lLsetID 'attach this force to the loadset we created Load.Put (Load.NextEmptyID) 'put the load into femap iRow = iRow + 1 'next rowLoopEnd Sub
4) Do a regen in Femap and activate the loadset created, illustrated below:
[ Home ] [ Up ]
top related