Etabs API using VBA



我不知道为什么在使用 Etabs API 文档中的代码时无法分配刚度值。

Sub Main()
'if the above flag is set to True, specify the path to ETABS below
Dim ProgramPath As String
''set it to the desired path of your model
Dim ModelDirectory As String
ModelDirectory = "C:CSi_ETABS_API_Example"
If Len(Dir(ModelDirectory, vbDirectory)) = 0 Then
MkDir ModelDirectory
End If
Dim ModelName As String
ModelName = "ETABS_API_Example.edb"
Dim ModelPath As String
ModelPath = ModelDirectory & Application.PathSeparator & ModelName
'create API helper object
Dim myHelper As cHelper
Set myHelper = New Helper
''dimension the ETABS Object as cOAPI type
Dim myETABSObject As cOAPI
Set myETABSObject = Nothing
''use ret to check return values of API calls
Dim ret As Long
On Error Resume Next
''get the active ETABS object
Set myETABSObject = GetObject(, "CSI.ETABS.API.ETABSObject")
If myETABSObject Is Nothing Then
If ProgramPath <> "" Then
''create an instance of the ETABS object from the specified path
Set myETABSObject = myHelper.CreateObject(ProgramPath)
Else
''create an instance of the ETABS object from the latest installed ETABS
Set myETABSObject = myHelper.CreateObjectProgID("CSI.ETABS.API.ETABSObject")
End If
''start ETABS application
myETABSObject.ApplicationStart
End If
''get a reference to cSapModel to access all OAPI classes and functions
Dim mySapModel As ETABS2016.cSapModel
Set mySapModel = myETABSObject.SapModel
''initialize model
ret = ret + mySapModel.InitializeNewModel()
''create steel deck template model
ret = ret + mySapModel.File.NewSteelDeck(1, 12, 12, 2, 2, 8, 8)
''Set release
Dim ii() As Boolean
Dim jj() As Boolean
Dim StartValue() As Double
Dim EndValue() As Double
ReDim ii(5)
ReDim jj(5)
ReDim StartValue(5)
ReDim EndValue(5)
ii(5) = True
jj(5) = True
StartValue(5) = 10000#
EndValue(5) = 10000#
ret = mySapModel.FrameObj.SetReleases("5", ii, jj, StartValue, EndValue)
''
''clean up variables
mySapModel = Nothing
myETABSObject = Nothing

结束子

在此处输入图像描述

代码可以设置发布,但不能分配值。 有没有办法解决它。 感谢您的任何帮助。

我想问题出在iijjStartValueEndValue的分配上。

需要更长的代码才能将每个值分配给这些数组。类似的东西

Dim StartValue(5) As Double, EndValue(5) As Double
Dim ii(5) As Boolean, jj(5) As Boolean
Dim i As Integer
'<If you need to make the 2 points released at M33 only>
'First: the DOFs with no release
For i = 0 To 4
StartValue(i) = 1
EndValue(i) = 1
ii(i) = False
jj(i) = False
Next i
'Second: the DOFs that have release
StartValue(5) = 0
EndValue(5) = 0
ii(5) = True
jj(5) = True

附言:无需使用ret = ret + Some_method形式,ret = Some_method就足以使您的方法起作用。

注意:-

部分固定性(我想这就是你所说的刚度(是01范围内的值,要为 M33 的部分固定度分配一个值,只需分配要StartValue(5)的值并EndValue(5)即可。

最新更新