Let's talk about libredwg support

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Let's talk about libredwg support

Post by looo »

carlopav wrote: Sat Feb 29, 2020 11:41 am
looo wrote: Sat Feb 29, 2020 8:36 am Currently we ship libredwg with the appimage and dmg (0.19_pre).
Thanks for the quick explanation... so no chance to test it for me on windows, right?
I'll keep watching the thread since i'm really interested. Let me know if there's something i can help doing.
I tried to build libredwg on windows too but never succeeded. Not sure what was missing but if I remember correctly not much was missing.
But there should be builds for Windows available from the github libredwg directly. Maybe you want to try this build.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

Thx looo, I gave it a look but no idea how to even test it... :oops: I'll stay tuned.
follow my experiments on BIM modelling for architecture design
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Let's talk about libredwg support

Post by vocx »

carlopav wrote: Sat Feb 29, 2020 1:29 pm Thx looo, I gave it a look but no idea how to even test it... :oops: I'll stay tuned.
https://github.com/LibreDWG/libredwg/releases

In the releases page there seems to be a nightly build of libredwg. I guess you just download it, and it's some executable files that you can place wherever you want in your system PATH. Then you can test with the latest FreeCAD code.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

vocx wrote: Sat Feb 29, 2020 4:47 pm In the releases page there seems to be a nightly build of libredwg. I guess you just download it, and it's some executable files that you can place wherever you want in your system PATH. Then you can test with the latest FreeCAD code.
I did try, but without succeding... it seems i have a missing dll... i'll try again and eventually ask for support to @rurban, thanks!
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

Ok, I have libredwg up and running in windows. The package didn't have the libssp-0.dll included, once downloaded and placed in the libredwg directory, everything runs (thanks to rurban).
Now, where should i move the whole libdwg folder (with all the .exe files) to make FreeCAD use it?
EDIT: I can open a topic in help subforum if this is not the better place.
follow my experiments on BIM modelling for architecture design
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Let's talk about libredwg support

Post by vocx »

carlopav wrote: Wed Apr 01, 2020 8:23 pm ...
Now, where should i move the whole libdwg folder (with all the .exe files) to make FreeCAD use it?
Well, this is the discussion to make libredwg work with FreeCAD so your question should be here.

As to where to put it, you need to make sure the executable "dwg2dxf" is found somewhere in your system's PATH. So, where exactly that is depends on your system. You could place the libredwg directory wherever you want as long as it is included in the PATH. In Windows you can set the value of the PATH variable in the control panel, or somewhere like that.

Otherwise you just copy all libredwg files inside the bin/ directory that contains freecad.exe, as surely this folder is already in PATH.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

Yes! It's working :)
So, small guide for dummies:
  • Be sure to use at least a recent build of FreeCAD Version 0.19
  • Get libredwg precompiled for you win-32 or win-64, download and unzip it and place where you want in you system (es. C:\libredwg\)
  • Try to doubleclick on es. C:\libredwg\dwg2dxf.exe to see if it prompts strange errors. (I encountered a missing dll: libssp-0.dll; I had to download the DLL from internet and place it inside C:\libredwg\)
It should now be used when importing dwg files.
follow my experiments on BIM modelling for architecture design
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

Importing works quite good on very simple dwg, while exporting produces the following error:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Carlo\Desktop\fcnew\Mod\Draft\importDWG.py", line 108, in insert
    doc = importDXF.insert(dxf, docname)
  File "C:\Users\Carlo\Desktop\fcnew\Mod\Draft\importDXF.py", line 2814, in insert
    Import.readDXF(filename)
<class 'RuntimeError'>: File doesn't exist
follow my experiments on BIM modelling for architecture design
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Let's talk about libredwg support

Post by vocx »

carlopav wrote: Thu Apr 02, 2020 6:37 am ...
File "C:\Users\Carlo\Desktop\fcnew\Mod\Draft\importDXF.py", line 2814, in insert
Import.readDXF(filename)
In my system this line is 2817, so it means we have a different version?

This line is after a test for the "legacy importer". It means you are using the C++ importer. Check the Draft preferences, and choose "legacy" for both import and export.

In general, the "legacy" Python DXF importer code is pretty long and convoluted. It could use a serious re-write, and breaking it into smaller modules. Such rewrite would take several weeks and needs to be done very carefully to make sure nothing breaks.

What we need is a well formed DXF test file that we can convert easily from FreeCAD to DXF and back without problems; then we can use it to test the progress as we update the DXF importer.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Let's talk about libredwg support

Post by carlopav »

vocx wrote: Thu Apr 02, 2020 7:26 am This line is after a test for the "legacy importer". It means you are using the C++ importer. Check the Draft preferences, and choose "legacy" for both import and export.
Yes, I am, the python dxf importer is really slow... do you think it worths working on it or you think it would be better to just have one only improved C++ one?
follow my experiments on BIM modelling for architecture design
Post Reply