×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

FEMAP API Woes - Element.GetGeomPropArray usage

FEMAP API Woes - Element.GetGeomPropArray usage

FEMAP API Woes - Element.GetGeomPropArray usage

(OP)
Hello Group.

I'm new to API usage/programming (and not much of a programmer in general), but have been trying to "Frankenstein" via examples a script that takes a selected group of elements, provides centroid coordinates and mass of each element, and essentially writes to a file a point cloud of element data that can be manipulated in Excel to generate distributed and cumulative axial and radial mass distributions for the selected element group. (Eventually I would like to perform the Excel operations in the script (sorting by coordinate bands, summing for each band, etc.), but first things first....).

Program is below. Note, for general information only, Z-direction is along FEM centerline, X and Y are transverse. I could make these variable, but for now plan to routinely set FEM up this way.

Things were going just fine until I added the "Dim mt" and "Set mt" definitions such that I could pull density for a named material and output that for the elements in a listing rather than just the material. (Actually, I later want to multiply that density by the element volume to produce an element mass value.) After that change, the Element.GetGeomPropArray operation seemed to product no meaningful information. Null (?) For example, after printing the numelem variable, the program returns "0". Program runs to completion without error messages in this case, but no output. And attempts to print other Element.GetGeomPropArray returned variables produces an error message regarding the variable.

Comment out the "Dim mt" and "Set mt" and respective operations, and remove rho from print request, and I get printed data for selected elements as expected.

I'm sure I am missing something very fundamental, but have spend hours trying to resolve. First resort is usually to do my best to work problem out for myself. Now becoming desperate.... winky smile

Any input would very much appreciated!

Thanks,
JD

=================

Sub Main

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

Dim mt As femap.Matl
Set mt = App.feMatl

Dim Element As femap.Elem
Set Element = App.feElem

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

Dim fName As String
Dim setID As Long
Dim numElem As Long
Dim entID As Variant
Dim propID As Variant
Dim matlID As Variant
Dim elemTYPE As Variant
Dim topology As Variant
Dim vCG As Variant
Dim vAXIAL As Double
Dim vRADIAL As Double
Dim length As Variant
Dim area As Variant
Dim volume As Variant
Dim rho As Double
Dim matNum As Variant

If App.feFileGetName( "Select File to Write Data To", "Text File (*.txt)", "*.txt", False, fName ) = FE_OK Then

Open fName For Output As #1

Print #1, "Element_ID " & " axial_distance " & " radial_distance " & " el_volume " & " material " & " density "

setID = 1

Element.setID=elSet.Select(FT_ELEM, True, "Select Elements to Include in Mass Distribution" )

Element.GetGeomPropArray(setID, numElem, entID, propID, matlID, elemTYPE, topology, vCG, length, area, volume)

REM Test Print
Print #1, numElem

For i = 0 To numElem - 1

vAXIAL=vCG(3*i+2)
vRADIAL=((vCG(3*i)^2)+(vCG(3*i+1)^2))^0.5
matNum = matlID(i)
mt.Get(matNum)
rho = mt.mval(49)

Print #1, entID(i) & " " & vAXIAL & " " & vRADIAL & " " & volume(i) & " " & matlID(i)& " " & rho
Next

Close #1

End If

End Sub

RE: FEMAP API Woes - Element.GetGeomPropArray usage

(OP)
=====================================================

Fix from other forum
https://community.plm.automation.siemens.com/t5/CA... :

Try this. You aren't that far off, but there were a few issues. First, most API calls return a return code...that should be tested for FE_OK..or some failure code, but not set into an ID like you had for the elSet.Select call. Secondly, and more importantly when an API call asks for the ID of a Set, you should always use SetObject.ID... in your case elSet.ID. You were passing the variable "setID" which you hard-coded to 1. I think that it just happened to work in your case before adding the "Dim mt...." code because elSet.ID must have been equal to 1. After you added that, it must have been something else and you weren't checking the elements you thought you were. Hope this helps.



The HTML Clipboard
Sub Main

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

Dim mt As femap.Matl
Set mt = App.feMatl

Dim Element As femap.Elem
Set Element = App.feElem

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

Dim fName As String
Dim numElem As Long
Dim entID As Variant
Dim propID As Variant
Dim matlID As Variant
Dim elemTYPE As Variant
Dim topology As Variant
Dim vCG As Variant
Dim vAXIAL As Double
Dim vRADIAL As Double
Dim length As Variant
Dim area As Variant
Dim volume As Variant
Dim rho As Double
Dim matNum As Variant

If App.feFileGetName( "Select File to Write Data To", "Text File (*.txt)", "*.txt", False, fName ) = FE_OK Then

Open fName For Output As #1

Print #1, "Element_ID " & " axial_distance " & " radial_distance " & " el_volume " & " material " & " density "

If elSet.Select(FT_ELEM, True, "Select Elements to Include in Mass Distribution" ) = FE_OK Then

If Element.GetGeomPropArray( elSet.ID, numElem, entID, propID, matlID, elemTYPE, topology, vCG, length, area, volume) Then

Print #1, numElem

For i = 0 To numElem - 1

vAXIAL=vCG(3*i+2)
vRADIAL=((vCG(3*i)^2)+(vCG(3*i+1)^2))^0.5
matNum = matlID(i)
If mt.Get(matNum) = FE_OK Then
rho = mt.mval(49)
Else
rho = 0.0
End If

Print #1, entID(i) & " " & vAXIAL & " " & vRADIAL & " " & volume(i) & " " & matlID(i)& " " & rho

Next

End If
End If

Close #1

End If

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources

eBook - Efficient and Effective Production Support with 3D Printed Jigs and Fixtures
Jigs and fixtures offer manufacturers a reliable process for delivering accurate, high-quality outcomes, whether for a specific part or feature, or for consistency across multiples of parts. Although the methodologies and materials for producing jigs and fixtures have evolved beyond the conventional metal tooling of years past, their position as a manufacturing staple remains constant due to the benefits they offer. Download Now
Overcoming Cutting Tool Challenges in Aerospace Machining
Aerospace manufacturing has always been on the cutting edge, from materials to production techniques. However, these two aspects of aerospace machining can conflict, as manufacturers strive to maintain machining efficiency with new materials by using new methods and cutting tools. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close