Grasshopper

algorithmic modeling for Rhino

Hello,

I have huge difficulties importing a .dll file from the FE-program Sofistik to access the CDBase. 

For using the interface the function int sof_cdb_init  ( char* FileName, int Index); has to be run. I tried to add the necessary cdb_w_edu33_x64.dll to the assemblies, but I got nothing but the error: 

//Import failed for 'C:\beispielordner\cdb_w_edu33_x64.dll': Die Datei oder Assembly "file:///C:\beispielordner\cdb_w_edu33_x64.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Im Modul wurde ein Assemblymanifest erwartet.

I have no idea how to access the file xxx.cdb. 

Hopefully, someone has a clue. 

Regards; Konrad

Views: 1611

Replies to This Discussion

Hi Konrad,

I think that .dll is probably a C++ (native) .dll and not a .Net one. This means that you cannot just directly link it in the Grasshopper C# component. If this supposition is true, you need to write a wrapper for each call using P/Invoke. That task will be probably a major one, requiring large amounts of time to a committed developer.

It seems that Karamba and GeometryGym have modules to inter-operate with Sofistik. Or even the Sofistik-made 'Sofistik Rhinoceros Interface'.

Please have a look if any of these routes would be easier to take.

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hi Giulio,

thank you for the C++ hint. Presuming you are right it will be way out of my capacities to write the wrappers. I will see if GeometryGym can help me.

I want to know in GH if Sofistik is calculating by checking if the cdb is locked. Don't you know another way to get this information?

Thank you for your help.

Konrad

This is speculation from a hint given by the error message.

You can check more carefully with the dumpbin.exe answer here: http://stackoverflow.com/questions/5275985/is-this-dll-managed-or-u...

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

'checking if the cdb is locked': is 'the cdb' a file? Is it locked in terms of Windows files being locked?

yes, the cdb is a file. I think that are the same terms of locking, but I'm not sure about it.

Sofistik says in the Help: 

"The database for the SOFiSTiK programs is a proprietary system based on an indexsequential philosophy. This stands for a sequential access to data organized in logical records addressed by a key formed by two Integers.

CDBASE may be seen by the programmer as an unlimited number of sequential streams organized in the form of a linked list. Physically CDBASE is formed by a direct access diskfile with fixed record length and a memory buffer to enhance IO-Operations. For parallel access an enhanced version using pvm is available."

"Locking is done via special entries in the database and the possibilities provided by the operating system (lockd / SHARE etc.) The lowest level ensures that writing of directory entries or requesting dataspace is only possible by a single process at the same time.

The next level locks a complete key. If you write to a key you will lock implicitly all records within the key. Other processes may lock other keys at the same time. You may lock a key explicitly by a call, then have to remove the lock explicitly by an other call. The implicit locks created by a writing process is implicitly released by a read from the same process."

As for the initiation, a function returns current status of the database: int sof_cdb_status ( int Index ) 

the current status of the file with Index is returned

    Index       Index of DB
    Returnvalue Stat Bitpattern
                CD_STAT_AKTIV   (1) CDBase is active
                CD_STAT_OPEN    (2) Index is connected to file
                CD_STAT_SWAP    (4) File has ByteSwap
                CD_STAT_READ    (8) File has been read
                CD_STAT_WRITE  (16) File has been written
                CD_STAT_LOCK   (32) File has active locks
                CD_STAT_PVM    (64) File is opened via pvm server

I hope it answers your questions, I am very uncertain in this topic.

The cdb_w_edu33_x64.dll is definitely a native C dll so there is not way your can refer to it directly in the C# component.

The easiest way to use it inside the C# component is to use P/Invoke via the DllImport attribute. Basically you declare static C# methods whose content is imported from an native dll. Then you can use these C# methods inside your main code.

Hello Nguyen,

thank you for your answer. I will try to build that component and put here my efforts ;)

Konrad

Hello,

I'm facing the same issue but I'm using Python language.

Indeed, I'm trying to use the CdbInterface of sofistik to extract datas from a sofistik database xxx.cdb to Grasshopper. For that, the function sof_cdb_init (char*fileName, 99) has to be run. But it seems like it doesn't properly run. I don't have an explicit error message but I can recognise there is something wrong because instead of accessing to the database named "fileName", it creates a file which name is the first letter of "fileName" in the same directory but with no extension.

I really have no idea of how to access the database.

I hope someone can help me.

With kind regards

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service