Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Femap API in Excel

Status
Not open for further replies.

Joel Pegg

Aerospace
Dec 11, 2020
1
Hi, I have been working in my free time in excel to create a database of materials that I can sort and quickly add to femap to save time. I accomplished this part pretty quickly and it has saved me and my colleagues quite a bit of time. Now I've grown tired of creating properties for screws and I'm trying to automate that as well. I've got everything working except it won't compute the shape properties. I'm new to femap and only have 3 months of experience I'm thinking the computestdshape is what I need but when I try to use it (note I'm doing everything from excel) it gives an error that it expects and an equal sign. any ideas would be helpful. code is below.

Public Sub Fastener()
Dim femap As Object
Dim tbl As ListObject
Set femap = GetObject(, "femap.model")
Set tbl = ActiveSheet.ListObjects("Fasteners")
Set tbl2 = Worksheets("Materials").ListObjects("Mats")
Dim feMatl As Object
Set feMatl = femap.feMatl
Dim feProp As Object
Set feProp = femap.feProp
Dim v As Variant
Dim i As Integer
Dim t As Variant
Dim j As Variant
Dim d As Double

tbl2.Range.AutoFilter _
Field:=2, _
Criteria1:="4340"

For i = 1 To tbl2.ListRows.Count
If tbl2.ListRows(i).Range.RowHeight > 0 Then
v = feMatl.mmat
feMatl.Title = tbl2.DataBodyRange(i, 1) & "-" & tbl2.DataBodyRange(i, 2) & " " & tbl2.DataBodyRange(i, 3)
v(49) = tbl2.DataBodyRange(i, 5)
v(0) = tbl2.DataBodyRange(i, 6)
v(6) = tbl2.DataBodyRange(i, 7)
v(52) = tbl2.DataBodyRange(i, 8)
v(85) = tbl2.DataBodyRange(i, 9)
v(84) = tbl2.DataBodyRange(i, 11)
feMatl.mmat = v
v = feMatl.imat
v(2) = 3
feMatl.imat = v
feMatl.Put (feMatl.NextEmptyID)


End If

Next i

tbl2.AutoFilter.ShowAllData

For i = 1 To tbl.ListRows.Count
If tbl.ListRows(i).Range.RowHeight > 0 Then
d = tbl.DataBodyRange(i, 3)

feProp.Title = "Fastener #" & tbl.DataBodyRange(i, 1) & tbl.DataBodyRange(i, 2) & " in Dia"
feProp.matlID = feMatl.ID
feProp.Type = 2
feProp.flagI(1) = 5
feProp.pval(40) = d
here is where i expect feProp.computestdshape needs to go but it doesn't want to work
feProp.Put (feProp.NextEmptyID)

End If

Next i

tbl.AutoFilter.ShowAllData

End Sub
 
Replies continue below

Recommended for you

The feComputeStdShape on the property object has multiple parameters. Are you sure that these are filled and filled properly? If they are, try adding an rc = feProp.ComputerStdShape(...). Does that fix the problem?

As an alternative to what you are doing, Femap has libraries for materials, properties and a couple others. These libraries can store saved properties that way you don't have to create them every time you start a new model. The Load and Save bottom toward the bottom of the property dialog box will bring you to the library dialog.

Library_save_load_o9fqdb.png


Here you can select a personal library that can be stored in any directory you would like. You can title the library whatever you would like. You can add to it as you need or modify what is existing in it.

Library_personal_properties_hervit.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor