CDB Python read clc_poin_lpt

Hello,

This is my code for reading the free point load:

for LC in range(10000,10000+1):
    if py_sof_cdb_kexist(12, LC) == 2: # the key exists and contains data 12:global load 10000: LC 10000-10233
        ie = c_int(0)
        RecLen = c_int(sizeof(clc_poin))
        ie.value = py_sof_cdb_get(Index, 12, LC, byref(clc_poin), byref(RecLen), 1)
        #lpt = clc_poin.m_lpt
        p = clc_poin_lpt.m_p
        x = clc_poin_lpt.m_x
        RecLen = c_int(sizeof(clc_poin))

A similar code already works for reading another variable (rpar) but as rpar is a list and not a float it’s not completly comparable. I’ve checked print(ie.value) and it says 1. So the size of the data does not fit. Reading sofistik_daten I was wondering:

  1. How m_p,m_x,m_y and m_z can be adressed correctly as lpt in clc_poin is an array of them (clc_poin_lpt)?
  2. How I can get the right datatype or size for reading the values?

Here is the code from sofistik_daten which I import in my file:

class CLC_POIN_LPT(Structure):     #        loadpt
   _fields_ = [
         ('m_p', c_float),
         ('m_x', c_float),         # [1001] 
         ('m_y', c_float),         # [1001] 
         ('m_z', c_float)          # [1001] 
      ]
clc_poin_lpt = CLC_POIN_LPT()

class CLC_POIN(Structure):         # 12/LC:10?  Free point loads
   _fields_ = [
         ('m_kref', c_int),        #        Reference type
         ('m_nref', c_int),        #        Reference number
         ('m_tref', c_int * 3),    #        Reference text    (12 characters)
         ('m_typ', c_int),         #        type of load
         ('m_txt', c_int * 3),     #        Identifiying Text (12 characters)
         ('m_prz', c_float),       # [   8] Percentage of load covered with elements
         ('m_width', c_float),     # [1001] Tolerance load direction to match elements
         ('m_lpt',  CLC_POIN_LPT)  #        loadpt
      ]
clc_poin = CLC_POIN()

I’m doing it in two loops: first one with “abstract” stucture (it length is 1) and save first value kref (but mostly it name is id, name doesn’t care in general), then in second loop you can choose proper structure to get data. I’m sure this is not the best way to read the data, but work :slight_smile:

What do you mean with the second loop? Something like this (only loop over load case)? I don’t really know what to run the loop through or how to define the structure correctly. Maybe you mean looping over different point loads (not needed here because I only have this one). My problem is more how I deal with those two classes (clc_poin and clc_poin_lpt) as clc_poin_lpt doesn’t want to be called through a key.

for LC in range(10000,10000+1):
    if py_sof_cdb_kexist(12, LC) == 2: # the key exists and contains data 12:global load 10000: LC 10000-10233
        ie = c_int(0)
        RecLen = c_int(sizeof(clc_poin))
        ie.value = py_sof_cdb_get(Index, 12, LC, byref(clc_poin), byref(RecLen), 1)
        lpt = clc_poin.m_lpt
        p = clc_poin_lpt.(lpt).m_p
        x = clc_poin_lpt.(lpt).m_x
        y = clc_poin_lpt.(lpt).m_y
        z = clc_poin_lpt.(lpt).m_z
        RecLen = c_int(sizeof(clc_poin))

Ok, I think I got it now. When I call it like in the last post I get the message:
< sofistik_daten.CLC_POIN_LPT object at 0x... so I called it like this:

p=clc_poin.m_lpt.m_p

The answer for print(p) is 0.0 even though it should be 0.988091 but I think the code is right like this.