2017-07-20 1 views
0

Ich weiß nicht, warum ich den Steifigkeitswert nicht zuweisen kann, wenn ich den Code aus der Etabs API-Dokumentation verwende.Etabs API mit VBA

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

enter image description here

Der Code die Freigabe einstellen kann, aber es nicht den Wert zuweisen können. Gibt es eine Möglichkeit, es zu beheben. Danke für jede Hilfe.

Antwort

0

Ich denke, das Problem liegt in der Zuordnung von ii, jj, StartValue und EndValue.

Es würde einen längeren Code benötigen, um diesen Arrays jeden Wert zuzuweisen. So etwas wie dieses

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. Keine Notwendigkeit, das Formular zu verwenden ret = ret + Some_method, ret = Some_method wäre genug, um nur Ihre Methode funktioniert.

Hinweis: -

Teileinspannung (Ich denke, das ist, was Sie von Steifigkeit bedeuten) ist ein Wert innerhalb des Bereichs zwischen und , um einen Wert zu M33 des Teileinspannung zuweisen, nur Weisen Sie die gewünschten Werte StartValue(5) und EndValue(5) zu.