can not import dwg-file

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

can not import dwg-file

Post by django013 »

Hello,

I downloaded some dwg-files and wanted to import them into fc.
I got this error popup:
FC-Error_001.png
FC-Error_001.png (18.92 KiB) Viewed 2266 times
fc-version:
OS: Debian GNU/Linux 8.1 (jessie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.5161 (Git)
Build type: Unknown
Branch: master
Hash: 48c25da133271a0caebec74427461f01c234c229
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
TeighaVersion.png
TeighaVersion.png (34.1 KiB) Viewed 2266 times
//Edith:
I found a workaround and converted all dwg files with Teiga outside of FC to dxf. DXF-Import then works ...
So no more help required.
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: can not import dwg-file

Post by yorik »

Usually this happens when there are non-ASCII characters in your file paths.. Teigha is very picky on that...
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: can not import dwg-file

Post by django013 »

Hi yorik,

thanks for that hint! You're right - path contains non-ASCII characters.
I use linux and utf-8 now for years and don't think about those limitations ...
... but yes, some apps (like meshlab and others) don't handle special characters right.

But ...
I had no problem with Teigha using the same path for conversion and Teigha did it.

Ah - I see :)
Just tried again - the log shows the problem:

Code: Select all

importDWG.insert(u"/home/xx/yy/Fr\xe4se-Selbstbau/FC/UNP 65.dwg","Unbenannt")
The name of downloaded file has space inside :O
May be the non-ASCII character is not the problem.

AFAIK if you quote the path with single quotes, it should do the trick - and the shell is outside.
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: can not import dwg-file

Post by yorik »

django013 wrote:AFAIK if you quote the path with single quotes, it should do the trick - and the shell is outside.
Are you sure? I always thought in python there is no difference between single and double quotes...
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: can not import dwg-file

Post by django013 »

Hi yorik

I'm sure, I don't know anything about python :O

... but I know linux and shell programming and every system call on linux systems involves a shell.
No matter what you do in python or c++ ... at the end a shell gets the path will all arguments. If at that stage, the arguments are not quoted, the shell starts to interpret each argument - and of cause, a space inside an argument will increase the number of arguments for the command called.
To prohibit the shell from any interaction, its best to have each argument embedded in single quotes.

... but quoted paths must match character code page from filesystem. There's no more codepage conversion then.

From python may be a good try, first embed each command argument in single quotes and then embed it into double quotes?
Don't know, whether it works that way - just an idea ...
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: can not import dwg-file

Post by yorik »

In any case, it's indeed worth trying to play with single/double quotes...
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: can not import dwg-file

Post by django013 »

Hi yorik,

could you please tell me some pointers where the call of the dwg-importer happens?
I'd like to have a look at it and do some tests.
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: can not import dwg-file

Post by PrzemoF »

That should be a good starting point for you:

Code: Select all

[przemo@localhost freecad]$ git grep dwg
Binary file src/Doc/freecad.qch matches
src/Mod/Arch/InitGui.py:                FreeCADGui.addPreferencePage(":/ui/preferences-dwg.ui","Import-Export")
src/Mod/Draft/InitGui.py:                FreeCADGui.addPreferencePage(":/ui/preferences-dwg.ui","Import-Export")
src/Mod/Draft/InitGui.py:App.addImportType("Autodesk DWG (*.dwg)","importDWG") 
src/Mod/Draft/InitGui.py:App.addExportType("Autodesk DWG (*.dwg)","importDWG")
src/Mod/Draft/Resources/Draft.qrc:        <file>ui/preferences-dwg.ui</file>
src/Mod/Draft/importDWG.py:def convertToDxf(dwgfilename):
src/Mod/Draft/importDWG.py:        indir = os.path.dirname(dwgfilename)
src/Mod/Draft/importDWG.py:        basename = os.path.basename(dwgfilename)
src/Mod/Draft/importDWG.py:def convertToDwg(dxffilename,dwgfilename):
src/Mod/Draft/importDWG.py:        outdir = os.path.dirname(dwgfilename)
src/Mod/Draft/importDWG.py:        return dwgfilename
Binary file src/Mod/Path/DemoParts/hole_puzzle.fcstd matches
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: can not import dwg-file

Post by django013 »

Thanks!

so after first look - how can I get the output of the print-statements?
No matter whether I enable python message redirection in fc or not - no print-message shows up :(
OS: Linux Debian Jessie amd64 - FC: Git Master
Post Reply