SOFiSTiK Forum

It is currently Thu Nov 21, 2019 1:02 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CDBase CSECT_ADD
PostPosted: Wed Feb 24, 2016 5:52 pm 
Offline

Joined: Wed Jun 08, 2011 4:19 pm
Posts: 3
I am trying to access the additional section properties using the CDBase.

I managed to get the CSECT routine to work but have trouble with CSECT_ADD.

Attached is the excel file with the macro. Would appreciate if someone can help.

Thanks in advance.

Evan


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 Post subject: Re: CDBase CSECT_ADD
PostPosted: Fri Feb 26, 2016 10:24 am 
Offline

Joined: Thu Apr 23, 2015 8:49 am
Posts: 2
Hello Evanho,

Code:
Range("A" & StartRow & ":M5000").ClearContents
For CurSectAdd = StartSectNo To EndSectNo
    AddDataLen = Len(SectPropAdd)
    CDB_Return = sof_cdb_get(Index, 9, CurSectAdd, SectPropAdd.m_ID, AddDataLen, pos)
    If CDB_Return = 0 Then
        Range("A" & Counter + StartRow - 1) = CurSectAdd
        Range("B" & Counter + StartRow - 1) = SectPropAdd.m_YMIN
        Range("C" & Counter + StartRow - 1) = SectPropAdd.m_YMAX
        Range("D" & Counter + StartRow - 1) = SectPropAdd.m_ZMIN
        Range("E" & Counter + StartRow - 1) = SectPropAdd.m_ZMAX
        Counter = Counter + 1
   End If
Next CurSectAdd


For @Rec: 009/NR:4 SECT_ADD is the ID = 4 see below:
@0= ID [int] Identification = 4

Therefore you need to loop by using sof_cdb_get to end (return value = 2 -> end reached) and only if the SectPropAdd.m_ID = 4 store the values to your range.
You can do it this way:

Code:
'Read the values
Public Sub S_CSECT_ADD()
Dim datalen As Long
Dim cdbPath As String

    'Get the path from the cell
    cdbPath = "C:\examplePath\...\yourCDB.cdb"

    Index = sof_cdb_init(cdbPath, 99) 'connect to CDB, the variable cdbPath contains the path of the selected cdb
    If Index <= 0 Then
        MsgBox "Error, connection to the CDB failed"
        Exit Sub
    End If

    'Declare data
    Dim data As CSECT_ADD
    datalen = Len(data)
       
        Do While sof_cdb_get(Index, 9, 1, data, datalen, 1) < 2
            If data.m_ID = 4 Then                  'ID=4 for SECT_ADD
                MsgBox data.m_ID & " " & data.m_MRF & " " & data.m_AB & " " & data.m_AK & " " & data.m_AT   ' this is just an example
            End If
            datalen = Len(data)  ' this is also important to set the datalen before every sof_cdb_get
        Loop

        ' Close CDB
        Call sof_cdb_close(0)
End Sub


Also when you read the data, call the sof_cdb_flush and at end it is necessary to close the CDB. Because CDB locks can occur.
P.S. I would suggest that you use .xlsm Excel extension (Excel Macro-Enabled Workbook file.) and not the .xls

Kind regards,
Smiljan / STU


Top
 Profile  
 
 Post subject: Re: CDBase CSECT_ADD
PostPosted: Sun Feb 28, 2016 6:59 am 
Offline

Joined: Wed Jun 08, 2011 4:19 pm
Posts: 3
Hi Smiljan,

Thank you very much for the reply. That solved my problem.

Kind regards,
Evan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group