我不知道为什么在使用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
End Sub
代码可以设置发布但不能分配值。 有没有办法解决它。 感谢您的帮助。
答案 0 :(得分:0)
我想问题出在ii
,jj
,StartValue
和EndValue
的分配上。
需要使用更长的代码将每个值分配给这些数组。像这样的东西
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
P.S。无需使用ret = ret + Some_method
表单,ret = Some_method
就足以让您的方法有效。
注意: -
部分固定性(我猜这是你的意思是刚度)是 0 和 1 之间的范围内的值,以指定价值为M33的部分固定性,只需将您想要的值分配到StartValue(5)
和EndValue(5)
。