Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Using Check Sum Forces in API

Status
Not open for further replies.

tlemonds

Aerospace
Feb 1, 2014
20
0
0
US
Hey folks!

I'm attempting to use the Check Sum Forces tool in my API script. I'm a bit of rookie writing VBA but I have a little experience--but I have no experience writing VBA in the FEMAP API (as my pasted code probably shows). The goal of the script is to prompt the user to select a range of node IDs and have the Check Sum Forces tool sum the forces of the nodes around the global rectangular origin. I can't seem to get the feCheckSumForces2 command to work, I keep receive the error " Expecting '(' " for that line. Here is my code:

Sub Main
Dim model1 As femap.model
Dim set1 As femap.Set
Dim node1 As femap.Node

Set model1 = GetObject(,"femap.model")
Set set1 = model1.feSet
Set node1 = model1.feNode

set1.Select(FT_NODE,True,"Select Node(s)")

Do While set1.Next
node1.Get(set1.CurrentID)
Loop

Dim origin(2) As Long
Dim checkParam(3) As Boolean
origin(0) = 0 : origin(1) = 0: origin(2) = 0
checkParam(0) = False : checkParam(1) = False : checkParam(2) = True : checkParam(3) = True


Dim checkoutput(26) As femap.OutputSet
checkoutput.feCheckSumForces2(checkParam, set1, 0, 0, origin, 0)

End Sub



And for convenience, here is the help page on feCheckSumForces2 :

3.5.6.17 feCheckSumForces2

feCheckSumForces2

( useBodyLoad, expandGEOM, doLIST, useSETS, nodeSET, elemSET, loaddefSET, base­POINT, csysID, summedFORCES )

Description:

This function checks loads from the active load set and sums the forces around a specific location.

Input:

BOOL useBodyLoad
If True, body loads will be included in the calculation. If not, body loads will be ignored

BOOL expandGEOM
If True, geometric loads are expanded before the check. If not, non­expanded geometric loads will be ignored.

BOOL doLIST
If True, a summary report is written.

BOOL useSETS
If True, nodeSET and elemSET OR loaddefSET must specify the nodes and elements OR load definitions to consider in the summa­tion. To use nodeSET and elemSET, set loaddefSET = 0, otherwise, loaddefSET will be used. If False, the full model is used.

INT4 nodeSET
The ID of a selection set that contains the IDs of the nodes to check. Alternatively, if you specify a negative value, this is simply the ID of the single node to check. Only used if useSETS=True and loaddef­SET = 0

INT4 elemSET
The ID of a selection set that contains the IDs of the elements to check. Alternatively, if you specify a negative value, this is simply the ID of the single element to check. Only used if useSETS=True and loaddefSET = 0.

INT4 loaddefSET
The ID of a selection set that contains the IDs of the load definitions to check. Alternatively, if you specify a negative value, this is simply the ID of the single load definition. Only used if useSETS=True.

REAL8 basePOINT[0..2]
The coordinates of the location to sum about. Must be in global rect­angular coordinates.

INT4 csysID
The coordinate system used to report and returned the summed loads.

Output:

REAL8 summed­FORCES[0..26]
The results of the force summation. Entries [0..5] are the nodal force summations. [6..8] contain the elemental force summation. [9..14] contain the total summation. [15-17] contain body translational acceleration. [18-20] contain body varying translational acceleration. [21-23] contain body rotational acceleration. [24-26] contain body rotational velocity.

 
Replies continue below

Recommended for you

Hey tlemonds!

Hmmm yes a few mistakes in your code:
"Dim checkoutput(26) As femap.OutputSet" won't do, you can't dimension an outputset object (or at least i don't think you can), I doubt VB6 will allow you to turn an objet into an array

Next the method you use belongs to the "femap.model" object, not the outputset object

Then when VB6 expects values it refuses arrays. so your "checkparam" array won't do

Then the method you use sums loads, not NASTRAN output forces, not sure this is what you had in mind...

Here's a cleaned version of you code, but you need to clarify exactly what you want to do

AP

Sub Main
Dim App As femap.model
Set App = feFemap()

Dim v1 As Variant
Dim origin(2) As Long

Dim set1 As femap.Set
Set set1 = App.feSet

If set1.Select(FT_NODE,True,"Select Node(s)") = FE_CANCEL Then End
App.feCheckSumForces2(False,False,True,True,set1.ID,0,0,origin,0,v1)
End Sub
 
Thanks for the quick response!

I was able to get it running after my initial post. After working with someone in the office I saw how many obvious mistakes I was making! Anyway, I can get the Check Sum Forces tool to run now but not in the manner I was hoping to use it. Yes, I am simply trying to sum the forces applied on the nodes, not the resultant loads/stresses from those forces. However, I need to run through the range of nodes "backwards" in an increasingly cumalative way. For instance, let's say that I selected nodes 301 through 305 (five nodes) in set1. I would want to first sum just the last node (305) about its coordinates, then I would want to sum the last two nodes (304 & 305) about 304's coordinates, then I would want to sum the last three nodes (303, 304, & 305) about 303's coordinates, and so on.

I was hoping I could simply select the range as 305 to 301 instead of 301 to 305 to get set1 formatted the right way but it won't let me do that. I realize I then need to create another set that somehow collects the nodes from set1 "backwards".

Does what I am trying to accomplish make sense?

Updated code:

Sub Main
Dim model1 As femap.model
Dim set1 As femap.Set
Dim node1 As femap.Node
Dim coord(3) As Variant

Set model1 = GetObject(,"femap.model")
Set set1 = model1.feSet
Set node1 = model1.feNode

If set1.Select(FT_NODE,True,"Select Node(s)") = FE_CANCEL Then End
set1.ID = 1

Do While set1.Next
node1.Get(set1.CurrentID)
Loop

Dim length As Double
length = set1.Count

coord(0)=node1.x
coord(1)=node1.y
coord(2)=node1.z

Dim checkoutput As Variant
model1.feCheckSumForces2(False,False,True,True, set1.ID, 0, 0, coord, 0,checkoutput)

End Sub
 
To retrieve nodes in the order you select them, use a sort set:

Dim set1 As femap.SortSet
Set set1 = App.feSort
If set1.Select(FT_NODE,False,"Select nodes") = FE_CANCEL Then End

The rest of your code doesn't make much sense I'm afraid.
Your loop is closed by the "Loop" statement, therefore it is not properly placed. Your "length" has no use. Perhaps what you're looking for is something like:

While set1.Next
model1.feCoordOnNode(set1.CurrentID,coord)
model1.feCheckSumForces2(False,False,True,True, set1.ID, 0, 0, coord, 0,checkoutput)
Wend

But the problem with this is that it won't really work with th efact that you want to group certain nodes for summation.
You could insert an If statement but that would be tedious and not generic.
The best way to structure your code (from what I understand) might be this:

While the user doesn't press cancel
ask for a new node selection​
find the geometric center of this selection (mean coord)​
call checksumforces2 and cumulate resulting force​

i.e:

Dim App As femap.model
Set App = feFemap()

Dim v1 As Variant
Dim coord() As Double, checkoutput(2) As Double

Dim set1 As femap.SortSet
Set set1 = App.feSort

While set1.Select(FT_NODE,False,"Select nodes") <> FE_CANCEL
set1.Reset
ReDim coord(2)

While set1.Next
App.feCoordOnNode(set1.Current,v1)
For i = 0 To 2
coord(i) =coord(i)+v1(i)
Next
Wend

For i = 0 To 2
coord(i) =coord(i)/set1.Count
Next

model1.feCheckSumForces2(False,False,True,True,set1.ID,0,0,coord, 0,v1)

For i = 0 To 2
checkoutput(0) =checkoutput(0)+v1(0)
Next
Wend
 
Dissecting your suggested code right now. What does the "<>" do in this portion of code?

While set1.Select(FT_NODE,False,"Select nodes") <> FE_CANCEL
set1.Reset
ReDim coord(2)

 
Got it to work the way I wanted but just ONE thing! So I have the Check Sum Forces running through all selected nodes and all load sets. However, I would like to add the ability to select a specific range of load sets in the same manner that I selected a specific range of nodes. However, FEMAP doesn't like me trying to use the .Select command. I've tried both loadSet1.Select(FT_LOAD_DEFINITION, True, "Select Load Set(s)") as well as loadSet1.Select(FT_LOAD_DIR, True, "Select Load Set(s)") to no avail. Both get me the following error: API Error (Line 23): (10091) ActiveX Automation: no such property or method.

I could think of a few work-around methods to only select a specific range of load sets but does FEMAP really not have a more convenient way of doing that just like it allows me to do for node selection (bolded line of code below)?

Dim set1 As femap.Set
Dim node1 As femap.Node
Dim coord(2) As Variant
Dim set2 As femap.Set
Dim checkoutput As Variant
Dim myExcel1 As Object
Dim loadSet1 As femap.LoadSet

Set model1 = GetObject(,"femap.model")
Set myExcel1 = GetObject(, "Excel.Application")
Set set1 = model1.feSet
Set set2 = model1.feSet
Set loadSet1 = model1.feLoadSet
Set node1 = model1.feNode

If set1.Select(FT_NODE,True,"Select Node(s)") = FE_CANCEL Then End
set1.ID = 1
set2.ID = 2

loadSet1.Select(FT_LOAD_DIR, True, "Select Load Set(s)")
 
A little insight into (what I understand of) FEMAP's API logic: when you select entities (nodes, elements, loadcases...) you want to end up with a list of IDs, not a list of objects. That is a set! So the moethod you're thinking of is a set method, not a loadcase method. You already applied this logic to nodes: it is a set which selects them, not a node.

So:

Dim set1 As femap.Set
Set set1 = App.feSet

set1.SelectMultiID(FT_LOAD_DIR,1,"Select LoadCases")

quick tip: take advatage of the fact that FEMAP suggests available functionnalities as you write in the API window. When writing my Code above, FEMAP proposed these methods when I wrote only "set1.sel":
Select
SelectID
SelectIDInSet
SelectList
SelectMultiID
SelectOutputVectorID

Then got the the API help to learn about all these different methods.

AP
 
Status
Not open for further replies.
Back
Top