I am trying to get the maximum stress with the API object "findmaxminstress".
When I run the macro inside the API module works but not when I launch it from excel
I guess there is something wrong with Dim emax As zBeamCalculatorStressComponent definiton
Any idea? The code is below. The macro allos to select one element and 1 output set is automatically selected .
Dim femap As Object
Set femap = GetObject(, "femap.model")
Dim fe As Object
Set fe = femap.feElem
Dim fbc As Object
Set fbc = femap.feBeamCalculator
Dim fsE As Object
Set fsE = femap.feset
rc = fsE.Select(8, True, "select elements")
Dim nMaxSetID As Long
Dim nMinSetID As Long
Dim dmaxlocation As Double
Dim dminlocation As Double
Dim dmaxstress As Double
Dim dminstress As Double
Dim emax As zBeamCalculatorStressComponent
Dim emin As zBeamCalculatorStressComponent
fbc.element = fsE.ID
rc = fbc.FindMaxMinStress(-1, FBMC_SC_VONMISES, nMaxSetID, emax, dmaxlocation, dmaxstress, nMinSetID, emin, dminlocation, dminstress)
Solved! Go to Solution.
To use the API with Excel you really need to add a reference to the FEMAP Type Library. In some cases you can write simple APIs without doing this, but if you use any of the FEMAP data types like zBeamCalculatorStressComponent you will definitely need it. When you run an API from the FEMAP API window we automatically reference the Type Library, but of course Excel doesn't do that.
To do it in Excel, go to Tools->References and choose the "femap.tlb" that is in your installation directory. After you do that, your existing API will work just like it does in FEMAp.