在他们发的工程里,我能用数组,他们的代码如下:
Private Sub BtnRunRFEM_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim application As IApplication = Nothing
Dim model As IModel = Nothing
Dim view As IView = Nothing
Try
' Creates New RFEM5 instance And gets it's interface.
application = New Global.Dlubal.RFEM5.Application()
'Shows RFEM GUI.
application.Show()
' Creates a new model and gets it's interface.
model = application.CreateModel("MyTestModel")
SetStructuralData(model)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Finally
labelInfo.Text = "Ready"
' View All
view = model.GetActiveView()
view.ShowAll()
view = Nothing
' Releases RFEM model interface.
model = Nothing
' Unlocks licence And releases RFEM application interface.
If application IsNot Nothing Then
application.UnlockLicense()
application = Nothing
End If
' Cleans Garbage Collector and releases all cached COM interfaces and objects.
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Try
End Sub
Private Sub SetStructuralData(ByVal model As IModel)
' Gets model data interface.
Dim modelData As IModelData = model.GetModelData()
' Allocates array of 4 nodes and sets theirs parameters.
Dim nodes() As Node = New Node(7) {}
nodes(0).No = 1
nodes(0).X = 0
nodes(0).Y = 0
nodes(0).Z = 0
nodes(1).No = 2
nodes(1).X = 8
nodes(1).Y = 0
nodes(1).Z = 0
nodes(2).No = 3
nodes(2).X = 18
nodes(2).Y = 0
nodes(2).Z = 0
nodes(3).No = 4
nodes(3).X = 26
nodes(3).Y = 0
nodes(3).Z = 0
nodes(4).No = 5
nodes(4).X = 0
nodes(4).Y = 6
nodes(4).Z = 0
nodes(5).No = 6
nodes(5).X = 8
nodes(5).Y = 6
nodes(5).Z = 0
nodes(6).No = 7
nodes(6).X = 18
nodes(6).Y = 6
nodes(6).Z = 0
nodes(7).No = 8
nodes(7).X = 26
nodes(7).Y = 6
nodes(7).Z = 0
' Allocates material variable and sets it's parameters.
Dim material() As Material = New Material(0) {}
material(0).No = 1
material(0).Description = "Beton C50/60 | DIN EN 1992-1-1/NA:2011-01"
' Allocates array of 3 lines for 3 members
Dim lines() As Line = New Line(9) {}
lines(0).No = 1
lines(0).NodeList = "1,2"
lines(0).Type = LineType.PolylineType
lines(1).No = 2
lines(1).NodeList = "2,3"
lines(1).Type = LineType.PolylineType
lines(2).No = 3
lines(2).NodeList = "3,4"
lines(2).Type = LineType.PolylineType
lines(3).No = 4
lines(3).NodeList = "5,6"
lines(3).Type = LineType.PolylineType
lines(4).No = 5
lines(4).NodeList = "6,7"
lines(4).Type = LineType.PolylineType
lines(5).No = 6
lines(5).NodeList = "7,8"
lines(5).Type = LineType.PolylineType
lines(6).No = 7
lines(6).NodeList = "1,5"
lines(6).Type = LineType.PolylineType
lines(7).No = 8
lines(7).NodeList = "2,6"
lines(7).Type = LineType.PolylineType
lines(8).No = 9
lines(8).NodeList = "3,7"
lines(8).Type = LineType.PolylineType
lines(9).No = 10
lines(9).NodeList = "4,8"
lines(9).Type = LineType.PolylineType
Dim tn As New SurfaceThickness
With tn
.Constant = 0.2
End With
Dim flaches() As Surface = New Surface(0) {}
flaches(0).No = 1
flaches(0).GeometryType = SurfaceGeometryType.PlaneSurfaceType
flaches(0).BoundaryLineList = "1,2,3,10,6,5,4,7"
flaches(0).MaterialNo = 1
flaches(0).Thickness = tn
' Allocates array of 2 nodal supports and sets theirs parameters.
Dim nodalSupports() As NodalSupport = New NodalSupport(0) {}
nodalSupports(0).No = 1
nodalSupports(0).NodeList = "1-10"
nodalSupports(0).SupportConstantX = -1
nodalSupports(0).SupportConstantY = -1
nodalSupports(0).SupportConstantZ = -1
nodalSupports(0).RestraintConstantX = 0
nodalSupports(0).RestraintConstantY = 0
nodalSupports(0).RestraintConstantZ = -1
' Writes all objects to the model.
modelData.PrepareModification()
Try
modelData.SetNodes(nodes)
modelData.SetMaterials(material)
modelData.SetLines(lines)
modelData.SetSurfaces(flaches)
modelData.SetNodalSupports(nodalSupports)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Finally
modelData.FinishModification()
End Try
End Sub
我自己建立了一个工程,引用了RFEM5,代码如下:
Imports Dlubal.RFEM5
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim application As IApplication = Nothing
Dim model As IModel = Nothing
Dim view As IView = Nothing
Try
' Creates New RFEM5 instance And gets it's interface.
application = New Global.Dlubal.RFEM5.Application()
'Shows RFEM GUI.
application.Show()
' Creates a new model and gets it's interface.
model = application.CreateModel("MyTestModel")
SetStructuralData(model)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
Finally
' View All
view = model.GetActiveView()
view.ShowAll()
view = Nothing
' Releases RFEM model interface.
model = Nothing
' Unlocks licence And releases RFEM application interface.
If application IsNot Nothing Then
application.UnlockLicense()
application = Nothing
End If
' Cleans Garbage Collector and releases all cached COM interfaces and objects.
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Try
End Sub
Private Sub SetStructuralData(ByVal model As IModel)
' Gets model data interface.
Dim modelData As IModelData = model.GetModelData()
' Allocates array of 4 nodes and sets theirs parameters.
Dim nodes() As Node = New Node(7) {}
nodes(0).No = 1
nodes(0).X = 0
...//相同代码略。
运行后出现如下对话框:
请教你了。