Cancel
Showing results for 
Search instead for 
Did you mean: 

API Create Load Cases Using Excel Spreadsheet

Pioneer
Pioneer

Hi

I am looking for the API to create Multiple load cases using API in Femap.

My Load cases will be in the Columns and Node ID will be in Rows. I will be using some Node ID multiple and Few have  Different Node ID's based on the load case as shown below

Load_Cases.png

Thank you

5 REPLIES

Re: API Create Load Cases Using Excel Spreadsheet

Pioneer
Pioneer

Any leads for the above problem?

 

Reagards

srini

Re: API Create Load Cases Using Excel Spreadsheet

Siemens Phenom Siemens Phenom
Siemens Phenom

Here is one way of doing it.  If you save your Excel sheet as a *.CSV file, you can read it in.  Below is an example of how you can take the "Load Case-X" and create Load Sets in Femap.

I will have some additional examples for you soon.

 

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

    '****************************************************************
    '   FEMAP Objects
    Dim Ls As LoadSet
    Dim Ld As LoadDefinition
    Dim Lm As LoadMesh
    Dim Rd As Read

    Set Ls = App.feLoadSet
    Set Ld = App.feLoadDefinition
    Set Lm = App.feLoadMesh
    Set Rd = App.feRead
    '****************************************************************

    Dim fName As String
    Dim i As Long
    Dim numL_Cases() As Long

    Dim LoadCaseRow As Variant, LoadComponentRow As Variant
    Dim DataString As Variant

    fName = GetFilePath$(,"CSV|*.csv") 'Windows Open Dialog

    '****************************************************************
    '                               WinWrap Read
    '****************************************************************
    Dim L
    i = 0
    Open fName For Input As #1
    For j = 0 To 3
        Line Input #1, DataString  'No length limit
        L = LOF(1) 'File length (in bytes)
'//         ' Read entire CSV into one Object: T$. Lose Line ability.
'//         'Dim L, T$
'//         'T$ = Input$(L,1)

        rc = FE_OK
        While rc = FE_OK
            On Error GoTo JumpOut
            t  = Trim$(Split(DataString,",")(i))
            L_Sets = Val( Replace(t,"Load Case-","") )  'Take the Number and make it an integer

            ReDim Preserve numL_Cases(i)
            numL_Cases(i) = L_Sets

            i += 1
        Wend
JumpOut:
    Next j
    Close #1

    For i = 0 To UBound(numL_Cases)-1
        Ls.Put(numL_Cases(i))
    Next

End Sub

Re: API Create Load Cases Using Excel Spreadsheet

Pioneer
Pioneer

Hi Catania

Thank you so much but it says the following error

 

"Basic Error (Line 34, Offset 0): (10053) Attempt to read past end-of-file."

Re: API Create Load Cases Using Excel Spreadsheet

Experimenter
Experimenter

Hi,

 

the attached Excel sheet does what you need (just list the load cases one below the other).

Re: API Create Load Cases Using Excel Spreadsheet

Pioneer
Pioneer

Hi Peter,

thank you so much for your attachment.  This is really excellent.

This is exactly what I am looking for.!!!

 

Regards

srini