API (vba): how to retrieve the section database a bar pertains to ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm stuck with a problem: I want to know the section database a bar comes from.
I've found a way to do it but it's incredibly time consuming (253 seconds for a 643 bars' model; 69 seconds for a 195 bars' model).
It's certainly due to "LoadFromDBase2" that reads data of the section found (and I don't need to read such data).
See code below.
Is there a way to quickly retrieve the section database a bar pertains to ?
Thanks in advance.
XD
--------------------------------------------------------------------------------------------------------------------------------------------
Sub Importer_barres()
Start = Timer
Dim RobApp As New RobotApplication
Dim AllBars As RobotBarServer
Dim AllNodes As RobotNodeServer
Dim CurrentBar As RobotBar
Dim EndNode As RobotNode
Dim StartNode As RobotNode
Dim BarSection As IRobotBarSectionData
Dim i As Long
Dim TNOB As Long ' Total number of bars
Dim CATA As String ' Catalogue de profilés
Dim MAT_BAR()
' ------------------------- Initialisation du serveur de barres ------------------------
' ------------------------------- et du serveur de noeuds ------------------------------
Set AllBars = RobApp.Project.Structure.Bars ' AllBars = Serveur avec toutes les barres
Set AllNodes = RobApp.Project.Structure.Nodes ' AllNodes = Serveur avec tous les noeuds
TNOB = AllBars.GetAll.Count ' TNOB = nb total de barres du modèle
If TNOB = 0 Then
MsgBox "Votre modèle ne contient aucune barre !", vbOKOnly, "ERROR"
Set AllBars = Nothing
Exit Sub
End If
' ----------------------- Enregistrement des barres dans MAT_BAR -----------------------
ReDim MAT_BAR(1 To TNOB, 1 To 9)
For i = 1 To TNOB
Set CurrentBar = AllBars.GetAll.Get(i)
Set StartNode = AllNodes.Get(CurrentBar.StartNode)
Set EndNode = AllNodes.Get(CurrentBar.EndNode)
Set BarSection = CurrentBar.GetLabel(I_LT_BAR_SECTION).Data
If BarSection.LoadFromDBase2(BarSection.Name, "AISC") Then
CATA = "AMERICAN"
ElseIf BarSection.LoadFromDBase2(BarSection.Name, "CHIN9") Then
CATA = "CHINESE"
ElseIf BarSection.LoadFromDBase2(BarSection.Name, "EURO") Then
CATA = "EUROPEAN"
ElseIf BarSection.LoadFromDBase2(BarSection.Name, "GOST") Then
CATA = "RUSSIAN (GOST)"
ElseIf BarSection.LoadFromDBase2(BarSection.Name, "KOREA") Then
CATA = "KOREAN"
End If
MAT_BAR(i, 1) = CurrentBar.Number ' N° de la barre
MAT_BAR(i, 2) = StartNode.Number ' Noeud de début
MAT_BAR(i, 3) = EndNode.Number ' Noeud de fin
MAT_BAR(i, 4) = CurrentBar.GetLabelName(I_LT_MEMBER_TYPE) ' Type de la barre
MAT_BAR(i, 5) = CurrentBar.LENGTH ' Longueur de la barre
MAT_BAR(i, 6) = BarSection.MaterialName ' Matière
MAT_BAR(i, 7) = BarSection.Name ' Section
MAT_BAR(i, 8) = CATA ' Catalogue
MAT_BAR(i, 9) = CurrentBar.Gamma ' Angle Gamma
Set CurrentBar = Nothing
Set BarSection = Nothing
Set EndNode = Nothing
Set StartNode = Nothing
CATA = Empty
Next i
' ---------------------- Libération des variables ne servant plus ----------------------
Set AllBars = Nothing
Set AllNodes = Nothing
TNOB = Empty
i = Empty
Finish = Timer
TotalTime = Finish - Start
MsgBox (TotalTime)
End Sub
