Python Interface: Material Title

I extract Material properties from a Sofistik Database. Looking at the database information, i should be able to read the title with cmat.m_title. But the information is extracted as an array with 17 integers. Which encoding is used to translate these integers into characters?


Check out the example in your installation folder:
C:\Program Files\SOFiSTiK\2020\SOFiSTiK 2020\interfaces\examples\python\python_3.x\number2string\

Hello sfr,
thanks for your answer. Unfortunately it is not working as expected for me.
Below is my code to get the Material Name with that string buffer.


The output is not showing the correct Titles. For some Material numbers there are no characters at all.

Although i can see the correct material title in the database info.

What am I missing?

In the example exchange lines:
ie.value = py_sof_cdb_get(Index, 12, 1, byref(clc_ctrl), byref(RecLen), 1)
myDLL.sof_lib_ps2cs(byref(cmat.m_rtex), byref(s), sizeof(s))
ie.value = py_sof_cdb_get(Index, 1, 1, byref(cmat), byref(RecLen), 1)
myDLL.sof_lib_ps2cs(byref(cmat.m_title), byref(s), sizeof(s))

You will get some junk, since you are only interested in records with id 0 (=Material title). So include a check for id number

Hey, I still get this weird output, where only one Material title is somewhat useable. For the other materials, I cant get anything reasonable. But the integer array seems to be correct. I dont understand the behavior of the string buffer. Its also not about the cdb. For other cdbs its similar behavior unfortunately. I would be very happy about any ideas what to do

Dear Paul,

please find attached a small example. Let me know if it did help out.
Try to use the function lng2txt(curLong, nrChar), in some cases you need to use nrChar = 2 and in some nrChar = 4.

Other solution would be to use the function sof_lib_ps2cs(). But I think that lng2txt is simpler to use.

P.S. I have renamed the extension of the PY file to DAT because of the upload policy of the forum. When you download it, just revert it back to .PY. (5.0 KB)

Kind regards,