I am trying to read with C# script values of punching force V-Ed as shown in the picture below.
The code that I am using is shown below and also result that I get on the right side
In the CDB documentation, I found the struct cs_quad_rne with the property m_ved.
Does someone know if this is the correct location to get the punching force for three supports as in the picture above and why I am getting only zero values? Thanks for all your help and I apologize because of the picture size at the moment I am not able to upload larger picture
It isn’t always clear where or if things are stored in the cdb.
Try to find the stored values in your specific cdb using the database information tool:
You should find the punching force under 262/DC: V
thanks for the information. With 262 I was able to read V but only on the first node and for some reason, the loop stops at number 55 and it doesn’t return values on other nodes.
Below is the complete code. I know that there is something regarding the length of the loop but I am not able to understand how datalen variable works. Her value is 256 and the loop runs only 55 times
class Program
{
// sof_cdb_init
[DllImport("sof_cdb_w-2023.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sof_cdb_init(
string name_,
int initType_
);
// sof_cdb_close
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void sof_cdb_close(
int index_);
// sof_cdb_status
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_status(
int index_);
// sof_cdb_flush
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_flush(
int index_);
// sof_cdb_flush
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_free(
int kwh_,
int kwl_);
// sof_cdb_flush
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void sof_cdb_kenq_ex(
int index,
ref int kwh_,
ref int kwl_,
int request_);
// sof_cdb_get
[DllImport("sof_cdb_w-2023.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_get(
int index_,
int kwh_,
int kwl_,
ref cs_quad_nrp data,
ref int recLen_,
int pos);
static void Main(string[] args)
{
int index = 0;
int status = 0;
// Define the path of the dlls
string directory1 = @"C:\Program Files\SOFiSTiK\2023\SOFiSTiK 2023\interfaces\64bit";
string directory2 = @"C:\Program Files\SOFiSTiK\2023\SOFiSTiK 2023";
// Get the path
string path = Environment.GetEnvironmentVariable("path");
// Set the new path environment variable + SOFiSTiK dlls path
path = directory1 + ";" + directory2 + ";" + path;
// Set the path variable (to read the data from CDB)
System.Environment.SetEnvironmentVariable("path", path);
// Connect to CDB, int sof_cdb_init ( char* FileName, int Index);
// Always use index 99, for more details see cdbase.chm
index = sof_cdb_init(@"C:\Users\acadi\Desktop\Sofistik API\my cdb Example\my slab.cdb", 99);
if (index < 0)
{
Console.WriteLine("ERROR: Index = " + index + " < 0 - see clib1.h for meaning of error code");
return;
}
else if (index == 0)
{
Console.WriteLine("ERROR: Index = " + index + " - The file is not a database");
return;
}
// Check if sof_cdb_flush is working
status = sof_cdb_status(index);
// print index and status
Console.WriteLine("Index: " + index);
Console.WriteLine("Status: " + status);
Console.WriteLine();
// data
cs_quad_nrp data = new cs_quad_nrp();
// get the length of the structure
int datalen = System.Runtime.InteropServices.Marshal.SizeOf(typeof(cs_quad_nrp));
Console.WriteLine(datalen);
int count = 1;
while (sof_cdb_get(index, 262, 1, ref data, ref datalen, 1) == 0)
{
Console.WriteLine(string.Format("{0,-14}", count++)+
string.Format("{0,-14}", data.m_v));
// check again for the length
datalen = System.Runtime.InteropServices.Marshal.SizeOf(typeof(cs_quad_nrp));
}
// use sof_cdb_flush() and sof_cdb_close()
sof_cdb_flush(index);
// close the CDB
sof_cdb_close(0);
// Output the status after closing the CDB
Console.WriteLine();
if (sof_cdb_status(index) == 0)
Console.WriteLine("CDB Status = 0, CDB closed succesfully");
else
Console.WriteLine("CDB Status <> 0, the CDB doesn't closed successfully");
Console.Write("Press <ENTER> key to close the application...");
Console.ReadKey();
}
}