Thanks for your reply, however even after reading it’s not entirely clear to me.
I did some looking into the database info:
I wanted to check if I could read materials from a CDB file. Just to check if I understood the CDB structure, and the DLL’s interaction with it.
Using the Database info I could determine that I would find 2 materials. 1 concrete; 2 steel inside the 1/1 & 1/2 respectively.
When I go to look using code. It suddenly fails.
Here’s what I do. Can you perhaps find a flaw in my logic?
def get_db_entries(idx:int, kwh:int, kwl:int, data_type:type):
"""Get DB entries of provided kwh, kwl and datatype"""
import copy
logger.info(f"Looking in {kwh}/{kwl} for type:{data_type} in db: %s" % self.db_id)
db_id = idx
data_target = data_type() # create instande of datatype
data_len = c_int(sizeof(data_type)) # this also matches sizeof(data_target)
data_set = []
ie = c_int(0)
while ie.value < 2:
# INTERACTIONS is a global object that houses my loaded DLL and provides acces to my dll
ie.value = INTERACTIONS.cdb_get(db_id, kwh, kwl, byref(data_target), byref(data_len), 1)
data_len.value = sizeof(data_target) # new reclen
# copies the info at returned pointer into an object so that I can retain the information in a simple python list
data_copy = copy.copy(data_target)
data_set.append(data_copy)
if ie.value == 3:
return
logger.info("Get DB returned with ie: %s" %ie.value )
yield data_copy
logger.info("Get DB Entries exited with ie: %s" %ie.value )
I have a testfunction to verify my findings
def test_db_entries(db_id):
if does_key_exist(1, 1):
logger.info("Key exists")
# CMAT is an import from the sofistik_datan.py file
for entry in db.get_db_entries(db_id, 1, 1, CMAT):
logger.info("Found record %s" % entry)
What I do not understand is that my output looks somewhat like the following:
key exists
Looking for 1/1 for type CMAKE in db: 1
Get DB returned with ie: 3
Any ideas what I’m doing wrong? The keys SHOULD exist, since I can read them using the DB information.