[Gambas-user] GauchoCAD + LibreDWG

Martin mbelmonte at belmotek.net
Mon Nov 2 02:32:37 CET 2020


- Yes it's correct, it has a substructure, but I don't know how to treat it.

- About implementing it on gambas, I have no idea whether it is 
convenient or not. I am honestly trying to do something, as the library 
promises a few features that would give the program a breakthrough. At 
the moment what I do is read the .txt file generated by a program called 
dwgread (present in test suite) and then treat it in gambas but that is 
very inefficient. What I want to do is directly extract the lists of 
entities, layers, blocks etc. and its properties to a collection in 
gambas to be able to recreate a model in memory and draw in OpenGL ant 
then alter.

Now is: Shell dwgread file.dwg > file.txt , gambas file.load(file.txt) > 
Collection

Future1:  gambas extern file.dwg > Collection

Future2:  gambas lib wraper fiile.dwg > Collection

- I attach one file dwg v2000 for testing.

- Regarding writing a container library in C.... Reini Urban 
<rurban at cpan.org> started this project on github (see below) but I don't 
know if it prospered and if it could serve as a guide for something. 
Take a look and see what you think.

https://github.com/LibreDWG/gambas3-bindings

Tanks

Regards.

Martín.


On 2/11/20 0:30, Jussi Lahtinen wrote:
> Again Dwg_Data contains substructures, which you replace with null 
> pointers.
> It really is not easy or small task to implement it on Gambas and I'm 
> not even sure it is necessary..?
> Do you have a working sample file for the sample project, so that I 
> could try if some simple tricks would work?
>
> Personally I would perhaps write a wrapper library in C, so that 
> libredwg would be easy to use in Gambas side.
>
>
> Jussi
>
>
> On Sun, Nov 1, 2020 at 8:13 PM Martin <mbelmonte at belmotek.net 
> <mailto:mbelmonte at belmotek.net>> wrote:
>
>     Well I made an little sample for research with the library because
>     GauchoCAD is more complex and difficult to follow the code.
>
>     I made an intent of structure translation but I fail again.
>
>     Please check the readme.md file in the project there are some info
>     relevant.
>
>     Regards.
>
>     On 1/11/20 4:19, Jussi Lahtinen wrote:
>>     Just a quick reply, I'll look it further when I have more time.
>>     It seems you are passing null pointer as an argument. Dwg_Data
>>     refers to a structure.
>>     See:
>>     https://git.savannah.gnu.org/cgit/libredwg.git/tree/include/dwg.h#n8846
>>     http://gambaswiki.org/wiki/lang/structdecl
>>
>>     Maybe you can just allocate the memory for it, instead of
>>     implementing it on Gambas.
>>     Also, please always send a project to demonstrate the problem,
>>     instead of snipped.
>>
>>     Jussi
>>
>>
>>
>>     On Sun, Nov 1, 2020 at 4:19 AM Martin <mbelmonte at belmotek.net
>>     <mailto:mbelmonte at belmotek.net>> wrote:
>>
>>         Hi.
>>
>>         First of all excuse 'nil' knowledge of C since I have just
>>         started trying to use the library with Extern, export or
>>         whatever is the correct name of the method.
>>         I made a module to try to do something with the C library in
>>         Gambas, but as expected it doesn't work :-(
>>
>>         Note: I am trying to read the number of layers in a dwg
>>         plane, I go step by step but the goal is to do many more things
>>         See please *dwg.h*
>>         https://git.savannah.gnu.org/cgit/libredwg.git/tree/include/dwg.h
>>
>>         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>         Library "/usr/local/lib/libredwg:0.0.11"
>>
>>         'EXPORT int dwg_read_file (const char *restrict filename,
>>         Dwg_Data *restrict dwg);
>>         Private Extern dwg_read_file(filename As String, Dwg_Data As
>>         Pointer) As Integer
>>
>>         'EXPORT int dxf_read_file (const char *restrict filename,
>>         Dwg_Data *restrict dwg);
>>         Private Extern dxf_read_file(filename As String, Dwg_Data As
>>         Pointer) As Integer
>>
>>         'EXPORT unsigned int dwg_get_layer_count (const Dwg_Data
>>         *restrict dwg);
>>         Private Extern dwg_get_layer_count(Dwg_Data As Pointer) As
>>         Integer
>>
>>         Public Function info(f As String) As Pointer
>>
>>           Dim info As Pointer
>>           Dim i As Integer
>>           Dim q As Integer
>>
>>           i = dwg_read_file(f, info)
>>
>>           q = dwg_get_layer_count(info)
>>
>>           Return q
>>
>>         End
>>         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>>         On 21/10/20 4:00, Jussi Lahtinen wrote:
>>>         What kind of help do you need?
>>>         Let's say example, this line:
>>>         Shell "/usr/local/bin/dwglayers -f '" & sFile & "' 2>&1 " To
>>>         sOut
>>>
>>>         The problem is to find equivalent function call(s) (in C)
>>>         from the API documentation. I personally don't have the time.
>>>         However, many here (including me) can help to translate the
>>>         C function calls to Gambas extern function calls, if that is
>>>         needed.
>>>
>>>         Jussi
>>>
>>>         On Wed, Oct 21, 2020 at 3:22 AM Martin
>>>         <mbelmonte at belmotek.net <mailto:mbelmonte at belmotek.net>> wrote:
>>>
>>>             Hi,
>>>             I am pleased to announce that GauchoCAD[1], which as you
>>>             know is a CAD
>>>             made with Gambas, is in good health, at the moment the
>>>             program is
>>>             capable of opening autocad DWG plans (thanks to
>>>             LibreDWG[2]) that close
>>>             LibreCAD[3].
>>>             We are using the library with the Shell instruction,
>>>             which is not the
>>>             best in terms of performance.
>>>             We need some help in order to do something with Extern
>>>             or directly a
>>>             gb.component that uses this library. Of course, if
>>>             someone does this it
>>>             will be useful for many other projects not just GauchoCAD.
>>>
>>>             We need read/write dwg and dxf files more efficiently
>>>
>>>             Here we are an script to install LibreDWG in the system
>>>
>>>                  #!/bin/bash
>>>                  git clone git://git.sv.gnu.org/libredwg.git
>>>             <http://git.sv.gnu.org/libredwg.git>
>>>                  cd libredwg
>>>                  sh autogen.sh
>>>                  ./configure --enable-trace
>>>                  make
>>>                  sudo make install
>>>                  make check
>>>                  cd ..
>>>
>>>             [1] https://github.com/tercoide/GauchoCAD
>>>
>>>             [2] https://www.gnu.org/software/libredwg/
>>>
>>>             [3] https://librecad.org/
>>>
>>>             Thanks.
>>>             Martin Belmonte
>>>
>>>
>>>             ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>
>>>
>>>         ----[http://gambaswiki.org/wiki/doc/netiquette  ]----
>>
>
>     ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201102/b6d9c2b6/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example_2000.dwg.tar.gz
Type: application/gzip
Size: 114079 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20201102/b6d9c2b6/attachment-0001.gz>


More information about the User mailing list