Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

FEMAP API - Extrude surface error 1

Status
Not open for further replies.

Brick6

Marine/Ocean
Joined
May 8, 2013
Messages
5
Location
NL
Dear all,

I'm writing an Excel VBA comment, which should automatically build a plane with stiffened panels. In drawing the curves, I succeed, however when I try to extrude these curves I cannot get my code working. Can somebody check what I am doing wrong?

My excel file:
Code:
Dimensions (mm)	L	B
Web	366	12
Flange	16	125
		
Number of stiffeners	3	
Deck longitudinal spacing	800	
		
Panel width	2400	
Web frame spacing	4500

My code:
Code:
Sub butBuilt_Click()
    
    Dim rc As Integer
    Dim ID As Integer
    Dim sID As Integer

    Dim app As Object
    Set app = GetObject(, "femap.model") 'Set model
    
    Dim WS As Worksheet
    Set WS = ThisWorkbook.Worksheets("Sheet1")

    rc = app.feDeleteAll(True, True, True, False) 'Delete old stuff
    
'Plane
    'Point #1
    Dim P As Object
    Set P = app.fePoint

    P.x = 0
    P.y = 0
    P.Z = 0
    
    ID = P.NextEmptyID
    rc = P.Put(ID)
    
    'Point #2
    P.x = WS.Cells(9, 3)
    P.y = 0
    P.Z = 0
    ID = P.NextEmptyID
    rc = P.Put(ID)

    'Line #1
    Dim Line As Object
    Set Line = app.feCurve
    
    Line.StdPoint(0) = P.PrevID
    Line.StdPoint(1) = P.NextEmptyID - 1

    ID = Line.NextEmptyID
    rc = Line.Put(ID)

'Web
    Dim i As Integer
    For i = 1 To WS.Cells(6, 3)
        'Point on plane
        P.x = WS.Cells(7, 3) / 2 + WS.Cells(7, 3) * (i - 1)
        P.y = 0
        P.Z = 0
        ID = P.NextEmptyID
        rc = P.Put(ID)
        
        'Point height web
        P.x = WS.Cells(7, 3) / 2 + WS.Cells(7, 3) * (i - 1)
        P.y = 0
        P.Z = WS.Cells(3, 3)
        ID = P.NextEmptyID
        rc = P.Put(ID)
        
        'Line web
        Line.StdPoint(0) = P.PrevID
        Line.StdPoint(1) = P.NextEmptyID - 1
    
        ID = Line.NextEmptyID
        rc = Line.Put(ID)
    Next
    
 'Flange
    For i = 1 To WS.Cells(6, 3)
        'Point west of flange
        P.x = WS.Cells(7, 3) / 2 + WS.Cells(7, 3) * (i - 1) - WS.Cells(4, 4) / 2
        P.y = 0
        P.Z = WS.Cells(3, 3)
        ID = P.NextEmptyID
        rc = P.Put(ID)
        
        'Point east of flange
        P.x = WS.Cells(7, 3) / 2 + WS.Cells(7, 3) * (i - 1) + WS.Cells(4, 4) / 2
        P.y = 0
        P.Z = WS.Cells(3, 3)
        ID = P.NextEmptyID
        rc = P.Put(ID)
        
        'Line flange
        Line.StdPoint(0) = P.PrevID
        Line.StdPoint(1) = P.NextEmptyID - 1
    
        ID = Line.NextEmptyID
        rc = Line.Put(ID)
    Next
    
'Create 3D model
    Dim curveSet1 As Object
    Set curveSet1 = app.feSet
    
    rc = curveSet1.Select(4, True, "Select") 'Select all curves
    curveSet1.ID = 1
    
    Dim dof(3) As Long
    Dim vdof As Variant
        
    dof(0) = 0
    dof(1) = -1
    dof(2) = 0
    vdof = dof
    
    rc = app.feSurfaceExtrude(1, 4500, vdof) '<-- does not work..
    
'Check

    If rc = -1 Then
        j = app.feAppMessage(1, "Done.")
    Else
        j = app.feAppMessage(3, "Failed.")
    End If

    app.feViewRegenerate (0)
    
End Sub

Any help is welcome!
 
Ok, solved it myself. Apparently there was something wrong with the datatype. The thread can be deleted if necessary.

Code:
'Create 3D model
    Dim curveSet1 As Object
    Set curveSet1 = app.feSet()
    
    rc = curveSet1.AddAll(4) 'Select all curves
    curveSet1.ID = 1
    
    Dim Dof(3) As Double
    Dim vDof As Variant
        
    Dof(0) = 0
    Dof(1) = 1
    Dof(2) = 0
    vDof = Dof
    
    rc = app.feSurfaceExtrude(1, 4500, vDof)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top