Brick6
Marine/Ocean
- May 8, 2013
- 5
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:
My code:
Any help is welcome!
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!